From 37ea4a197a756e112b0decd8c38abcab63658a7e Mon Sep 17 00:00:00 2001 From: ramonn Date: Wed, 28 Nov 2012 19:41:24 +0000 Subject: [PATCH] 2012-11-28 Ramon Novoa * lib/PandoraFMS/NetworkServer.pm, lib/PandoraFMS/Core.pm, lib/PandoraFMS/Tools.pm: Temporal fix to OID translation. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7200 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 6 +++++ pandora_server/lib/PandoraFMS/Core.pm | 3 +-- .../lib/PandoraFMS/NetworkServer.pm | 12 ++++++++-- pandora_server/lib/PandoraFMS/Tools.pm | 23 ++++++++----------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 4ace5a29fc..b3d258ad45 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,9 @@ +2012-11-28 Ramon Novoa + + * lib/PandoraFMS/NetworkServer.pm, + lib/PandoraFMS/Core.pm, + lib/PandoraFMS/Tools.pm: Temporal fix to OID translation. + 2012-11-28 Ramon Novoa * lib/PandoraFMS/Core.pm: Added fired alert count. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 42aa89065a..0f9b8be36d 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -3540,8 +3540,7 @@ sub pandora_self_monitoring ($$) { AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND running_by = $my_data_server - AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24,100) - AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)"); + AND estado = 3"); $agents_unknown = 0 if (!defined($agents_unknown)); } diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index e5403007ed..89a5a8fbc2 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -330,8 +330,16 @@ sub pandora_query_snmp ($$$) { my $snmp_oid = $module->{"snmp_oid"}; return (undef, 0) unless ($snmp_oid ne ''); if ($snmp_oid =~ m/[a-zA-Z]/) { - $snmp_oid = translate_obj ($dbh, $snmp_oid, $module->{"id_agente_modulo"}); - return (undef, 1) unless ($snmp_oid ne ''); + $snmp_oid = translate_obj ($dbh, $snmp_oid, ); + + # Could not translate OID, disable the module + if (! defined ($snmp_oid) || $snmp_oid eq '') { + db_do ($dbh, 'UPDATE tagente_modulo SET disabled = 1 WHERE id_agente_modulo = ?', $module->{"id_agente_modulo"}); + return (undef, 1); + } + + # Update module configuration + db_do ($dbh, 'UPDATE tagente_modulo SET snmp_oid = ? WHERE id_agente_modulo = ?', $snmp_oid, $module->{"id_agente_modulo"}); } my $snmp_timeout = $module->{"max_timeout"} != 0 ? $module->{"max_timeout"} : $pa_config->{"snmp_timeout"}; diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 94d1873b7c..ee31f05d42 100644 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -1036,23 +1036,18 @@ sub month_have_days($$) { ############################################################################### # Convert a text obj tag to an OID and update the module configuration. ############################################################################### -sub translate_obj ($$$) { - my ($dbh, $obj, $module_id) = @_; +sub translate_obj ($$) { + my ($dbh, $obj) = @_; # SNMP is not thread safe - $SNMPSem->down (); - my $oid = SNMP::translateObj ($obj); - $SNMPSem->up (); - - # Could not translate OID, disable the module - if (! defined ($oid)) { - db_do ($dbh, 'UPDATE tagente_modulo SET disabled = 1 WHERE id_agente_modulo = ?', $module_id); - return ''; + if (defined ($SNMPSem)) { + $SNMPSem->down (); } - - # Update module configuration - db_do ($dbh, 'UPDATE tagente_modulo SET snmp_oid = ? WHERE id_agente_modulo = ?', $oid, $module_id); - + my $oid = SNMP::translateObj ($obj); + if (defined ($SNMPSem)) { + $SNMPSem->up (); + } + return $oid; }