Fix the service cascade protection.

This commit is contained in:
Ramon Novoa 2018-07-11 13:07:37 +02:00
parent b36bf868b1
commit 62ed69af90
2 changed files with 18 additions and 24 deletions

View File

@ -352,16 +352,6 @@ sub pandora_generate_alerts ($$$$$$$$;$$$) {
return;
}
if ($agent->{'cps'} > 0) {
logger($pa_config, "Generate Alert. The agent '" . $agent->{'nombre'} . "' is in quiet mode by cascade protection services.", 10);
return;
}
if ($module->{'cps'} > 0) {
logger($pa_config, "Generate Alert. The module '" . $module->{'nombre'} . "' is in quiet mode by cascade protection services.", 10);
return;
}
# Do not generate alerts for disabled groups
if (is_group_disabled ($dbh, $agent->{'id_grupo'})) {
return;
@ -1649,7 +1639,7 @@ sub pandora_process_module ($$$$$$$$$;$) {
}
# Generate alerts
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) {
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) {
pandora_generate_alerts ($pa_config, $processed_data, $status, $agent, $module, $utimestamp, $dbh, $timestamp, $extra_macros, $last_data_value);
}
else {
@ -3140,11 +3130,6 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) {
logger($pa_config, "Generate Event. The agent '" . $agent->{'nombre'} . "' is in quiet mode.", 10);
return;
}
if (defined ($agent) && $agent->{'cps'} > 0) {
logger($pa_config, "Generate Event. The agent '" . $agent->{'nombre'} . "' is in quiet mode by cascade protection services.", 10);
return;
}
}
my $module = undef;
@ -3154,11 +3139,6 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) {
logger($pa_config, "Generate Event. The module '" . $module->{'nombre'} . "' is in quiet mode.", 10);
return;
}
if (defined ($module) && $module->{'cps'} > 0) {
logger($pa_config, "Generate Event. The module '" . $module->{'nombre'} . "' is in quiet mode by cascade protection services.", 10);
return;
}
}
# Get module tags
@ -4289,6 +4269,20 @@ sub pandora_inhibit_alerts {
return pandora_inhibit_alerts ($pa_config, $agent, $dbh, $depth + 1);
}
##########################################################################
# Returns 1 if service cascade protection is enabled for the given
# agent/module, 0 otherwise.
##########################################################################
sub pandora_cps_enabled($$) {
my ($agent, $module) = @_;
return 1 if ($agent->{'cps'} > 0);
return 1 if ($module->{'cps'} > 0);
return 0;
}
##########################################################################
=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>]) >>
@ -4925,7 +4919,7 @@ sub pandora_module_unknown ($$) {
pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'});
# Generate alerts
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) {
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) {
pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown');
}
else {
@ -4969,7 +4963,7 @@ sub pandora_module_unknown ($$) {
pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'});
# Generate alerts
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) {
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) {
pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown');
}
else {

View File

@ -176,7 +176,7 @@ sub exec_prediction_module ($$$$) {
logger ($pa_config, "Executing service module " .
$agent_module->{'id_agente_modulo'} . " " .
$agent_module->{'nombre'}, 10);
enterprise_hook ('exec_service_module', [$pa_config, $agent_module, $server_id, $dbh]);
enterprise_hook ('exec_service_module', [$pa_config, $agent_module, undef, $server_id, $dbh]);
}
return;