When an alert is forced, all actions configured for that module
are executed without seeing times fired
This commit is contained in:
parent
aaea9ef42d
commit
da773b98a1
|
@ -569,7 +569,7 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
||||||
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id);
|
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 0, $dbh, $timestamp, $extra_macros);
|
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 0, $dbh, $timestamp, 0, $extra_macros);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,21 +609,21 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
||||||
last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?',
|
last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?',
|
||||||
$alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id);
|
$alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id);
|
||||||
|
|
||||||
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, $dbh, $timestamp, $extra_macros);
|
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, $dbh, $timestamp, 0, $extra_macros);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
=head2 C<< pandora_execute_alert (I<$pa_config>, I<$data>, I<$agent>, I<$module>, I<$alert>, I<$alert_mode>, I<$dbh>, I<$timestamp>) >>
|
=head2 C<< pandora_execute_alert (I<$pa_config>, I<$data>, I<$agent>, I<$module>, I<$alert>, I<$alert_mode>, I<$dbh>, I<$timestamp>, I<$forced_alert>) >>
|
||||||
|
|
||||||
Execute the given alert.
|
Execute the given alert.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub pandora_execute_alert ($$$$$$$$;$) {
|
sub pandora_execute_alert ($$$$$$$$$;$) {
|
||||||
my ($pa_config, $data, $agent, $module,
|
my ($pa_config, $data, $agent, $module,
|
||||||
$alert, $alert_mode, $dbh, $timestamp, $extra_macros) = @_;
|
$alert, $alert_mode, $dbh, $timestamp, $forced_alert, $extra_macros) = @_;
|
||||||
|
|
||||||
# Alerts in stand-by are not executed
|
# Alerts in stand-by are not executed
|
||||||
if ($alert->{'standby'} == 1) {
|
if ($alert->{'standby'} == 1) {
|
||||||
|
@ -667,18 +667,31 @@ sub pandora_execute_alert ($$$$$$$$;$) {
|
||||||
$alert->{'id_template_module'}, $alert->{'times_fired'});
|
$alert->{'id_template_module'}, $alert->{'times_fired'});
|
||||||
} else {
|
} else {
|
||||||
# Avoid the use of alias bigger than 30 characters.
|
# Avoid the use of alias bigger than 30 characters.
|
||||||
@actions = get_db_rows ($dbh,
|
if ($forced_alert){
|
||||||
'SELECT taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
@actions = get_db_rows ($dbh,
|
||||||
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
'SELECT taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
||||||
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
||||||
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
||||||
WHERE tatma.id_alert_action = taa.id
|
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
||||||
AND taa.id_alert_command = tac.id
|
WHERE tatma.id_alert_action = taa.id
|
||||||
AND tatma.id_alert_template_module = ?
|
AND taa.id_alert_command = tac.id
|
||||||
AND ((fires_min = 0 AND fires_max = 0)
|
AND tatma.id_alert_template_module = ?',
|
||||||
OR (fires_min <= fires_max AND ? >= fires_min AND ? <= fires_max)
|
$alert->{'id_template_module'});
|
||||||
OR (fires_min > fires_max AND ? >= fires_min))',
|
|
||||||
$alert->{'id_template_module'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'});
|
} else {
|
||||||
|
@actions = get_db_rows ($dbh,
|
||||||
|
'SELECT taa.*, tac.*, tatma.id AS id_alert_templ_module_actions,
|
||||||
|
tatma.id_alert_template_module, tatma.id_alert_action, tatma.fires_min,
|
||||||
|
tatma.fires_max, tatma.module_action_threshold, tatma.last_execution
|
||||||
|
FROM talert_template_module_actions tatma, talert_actions taa, talert_commands tac
|
||||||
|
WHERE tatma.id_alert_action = taa.id
|
||||||
|
AND taa.id_alert_command = tac.id
|
||||||
|
AND tatma.id_alert_template_module = ?
|
||||||
|
AND ((fires_min = 0 AND fires_max = 0)
|
||||||
|
OR (fires_min <= fires_max AND ? >= fires_min AND ? <= fires_max)
|
||||||
|
OR (fires_min > fires_max AND ? >= fires_min))',
|
||||||
|
$alert->{'id_template_module'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get default action
|
# Get default action
|
||||||
|
@ -3018,7 +3031,7 @@ sub pandora_exec_forced_alerts {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora_execute_alert ($pa_config, 'N/A', $agent, $module, $alert, 1, $dbh, undef);
|
pandora_execute_alert ($pa_config, 'N/A', $agent, $module, $alert, 1, $dbh, undef, 1, undef);
|
||||||
|
|
||||||
# Reset the force_execution flag, even if the alert could not be executed
|
# Reset the force_execution flag, even if the alert could not be executed
|
||||||
db_do ($dbh, "UPDATE talert_template_modules SET force_execution = 0 WHERE id = " . $alert->{'id_template_module'});
|
db_do ($dbh, "UPDATE talert_template_modules SET force_execution = 0 WHERE id = " . $alert->{'id_template_module'});
|
||||||
|
|
Loading…
Reference in New Issue