diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 4726df4710..047c52acc0 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -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); + } } } }