mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Fixed the get_module_data in the CLI tool for module data type string or incremental. TICKET: #1755
(cherry picked from commit f5a1e0ead12d96903fd55e82ac1c831a405b5ac2)
This commit is contained in:
parent
c21f16f923
commit
d733ab607c
@ -3463,7 +3463,16 @@ sub cli_stop_downtime () {
|
|||||||
# Related option: --get_module_data
|
# Related option: --get_module_data
|
||||||
###############################################################################
|
###############################################################################
|
||||||
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);
|
||||||
@ -3471,20 +3480,49 @@ sub cli_module_get_data () {
|
|||||||
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,
|
||||||
FROM tagente_datos
|
"SELECT id_tipo_modulo FROM tagente_modulo WHERE id_agente_modulo = ?;",
|
||||||
WHERE id_agente_modulo = $id_agent_module
|
$id_agent_module);
|
||||||
AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval)
|
|
||||||
ORDER BY utimestamp DESC");
|
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
|
||||||
|
WHERE id_agente_modulo = $id_agent_module
|
||||||
|
AND utimestamp > (UNIX_TIMESTAMP(NOW()) - $interval)
|
||||||
|
ORDER BY utimestamp DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach my $data_timestamp (@data) {
|
foreach my $data_timestamp (@data) {
|
||||||
print $data_timestamp->{'utimestamp'};
|
print $data_timestamp->{'utimestamp'};
|
||||||
print $csv_separator;
|
print $csv_separator;
|
||||||
@ -3492,7 +3530,7 @@ sub cli_module_get_data () {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user