From 8a4e381cf8164e0f69b13130a88fd447e36fa4c1 Mon Sep 17 00:00:00 2001 From: ramonn Date: Mon, 20 Feb 2012 17:47:08 +0000 Subject: [PATCH] 2012-02-20 Ramon Novoa * conf/pandora_server.conf, lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Config.pm: Added two new configuration tokens suggested by Koichiro: snmp_ignore_authfailure and snmp_pdu_address. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5623 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 +++++++ pandora_server/conf/pandora_server.conf | 6 ++++++ pandora_server/lib/PandoraFMS/Config.pm | 11 +++++++++-- pandora_server/lib/PandoraFMS/SNMPServer.pm | 12 +++++++++--- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 9dbfab0fcd..6fe7ccb7ba 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2012-02-20 Ramon Novoa + + * conf/pandora_server.conf, + lib/PandoraFMS/SNMPServer.pm, + lib/PandoraFMS/Config.pm: Added two new configuration tokens + suggested by Koichiro: snmp_ignore_authfailure and snmp_pdu_address. + 2012-02-16 Vanessa Gil * util/pandora_manage.pl: Modify user comment format. diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf index 565196ac81..e5aced5a8d 100755 --- a/pandora_server/conf/pandora_server.conf +++ b/pandora_server/conf/pandora_server.conf @@ -80,6 +80,12 @@ master 1 snmpconsole 1 +# snmptrapd will ignore authenticationFailure traps if set to 1. +snmp_ignore_authfailure 1 + +# snmptrapd will read the PDU source address instead of the agent-addr field is set to 1. +snmp_pdu_address 0 + # Activate (1) Pandora Network Server networkserver 1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 27c0dde003..6f5a676cff 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -231,9 +231,10 @@ sub pandora_load_config { $pa_config->{"snmpserver"} = 0; # 4.0 $pa_config->{"snmp_threads"} = 3; # 4.0 $pa_config->{"block_size"} = 15; # 4.0 - $pa_config->{"max_queue_files"} = 500; - + $pa_config->{"snmp_ignore_authfailure"} = 1; # 5.0 + $pa_config->{"snmp_pdu_address"} = 0; # 5.0 + # Internal MTA for alerts, each server need its own config. $pa_config->{"mta_address"} = '127.0.0.1'; # Introduced on 2.0 $pa_config->{"mta_port"} = '25'; # Introduced on 2.0 @@ -384,6 +385,12 @@ sub pandora_load_config { elsif ($parametro =~ m/^snmp_logfile\s(.*)/i) { $pa_config->{'snmp_logfile'}= clean_blank($1); } + elsif ($parametro =~ m/^snmp_ignore_authfailure\s+([0-1])/i) { + $pa_config->{'snmp_ignore_authfailure'}= clean_blank($1); + } + elsif ($parametro =~ m/^snmp_pdu_address\s+([0-1])/i) { + $pa_config->{'snmp_pdu_address'}= clean_blank($1); + } elsif ($parametro =~ m/^dbengine\s(.*)/i) { $pa_config->{'dbengine'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index 2ef49b2dba..ccb0e3f4e7 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -63,9 +63,15 @@ sub new ($$;$) { kill (9, $pid); } } - - my $snmptrapd_args = ' -t -On -n -a -Lf ' . $config->{'snmp_logfile'} . ' -p ' . $pid_file; - $snmptrapd_args .= ' --format1=SNMPv1[**]%4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%a[**]%N[**]%w[**]%W[**]%q[**]%v\\\n'; + + # Ignore auth failure traps + my $snmp_ignore_authfailure = ($config->{'snmp_ignore_authfailure'} eq '1' ? ' -a' : ''); + + # Select agent-addr field of the PDU or PDU source address for V1 traps + my $address_format = ($config->{'snmp_pdu_address'} eq '0' ? '%a' : '%b'); + + my $snmptrapd_args = ' -t -On -n' . $snmp_ignore_authfailure . ' -Lf ' . $config->{'snmp_logfile'} . ' -p ' . $pid_file; + $snmptrapd_args .= ' --format1=SNMPv1[**]%4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]' . $address_format . '[**]%N[**]%w[**]%W[**]%q[**]%v\\\n'; $snmptrapd_args .= ' --format2=SNMPv2[**]%4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%b[**]%v\\\n'; if (system ($config->{'snmp_trapd'} . $snmptrapd_args . ' >/dev/null 2>&1') != 0) {