Fixed the get_module_data in the CLI tool for module data type string or incremental. TICKET: #1755
This commit is contained in:
parent
2e2bc36138
commit
6ef2d3887b
|
@ -3490,25 +3490,63 @@ sub cli_stop_downtime () {
|
||||||
sub cli_module_get_data () {
|
sub cli_module_get_data () {
|
||||||
my ($agent_name, $module_name, $interval, $csv_separator) = @ARGV[2..5];
|
my ($agent_name, $module_name, $interval, $csv_separator) = @ARGV[2..5];
|
||||||
|
|
||||||
|
$csv_separator = '|' unless defined($csv_separator);
|
||||||
|
|
||||||
|
if ($interval <= 0) {
|
||||||
|
print_log "[ERROR] Interval must be a possitive value\n\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
my $agent_id = get_agent_id($dbh,$agent_name);
|
my $agent_id = get_agent_id($dbh,$agent_name);
|
||||||
exist_check($agent_id, 'agent name', $agent_name);
|
exist_check($agent_id, 'agent name', $agent_name);
|
||||||
|
|
||||||
my $module_id = get_agent_module_id($dbh, $module_name, $agent_id);
|
my $module_id = get_agent_module_id($dbh, $module_name, $agent_id);
|
||||||
exist_check($module_id, 'module name', $module_name);
|
exist_check($module_id, 'module name', $module_name);
|
||||||
|
|
||||||
if($interval <= 0) {
|
|
||||||
print_log "[ERROR] Interval must be a possitive value\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$csv_separator = '|' unless defined($csv_separator);
|
|
||||||
|
|
||||||
my $id_agent_module = get_agent_module_id ($dbh, $module_name, $agent_id);
|
my $id_agent_module = get_agent_module_id ($dbh, $module_name, $agent_id);
|
||||||
|
|
||||||
my @data = get_db_rows ($dbh, "SELECT utimestamp, datos
|
my $module_type_id = get_db_value($dbh,
|
||||||
|
"SELECT id_tipo_modulo FROM tagente_modulo WHERE id_agente_modulo = ?;",
|
||||||
|
$id_agent_module);
|
||||||
|
|
||||||
|
my $module_type = get_db_value($dbh,
|
||||||
|
"SELECT nombre FROM ttipo_modulo WHERE id_tipo = ?",
|
||||||
|
$module_type_id);
|
||||||
|
|
||||||
|
my @data = NULL;
|
||||||
|
if ($module_type eq "log4x") {
|
||||||
|
@data = get_db_rows ($dbh, "SELECT utimestamp, datos
|
||||||
|
FROM tagente_datos_log4x
|
||||||
|
WHERE id_agente_modulo = $id_agent_module
|
||||||
|
AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval)
|
||||||
|
ORDER BY utimestamp DESC");
|
||||||
|
}
|
||||||
|
elsif ($module_type =~ m/_string/) {
|
||||||
|
print("aaaa\n");
|
||||||
|
@data = get_db_rows ($dbh, "SELECT utimestamp, datos
|
||||||
|
FROM tagente_datos_string
|
||||||
|
WHERE id_agente_modulo = $id_agent_module
|
||||||
|
AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval)
|
||||||
|
ORDER BY utimestamp DESC");
|
||||||
|
}
|
||||||
|
elsif ($module_type =~ m/_inc$/) {
|
||||||
|
@data = get_db_rows ($dbh, "SELECT utimestamp, datos
|
||||||
|
FROM tagente_datos_inc
|
||||||
|
WHERE id_agente_modulo = $id_agent_module
|
||||||
|
AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval)
|
||||||
|
ORDER BY utimestamp DESC");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
@data = get_db_rows ($dbh, "SELECT utimestamp, datos
|
||||||
FROM tagente_datos
|
FROM tagente_datos
|
||||||
WHERE id_agente_modulo = $id_agent_module
|
WHERE id_agente_modulo = $id_agent_module
|
||||||
AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval)
|
AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval)
|
||||||
ORDER BY utimestamp DESC");
|
ORDER BY utimestamp DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach my $data_timestamp (@data) {
|
foreach my $data_timestamp (@data) {
|
||||||
print $data_timestamp->{'utimestamp'};
|
print $data_timestamp->{'utimestamp'};
|
||||||
|
|
Loading…
Reference in New Issue