Recovered alerts skipping when threshold applies

This commit is contained in:
Calvo 2023-04-03 18:06:48 +02:00
parent e8f7246e54
commit 134bc6ac3f
1 changed files with 17 additions and 8 deletions

View File

@ -801,10 +801,6 @@ sub pandora_process_alert ($$$$$$$$;$$) {
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = 0,
internal_counter = 0 WHERE id = ?', $id);
# Reset action thresholds
if (defined ($alert->{'id_template_module'})) {
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id);
}
if ($pa_config->{'alertserver'} == 1 || $pa_config->{'alertserver_queue'} == 1) {
pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module,
@ -1031,6 +1027,7 @@ sub pandora_execute_alert {
$threshold = $action->{'action_threshold'} if (defined ($action->{'action_threshold'}) && $action->{'action_threshold'} > 0);
$threshold = $action->{'module_action_threshold'} if (defined ($action->{'module_action_threshold'}) && $action->{'module_action_threshold'} > 0);
if (time () >= ($action->{'last_execution'} + $threshold)) {
print "Entro";
my $monitoring_event_custom_data = '';
push(@{$custom_data->{'actions'}}, safe_output($action->{'action_name'}));
@ -1043,10 +1040,22 @@ sub pandora_execute_alert {
pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros, $monitoring_event_custom_data);
} else {
if (defined ($module)) {
logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10);
} else {
logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "'.", 10);
if($alert_mode == RECOVERED_ALERT) {
# Reset action thresholds
if (defined ($alert->{'id_template_module'})) {
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $alert->{'id_template_module'});
if (defined ($module)) {
logger ($pa_config, "Skipping recover action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10);
} else {
logger ($pa_config, "Skipping recover action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "'.", 10);
}
}
} else {
if (defined ($module)) {
logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10);
} else {
logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "'.", 10);
}
}
}
}