From ec65703d8bf45ce27ab403808f4788d8969ebc53 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 20 Mar 2013 15:50:41 +0000 Subject: [PATCH] 2013-03-20 Ramon Novoa * conf/pandora_server.conf, lib/PandoraFMS/Core.pm, lib/PandoraFMS/Config.pm, bin/pandora_server: Added the parameter braa_retries, which lets braa retry SNMP modules a number of times before handing it over to the network server. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7873 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 9 +++++++++ pandora_server/bin/pandora_server | 2 +- pandora_server/conf/pandora_server.conf | 4 ++++ pandora_server/lib/PandoraFMS/Config.pm | 8 +++++++- pandora_server/lib/PandoraFMS/Core.pm | 9 +++++---- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index fce828bf12..ba57613ccd 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,12 @@ +2013-03-20 Ramon Novoa + + * conf/pandora_server.conf, + lib/PandoraFMS/Core.pm, + lib/PandoraFMS/Config.pm, + bin/pandora_server: Added the parameter braa_retries, which lets braa + retry SNMP modules a number of times before handing it over to the + network server. + 2013-03-19 Ramon Novoa * bin/pandora_server: Moved a log message to verbosity 10. diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 9c33cd0a9f..39cad31a44 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -313,7 +313,7 @@ while (1) { # Update module status and fired alert counts my @agents = get_db_rows ($DBH, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)'); foreach my $agent (@agents) { - print_message (\%Config, " [*] Updating module status and alert fired counts for agent " . $agent->{'nombre'}, 10); + logger (\%Config, " [*] Updating module status and alert fired counts for agent " . $agent->{'nombre'}, 10); if ($agent->{'update_module_count'} == 1) { pandora_update_agent_module_count ($DBH, $agent->{'id_agente'}); diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf index da0425f080..1cc5982c8b 100755 --- a/pandora_server/conf/pandora_server.conf +++ b/pandora_server/conf/pandora_server.conf @@ -234,6 +234,10 @@ snmpget /usr/bin/snmpget braa /usr/bin/braa +# Number of retries before braa hands a module over to the Network Server (PANDORA FMS ENTERPRISE ONLY). + +braa_retries 3 + # Default group id for new agents created with Pandora FMS Data Server autocreate_group 2 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index c60b3d414c..3156b94078 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -253,6 +253,9 @@ sub pandora_load_config { # braa for enterprise snmp server $pa_config->{"braa"} = "/usr/bin/braa"; + # SNMP enterprise retries (for braa) + $pa_config->{"braa_retries"} = 3; # 5.0 + # Xprobe2 for recon OS fingerprinting and tcpscan (optional) $pa_config->{"xprobe2"} = "/usr/bin/xprobe2"; @@ -292,7 +295,7 @@ sub pandora_load_config { # Event auto-validation $pa_config->{"event_auto_validation"} = 1; # 5.0 - + # ------------------------------------------------------------------------- # This values are not stored in .conf files. # This values should be stored in database, not in .conf files! @@ -541,6 +544,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^braa\s(.*)/i) { $pa_config->{'braa'}= clean_blank($1); } + elsif ($parametro =~ m/^braa_retries\s([0-9]*)/i) { + $pa_config->{"braa_retries"} = clean_blank($1); + } elsif ($parametro =~ m/^xprobe2\s(.*)/i) { $pa_config->{'xprobe2'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 97190684fc..d56f34f28f 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -997,6 +997,7 @@ sub pandora_process_module ($$$$$$$$$;$) { my $status_changes = $agent_status->{'status_changes'}; my $last_data_value = $agent_status->{'datos'}; my $last_known_status = $agent_status->{'last_known_status'}; + my $last_error = defined ($module->{'last_error'}) ? $module->{'last_error'} : $agent_status->{'last_error'}; # Get new status my $new_status = get_module_status ($processed_data, $module, $module_type); @@ -1074,10 +1075,10 @@ sub pandora_process_module ($$$$$$$$$;$) { SET datos = ?, estado = ?, last_status = ?, last_known_status = ?, status_changes = ?, utimestamp = ?, timestamp = ?, id_agente = ?, current_interval = ?, running_by = ?, - last_execution_try = ?, last_try = ? + last_execution_try = ?, last_try = ?, last_error = ? WHERE id_agente_modulo = ?', $processed_data, $status, $last_status, $last_status, $status_changes, $current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id, - $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $module->{'id_agente_modulo'}); + $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $module->{'id_agente_modulo'}); # Save module data. Async and log4x modules are not compressed. if ($module_type =~ m/(async)|(log4x)/ || $save == 1) { @@ -3781,7 +3782,7 @@ sub pandora_module_unknown ($$) { } # Update module status count - pandora_mark_agent_for_module_update ($dbh, $agent, 0, $module->{'estado'}); + pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'}); # Generate alerts if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { @@ -3811,7 +3812,7 @@ sub pandora_module_unknown ($$) { } # Update module status count - pandora_mark_agent_for_module_update ($dbh, $agent, 3, $module->{'estado'}); + pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'}); # Generate alerts if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) {