This change permits forced all alerts without seen the times that it was fired
This commit is contained in:
parent
c3dfc93ade
commit
a3d75e46de
|
@ -546,7 +546,7 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -585,8 +585,7 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = ?,
|
||||
last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE 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;
|
||||
}
|
||||
}
|
||||
|
@ -598,9 +597,9 @@ Execute the given alert.
|
|||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_execute_alert ($$$$$$$$;$) {
|
||||
sub pandora_execute_alert ($$$$$$$$$;$) {
|
||||
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
|
||||
if ($alert->{'standby'} == 1) {
|
||||
|
@ -634,15 +633,24 @@ sub pandora_execute_alert ($$$$$$$$;$) {
|
|||
OR ? >= fires_min)',
|
||||
$alert->{'id_template_module'}, $alert->{'times_fired'});
|
||||
} else {
|
||||
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions
|
||||
FROM talert_template_module_actions, talert_actions, talert_commands
|
||||
WHERE talert_template_module_actions.id_alert_action = talert_actions.id
|
||||
AND talert_actions.id_alert_command = talert_commands.id
|
||||
AND talert_template_module_actions.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'});
|
||||
if ($forced_alert) {
|
||||
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions
|
||||
FROM talert_template_module_actions, talert_actions, talert_commands
|
||||
WHERE talert_template_module_actions.id_alert_action = talert_actions.id
|
||||
AND talert_actions.id_alert_command = talert_commands.id
|
||||
AND talert_template_module_actions.id_alert_template_module = ?',
|
||||
$alert->{'id_template_module'});
|
||||
} else {
|
||||
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions
|
||||
FROM talert_template_module_actions, talert_actions, talert_commands
|
||||
WHERE talert_template_module_actions.id_alert_action = talert_actions.id
|
||||
AND talert_actions.id_alert_command = talert_commands.id
|
||||
AND talert_template_module_actions.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
|
||||
|
@ -2876,7 +2884,7 @@ sub pandora_exec_forced_alerts {
|
|||
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
|
||||
db_do ($dbh, "UPDATE talert_template_modules SET force_execution = 0 WHERE id = " . $alert->{'id_template_module'});
|
||||
|
|
Loading…
Reference in New Issue