From 63cfd01ff2fc14d7881babd727fabce230b241bb Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 20 Oct 2009 11:19:08 +0000 Subject: [PATCH] 2009-10-20 Ramon Novoa * lib/PandoraFMS/SNMPServer.pm: Save as much information as possible if the trap could not be properly parsed. * lib/PandoraFMS/Core.pm: Changed the name of the alert name macro to avoid conflicts with other macros. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2037 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 8 ++++++++ pandora_server/lib/PandoraFMS/Core.pm | 2 +- pandora_server/lib/PandoraFMS/SNMPServer.pm | 18 ++++++------------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index bd4f874d1c..d4e824f749 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2009-10-20 Ramon Novoa + + * lib/PandoraFMS/SNMPServer.pm: Save as much information as possible if + the trap could not be properly parsed. + + * lib/PandoraFMS/Core.pm: Changed the name of the alert name macro to + avoid conflicts with other macros. + 2009-10-20 Sancho Lerena * tools.pm, core.pm: Float data with "," will be replace this diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 2cc278e14a..aa0c8c75ed 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -437,7 +437,7 @@ sub pandora_execute_action ($$$$$$$$) { _address_ => (defined ($agent)) ? $agent->{'direccion'} : '', _timestamp_ => strftime ("%Y-%m-%d %H:%M:%S", localtime()), _data_ => $data, - _alert_ => $alert->{'name'}, + _alert_name_ => $alert->{'name'}, _alert_description_ => $alert->{'description'}, _alert_threshold_ => $alert->{'time_threshold'}, _alert_times_fired_ => $alert->{'times_fired'}, diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index b6c51a4124..4aa7e31fe9 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -130,19 +130,13 @@ sub pandora_snmptrapd { my $timestamp = $date . ' ' . $time; $value = limpia_cadena ($value); - my ($custom_oid, $custom_type, $custom_value) = ('', '', $type_desc); + my ($custom_oid, $custom_type, $custom_value) = ('', '', ''); + ($custom_oid, $custom_type, $custom_value) = ($1, $2, limpia_cadena ($3)) if ($data =~ m/([0-9\.]*)\s\=\s([A-Za-z0-9]*)\:\s(.+)/); - # Custom OID - if ($type eq '6') { - - #String data - next if ($data =~ m/STRING/) && ($data !~ m/([0-9\.]*)\s\=\s([A-Za-z0-9]*)\:\s\"(.+)\"/); - - next if ($data !~ m/([0-9\.]*)\s\=\s([A-Za-z0-9]*)\:\s(.+)/); - - ($custom_oid, $custom_type, $custom_value) = ($1, $2, $3); - $custom_value = limpia_cadena ($custom_value); - } + # Try to save as much information as possible if the trap could not be parsed + $oid = $type_desc if ($oid eq '' || $oid eq '.'); + $custom_value = $type_desc if ($custom_oid eq '' || $custom_oid eq '.'); + $custom_value = $data if ($custom_value eq ''); # Insert the trap into the DB if (! defined(enterprise_hook ('snmp_insert_trap', [$pa_config, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type, $timestamp, $dbh]))) {