From 396c48ca57850509514e5987cb7f94970ed545ae Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 10 May 2010 15:59:09 +0000 Subject: [PATCH] 2010-05-10 Ramon Novoa * lib/PandoraFMS/Core.pm: Made cascade protection recursive to check any of the agent's parents in the tree. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2687 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/Core.pm | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index dfa8738bbc..47f0e3892d 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2010-05-10 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Made cascade protection recursive to + check any of the agent's parents in the tree. + 2010-05-10 Sergio Martin * lib/PandoraFMS/Tools.pm: Typo fix in error message diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index f8a4051393..ac610d96a1 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -740,6 +740,8 @@ sub pandora_process_module ($$$$$$$$$;$) { # Generate alerts if (pandora_inhibit_alerts ($pa_config, $agent, $dbh) == 0) { pandora_generate_alerts ($pa_config, $processed_data, $status, $agent, $module, $utimestamp, $dbh, $extraMacros, $last_data_value); + } else { + logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10); } # tagente_estado.last_try defaults to NULL, should default to '0000-00-00 00:00:00' @@ -1665,10 +1667,11 @@ sub export_module_data ($$$$$$$) { ########################################################################## # Returns 1 if alerts for the given agent should be inhibited, 0 otherwise. ########################################################################## -sub pandora_inhibit_alerts ($$$) { - my ($pa_config, $agent, $dbh) = @_; +#sub pandora_inhibit_alerts ($$$$) { +sub pandora_inhibit_alerts { + my ($pa_config, $agent, $dbh, $depth) = @_; - return 0 if ($agent->{'cascade_protection'} ne '1' || $agent->{'id_parent'} eq '0'); + return 0 if ($agent->{'cascade_protection'} ne '1' || $agent->{'id_parent'} eq '0' || $depth > 1024); # Are any of the parent's critical alerts fired? my $count = get_db_value ($dbh, 'SELECT COUNT(*) FROM tagente_modulo, talert_template_modules, talert_templates @@ -1683,8 +1686,13 @@ sub pandora_inhibit_alerts ($$$) { $count = get_db_value ($dbh, 'SELECT COUNT(*) FROM talert_compound WHERE id_agent = ? AND times_fired > 0 AND priority = 4', $agent->{'id_parent'}); return 1 if ($count > 0); - return 0; + # Check the parent's parent next + $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $agent->{'id_parent'}); + return 0 unless defined ($agent); + + return pandora_inhibit_alerts ($pa_config, $agent, $dbh, $depth + 1); } + ########################################################################## =head2 C<< save_agent_position (I<$pa_config>, I<$current_longitude>, I<$current_latitude>, I<$current_altitude>, I<$agent_id>, I<$dbh>, [I<$start_timestamp>], [I<$description>]) >>