diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 3ea2b67cb8..7b32f1173f 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2011-05-23 Ramon Novoa + + * lib/PandoraFMS/SNMPServer.pm: Applied Koichiro's patch to reuse an + already running snmptrapd. + + * lib/PandoraFMS/DataServer.pm: Do not update the configuration of + policy modules. + 2011-05-23 Sergio Martin * lib/PandoraFMS/DB.pm diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 004e183b32..1fddf1fedb 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -550,8 +550,8 @@ sub process_module_data ($$$$$$$$$) { $module_conf->{'id_module_group'} = ($conf_group_id == -1) ? $module->{'id_module_group'} : $conf_group_id; } - # Update module configuration if in learning mode - if ($agent->{'modo'} eq '1') { + # Update module configuration if in learning mode and not a policy module + if ($agent->{'modo'} eq '1' && $module->{'id_policy_module'} == 0) { update_module_configuration ($pa_config, $dbh, $module, $module_conf); } diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index da9bcc7937..a8dc3b929b 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -47,7 +47,23 @@ sub new ($$;$) { return undef unless $config->{'snmpconsole'} == 1; # Start snmptrapd - if (system ($config->{'snmp_trapd'} . ' -t -On -n -a -Lf ' . $config->{'snmp_logfile'} . ' -p /var/run/pandora_snmptrapd.pid -F %4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%a[**]%N[**]%w[**]%W[**]%q[**]%v\\\n >/dev/null 2>&1') != 0) { + + my $pid_file = '/var/run/pandora_snmptrapd.pid'; + + my $snmptrapd_running = 0; + + if ( -e $pid_file && open (PIDFILE, $pid_file)) { + my $pid = + 0; + close PIDFILE; + + # check if snmptrapd is running + if ($snmptrapd_running = kill (0, $pid)) { + logger ($config, "snmptrapd (pid $pid) is already running, using existing process.", 1); + print_message ($config, "snmptrapd (pid $pid) is already running, using existing process.", 1); + } + } + + if (!$snmptrapd_running && system ($config->{'snmp_trapd'} . ' -t -On -n -a -Lf ' . $config->{'snmp_logfile'} . ' -p ' . $pid_file . ' -F %4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%a[**]%N[**]%w[**]%W[**]%q[**]%v\\\n >/dev/null 2>&1') != 0) { logger ($config, " [E] Could not start snmptrapd.", 1); print_message ($config, " [E] Could not start snmptrapd.", 1); return undef;