Alert recuperation only executes one time if in threshold interval
This commit is contained in:
parent
c2e16ec94f
commit
3bbaf5e562
|
@ -804,7 +804,6 @@ sub pandora_process_alert ($$$$$$$$;$$) {
|
||||||
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = 0,
|
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = 0,
|
||||||
internal_counter = 0 WHERE id = ?', $id);
|
internal_counter = 0 WHERE id = ?', $id);
|
||||||
|
|
||||||
|
|
||||||
if ($pa_config->{'alertserver'} == 1 || $pa_config->{'alertserver_queue'} == 1) {
|
if ($pa_config->{'alertserver'} == 1 || $pa_config->{'alertserver_queue'} == 1) {
|
||||||
pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module,
|
pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module,
|
||||||
$alert, 0, $timestamp, 0, $extra_macros, $is_correlated_alert]);
|
$alert, 0, $timestamp, 0, $extra_macros, $is_correlated_alert]);
|
||||||
|
@ -915,7 +914,7 @@ sub pandora_execute_alert {
|
||||||
@actions = get_db_rows ($dbh,
|
@actions = get_db_rows ($dbh,
|
||||||
'SELECT taa.name as action_name, taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
'SELECT taa.name as action_name, taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
||||||
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
||||||
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution, tatma.recovered
|
||||||
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
||||||
WHERE tatma.id_alert_action = taa.id
|
WHERE tatma.id_alert_action = taa.id
|
||||||
AND taa.id_alert_command = tac.id
|
AND taa.id_alert_command = tac.id
|
||||||
|
@ -1026,10 +1025,13 @@ sub pandora_execute_alert {
|
||||||
|
|
||||||
# Check the action threshold (template_action_threshold takes precedence over action_threshold)
|
# Check the action threshold (template_action_threshold takes precedence over action_threshold)
|
||||||
my $threshold = 0;
|
my $threshold = 0;
|
||||||
$action->{'last_execution'} = 0 unless defined ($action->{'last_execution'});
|
my $recovered = 0;
|
||||||
|
$action->{'last_execution'} = 0 unless defined ($action->{'last_execution'});
|
||||||
|
$action->{'recovered'} = 0 unless defined ($action->{'recovered'});
|
||||||
|
|
||||||
$threshold = $action->{'action_threshold'} if (defined ($action->{'action_threshold'}) && $action->{'action_threshold'} > 0);
|
$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);
|
$threshold = $action->{'module_action_threshold'} if (defined ($action->{'module_action_threshold'}) && $action->{'module_action_threshold'} > 0);
|
||||||
if (time () >= ($action->{'last_execution'} + $threshold)) {
|
if ((time () >= ($action->{'last_execution'} + $threshold)) || ($alert_mode == RECOVERED_ALERT && $action->{'recovered'} == 0)) {
|
||||||
my $monitoring_event_custom_data = '';
|
my $monitoring_event_custom_data = '';
|
||||||
|
|
||||||
push(@{$custom_data->{'actions'}}, safe_output($action->{'action_name'}));
|
push(@{$custom_data->{'actions'}}, safe_output($action->{'action_name'}));
|
||||||
|
@ -1039,13 +1041,18 @@ sub pandora_execute_alert {
|
||||||
$event_generated = 1;
|
$event_generated = 1;
|
||||||
$monitoring_event_custom_data = $custom_data;
|
$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);
|
||||||
|
|
||||||
# Reset action thresholds
|
|
||||||
if($alert_mode == RECOVERED_ALERT) {
|
if($alert_mode == RECOVERED_ALERT) {
|
||||||
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $alert->{'id_template_module'});
|
# 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'});
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros, $monitoring_event_custom_data);
|
|
||||||
} else {
|
} else {
|
||||||
if($alert_mode == RECOVERED_ALERT) {
|
if($alert_mode == RECOVERED_ALERT) {
|
||||||
if (defined ($alert->{'id_template_module'})) {
|
if (defined ($alert->{'id_template_module'})) {
|
||||||
|
|
Loading…
Reference in New Issue