Fix alert action execution when recovered
This commit is contained in:
parent
7fa32854e9
commit
7c13a32c32
|
@ -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'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue