From 6b28deefe568515e93d206bab0b247806721db36 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 10 Nov 2009 17:04:48 +0000 Subject: [PATCH] 2009-11-10 Ramon Novoa * lib/PandoraFMS/Core.pm: Fixed forced alert execution. Substitute alert macros after decoding HTML entities. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2102 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/Core.pm | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 61cdb1b8d4..b981227649 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2009-11-10 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Fixed forced alert execution. Substitute alert + macros after decoding HTML entities. + 2009-11-10 Ramon Novoa * lib/PandoraFMS/PredictionServer.pm: Fixed bug #2894950. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 345cd794d2..d338c94801 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -452,7 +452,7 @@ sub pandora_execute_action ($$$$$$$$) { # User defined alerts if ($action->{'internal'} == 0) { - my $command = decode_entities(subst_alert_macros ($action->{'command'}, \%macros)); + my $command = subst_alert_macros (decode_entities ($action->{'command'}), \%macros); $command = subst_alert_macros ($command, \%macros); logger($pa_config, "Executing command $command", 4); @@ -819,8 +819,11 @@ sub pandora_exec_forced_alerts { my ($pa_config, $dbh) = @_; # Get alerts marked for forced execution (even disabled alerts) - my @alerts = get_db_rows ($dbh, 'SELECT * FROM talert_template_modules WHERE force_execution = 1'); - + my @alerts = get_db_rows ($dbh, 'SELECT talert_template_modules.id as id_template_module, + talert_template_modules.*, talert_templates.* + FROM talert_template_modules, talert_templates + WHERE talert_template_modules.id_alert_template = talert_templates.id + AND force_execution = 1'); foreach my $alert (@alerts) { # Get the agent and module associated with the alert @@ -829,11 +832,10 @@ sub pandora_exec_forced_alerts { my $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $module->{'id_agente'}); next unless defined ($agent); - # $alert already contains agent data! pandora_execute_alert ($pa_config, 'N/A', $agent, $module, $alert, 1, $dbh); # 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'}); + db_do ($dbh, "UPDATE talert_template_modules SET force_execution = 0 WHERE id = " . $alert->{'id_template_module'}); } }