From a90f94c9a5ff3d2bd4c5a380bec9a7c2ef4cdea6 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 17 Apr 2009 11:52:28 +0000 Subject: [PATCH] 2009-04-17 Ramon Novoa * lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Properly set module interval when auto-creating modules. * lib/PandoraFMS/NetworkServer.pm: Disabled error messages from snmpget. The logs where flooded with timeout messages. * util/pandora_db.pl: Updated to work with the new code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1626 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 10 ++++++++++ pandora_server/lib/PandoraFMS/Core.pm | 8 ++++---- pandora_server/lib/PandoraFMS/DataServer.pm | 9 +++++---- pandora_server/lib/PandoraFMS/NetworkServer.pm | 2 +- pandora_server/util/pandora_db.pl | 4 ++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index ec5ded755d..c2d21f7d62 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,13 @@ +2009-04-17 Ramon Novoa + + * lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Properly set + module interval when auto-creating modules. + + * lib/PandoraFMS/NetworkServer.pm: Disabled error messages from + snmpget. The logs where flooded with timeout messages. + + * util/pandora_db.pl: Updated to work with the new code. + 2009-04-17 Ramon Novoa * lib/PandoraFMS/PluginServer.pm, lib/PandoraFMS/PredictionServer.pm, diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 04f147d017..a4e4b5fcfb 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -705,17 +705,17 @@ sub pandora_audit ($$$$$) { #Create a new entry in tagente_modulo and the corresponding entry in #tagente_estado. ########################################################################## -sub pandora_create_module ($$$$$$$) { +sub pandora_create_module ($$$$$$$$) { my ($agent_id, $module_type_id, $module_name, $max, - $min, $description, $dbh) = @_; + $min, $description, $interval, $dbh) = @_; # Provide some default values $max = 0 if ($max eq ''); $min = 0 if ($min eq ''); $description = 'N/A' if ($description eq ''); - my $module_id = db_insert($dbh, 'INSERT INTO tagente_modulo (`id_agente`, `id_tipo_modulo`, `nombre`, `max`, `min`, `descripcion`, `id_modulo`) - VALUES (?, ?, ?, ?, ?, ?, 1)', $agent_id, $module_type_id, $module_name, $max, $min, $description); + my $module_id = db_insert($dbh, 'INSERT INTO tagente_modulo (`id_agente`, `id_tipo_modulo`, `nombre`, `max`, `min`, `descripcion`, `module_interval`, `id_modulo`) + VALUES (?, ?, ?, ?, ?, ?, ?, 1)', $agent_id, $module_type_id, $module_name, $max, $min, $description, $interval); db_do ($dbh, 'INSERT INTO tagente_estado (`id_agente_modulo`) VALUES (?)', $module_id); return $module_id; } diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 7cb57173b4..042268212a 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -186,7 +186,7 @@ sub process_xml_data { # Single data if (! defined ($module_data->{'datalist'})) { my $data_timestamp = (defined ($module_data->{'timestamp'})) ? $module_data->{'timestamp'}->[0] : $timestamp; - process_module_data ($pa_config, $module_data, $agent_name, $module_name, $module_type, $data_timestamp, $dbh); + process_module_data ($pa_config, $module_data, $agent_name, $module_name, $module_type, $interval, $data_timestamp, $dbh); next; } @@ -213,8 +213,9 @@ sub process_xml_data { ########################################################################## # Process module data, creating module if necessary. ########################################################################## -sub process_module_data ($$$$$$$) { - my ($pa_config, $data, $agent_name, $module_name, $module_type, $timestamp, $dbh) = @_; +sub process_module_data ($$$$$$$$) { + my ($pa_config, $data, $agent_name, $module_name, + $module_type, $interval, $timestamp, $dbh) = @_; my $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE nombre = ?', $agent_name); return unless defined ($agent); @@ -229,7 +230,7 @@ sub process_module_data ($$$$$$$) { $min = $data->{'min'}->[0] if (defined ($data->{'min'})); $description = $data->{'description'}->[0] if (defined ($data->{'description'})); pandora_create_module ($agent->{'id_agente'}, $module_id, $module_name, - $max, $min, $description, $dbh); + $max, $min, $description, $interval, $dbh); $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND nombre = ?', $agent->{'id_agente'}, $module_name); return unless defined $module; } diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index 15c17c6780..ddebe8c09d 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -335,7 +335,7 @@ sub pandora_query_snmp (%$$$$$) { $_[5] = 0; my $snmpget_cmd = $pa_config->{"snmpget"}; - my $output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -c $snmp_community $snmp_target $snmp_oid`; + my $output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -c $snmp_community $snmp_target $snmp_oid 2>/dev/null`; if ($output eq ""){ $_[5] = 1; } diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 49f7a6beb0..2208217025 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -117,10 +117,10 @@ sub pandora_purgedb { $dbh->do ("DELETE FROM tagente_modulo WHERE delete_pending = 1"); print "[PURGE] Delete old session data \n"; - db_do ("DELETE FROM tsesion WHERE utimestamp < $ulimit_timestamp", $dbh); + $dbh->do ("DELETE FROM tsesion WHERE utimestamp < $ulimit_timestamp"); print "[PURGE] Delete old data from SNMP Traps \n"; - db_do ("DELETE FROM ttrap WHERE timestamp < '$limit_timestamp'", $dbh); + $dbh->do ("DELETE FROM ttrap WHERE timestamp < '$limit_timestamp'"); $dbh->disconnect(); }