From 24d57bbcbffc67fb39cb73229a3cda922391b42f Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 19 Feb 2010 13:16:46 +0000 Subject: [PATCH] 2010-02-19 Ramon Novoa * lib/PandoraFMS/Core.pm: Enabled FF protection for module states (not just events). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2388 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 ++++ pandora_server/lib/PandoraFMS/Core.pm | 33 ++++++++++++++++----------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 23c6839d43..e3fb05552c 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2010-02-19 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Enabled FF protection for module states + (not just events). + 2010-02-19 Sancho Lerena * lib/PandoraFMS/Core.pm: Added comments to new statistical functions. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index c06430e2eb..d3f016ce1f 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -693,25 +693,32 @@ sub pandora_process_module ($$$$$$$$$;$) { pandora_update_module_on_error ($pa_config, $module->{'id_agente_modulo'}, $dbh); return; } + my $last_status = $agent_status->{'last_status'}; + my $status = $agent_status->{'estado'}; + my $status_changes = $agent_status->{'status_changes'}; - # Get current status - my $status = get_module_status ($processed_data, $module, $module_type); + # Get new status + my $new_status = get_module_status ($processed_data, $module, $module_type); + + #Update module status + my $current_utimestamp = time (); + if ($last_status == $new_status) { + $status_changes++; + } else { + $status_changes = 0; + } + + if ($status_changes == $module->{'min_ff_event'}) { + generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $dbh); + $status = $new_status; + } + + $last_status = $new_status; # Generate alerts if (pandora_inhibit_alerts ($pa_config, $agent, $dbh) == 0) { pandora_generate_alerts ($pa_config, $processed_data, $status, $agent, $module, $utimestamp, $dbh, $extraMacros); } - - #Update module status - my $current_utimestamp = time (); - my ($status_changes, $last_status) = ($status != $agent_status->{'estado'}) ? - (0, $agent_status->{'estado'}) : - ($agent_status->{'status_changes'} + 1, $agent_status->{'last_status'}); - - # Generate events - if ($status_changes == $module->{'min_ff_event'}) { - generate_status_event ($pa_config, $processed_data, $agent, $module, $status, $last_status, $dbh); - } # tagente_estado.last_try defaults to NULL, should default to '0000-00-00 00:00:00' $agent_status->{'last_try'} = '0000-00-00 00:00:00' unless defined ($agent_status->{'last_try'});