This change permits forced all alerts without seen the times that it was fired

This commit is contained in:
fermin831 2015-07-06 18:00:32 +02:00
parent c3dfc93ade
commit a3d75e46de

20
pandora_server/lib/PandoraFMS/Core.pm Normal file → Executable file
View File

@ -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); 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;
} }
@ -585,8 +585,7 @@ sub pandora_process_alert ($$$$$$$$;$) {
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = ?, db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = ?,
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, 0, $extra_macros);
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, $dbh, $timestamp, $extra_macros);
return; return;
} }
} }
@ -598,9 +597,9 @@ 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) {
@ -633,6 +632,14 @@ sub pandora_execute_alert ($$$$$$$$;$) {
AND ((fires_min = 0 AND fires_max = 0) AND ((fires_min = 0 AND fires_max = 0)
OR ? >= fires_min)', OR ? >= fires_min)',
$alert->{'id_template_module'}, $alert->{'times_fired'}); $alert->{'id_template_module'}, $alert->{'times_fired'});
} else {
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 { } else {
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions @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 FROM talert_template_module_actions, talert_actions, talert_commands
@ -644,6 +651,7 @@ sub pandora_execute_alert ($$$$$$$$;$) {
OR (fires_min > fires_max AND ? >= fires_min))', OR (fires_min > fires_max AND ? >= fires_min))',
$alert->{'id_template_module'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'}); $alert->{'id_template_module'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'});
} }
}
# Get default action # Get default action
if ($#actions < 0) { if ($#actions < 0) {
@ -2876,7 +2884,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'});