diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 06deaa4331..370358b365 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1041,18 +1041,7 @@ sub pandora_execute_alert { $event_generated = 1; $monitoring_event_custom_data = $custom_data; } - pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros, $monitoring_event_custom_data); - - if($alert_mode == RECOVERED_ALERT) { - # Reset action thresholds and set recovered - if (defined ($alert->{'id_template_module'})) { - db_do($dbh, 'UPDATE talert_template_module_actions SET recovered = 1 WHERE id_alert_template_module = ?', $alert->{'id_template_module'}); - } - } else { - # Action executed again, set recovered to 0. - db_do($dbh, 'UPDATE talert_template_module_actions SET recovered = 0 WHERE id_alert_template_module = ?', $alert->{'id_template_module'}); - } } else { if($alert_mode == RECOVERED_ALERT) { if (defined ($alert->{'id_template_module'})) { @@ -1969,10 +1958,20 @@ sub pandora_execute_action ($$$$$$$$$;$$) { logger($pa_config, "Unknown action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3); } - # Update action last execution date - if (defined ($action->{'last_execution'}) && defined ($action->{'id_alert_templ_module_actions'})) { + # Update action last execution date and recovered alert. + if ($alert_mode != RECOVERED_ALERT && defined ($action->{'last_execution'}) && defined ($action->{'id_alert_templ_module_actions'})) { db_do ($dbh, 'UPDATE talert_template_module_actions SET last_execution = ? WHERE id = ?', int(time ()), $action->{'id_alert_templ_module_actions'}); + # Update recovered status + db_do($dbh, 'UPDATE talert_template_module_actions SET recovered = 0 + WHERE id = ?', $action->{'id_alert_templ_module_actions'}); + + } else { + if (defined ($action->{'id_alert_templ_module_actions'})) { + # Update recovered status + db_do($dbh, 'UPDATE talert_template_module_actions SET recovered = 1 + WHERE id = ?', $alert->{'id_alert_templ_module_actions'}); + } } }