From bb9cd2023f16e25477b93d775c337f884ca555b1 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 23 May 2011 13:13:34 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4376 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 8 ++++++++ pandora_server/lib/PandoraFMS/DataServer.pm | 4 ++-- pandora_server/lib/PandoraFMS/SNMPServer.pm | 18 +++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) 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;