2011-02-15 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Core.pm: Added support for action thresholds.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3856 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2011-02-15 16:42:37 +00:00
parent 716c90b318
commit 5dac65d9ee
2 changed files with 19 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2011-02-15 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Added support for action thresholds.
2011-02-14 Dario Rodriguez <dario.rodriguez@artica.es>
* util/pandora_xml_stress.pl: Fixed an error using config files with

View File

@ -571,7 +571,16 @@ sub pandora_execute_alert ($$$$$$$$;$) {
# Execute actions
foreach my $action (@actions) {
pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros);
# Check the action threshold (template_action_threshold takes precedence over action_threshold)
my $threshold = 0;
$threshold = $action->{'action_threshold'} if (defined ($action->{'action_threshold'}) && $action->{'action_threshold'} > 0);
$threshold = $action->{'module_action_threshold'} if (defined ($action->{'module_action_threshold'}) && $action->{'module_action_threshold'} > 0);
if (time () >= ($action->{'last_execution'} + $threshold)) {
pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros);
} else {
logger ($pa_config, "Skipping action " . $action->{'name'} . " for alert '" . $alert->{'name'} . "' module '" . $module->{'nombre'} . "'.", 10);
}
}
# Generate an event
@ -676,6 +685,11 @@ sub pandora_execute_action ($$$$$$$$$;$) {
} else {
logger($pa_config, "Unknown action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'nombre'} : 'N/A') . "'.", 3);
}
# Update action last execution date
if (defined ($action->{'last_execution'}) && defined ($action->{'id'})) {
db_do ($dbh, 'UPDATE talert_template_module_actions SET last_execution = ? WHERE id = ?', time (), $alert->{'id'});
}
}
##########################################################################