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
1 changed files with 23 additions and 15 deletions

38
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) {
@ -634,15 +633,24 @@ sub pandora_execute_alert ($$$$$$$$;$) {
OR ? >= fires_min)', OR ? >= fires_min)',
$alert->{'id_template_module'}, $alert->{'times_fired'}); $alert->{'id_template_module'}, $alert->{'times_fired'});
} else { } else {
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions if ($forced_alert) {
FROM talert_template_module_actions, talert_actions, talert_commands @actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions
WHERE talert_template_module_actions.id_alert_action = talert_actions.id FROM talert_template_module_actions, talert_actions, talert_commands
AND talert_actions.id_alert_command = talert_commands.id WHERE talert_template_module_actions.id_alert_action = talert_actions.id
AND talert_template_module_actions.id_alert_template_module = ? AND talert_actions.id_alert_command = talert_commands.id
AND ((fires_min = 0 AND fires_max = 0) AND talert_template_module_actions.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))', } else {
$alert->{'id_template_module'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'}); @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 # Get default action
@ -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'});