Added global alert timeout to Pandora Server Alerts.
This commit is contained in:
parent
0dd0ae4b4c
commit
cabacec0ef
|
@ -506,3 +506,6 @@ console_pass pandora
|
|||
# Time interval (as a multiple of the module interval) before a module becomes unknown. Twice the module's interval by default.
|
||||
#unknown_interval 2
|
||||
|
||||
# Maximum executing time of an alert (in seconds)
|
||||
global_alert_timeout 15
|
||||
|
||||
|
|
|
@ -313,3 +313,6 @@ console_pass pandora
|
|||
# Time interval (as a multiple of the module interval) before a module becomes unknown. Twice the module's interval by default.
|
||||
#unknown_interval 2
|
||||
|
||||
# Maximum executing time of an alert (in seconds)
|
||||
global_alert_timeout 15
|
||||
|
||||
|
|
|
@ -382,6 +382,9 @@ sub pandora_load_config {
|
|||
$pa_config->{"snmp_forward_secLevel"}= '';
|
||||
$pa_config->{"snmp_forward_version"}= 2;
|
||||
$pa_config->{"snmp_forward_ip"}= '';
|
||||
|
||||
# Global Timeout for Custom Commands Alerts
|
||||
$pa_config->{"global_alert_timeout"}= 15; # 6.0
|
||||
|
||||
|
||||
# Check for UID0
|
||||
|
@ -851,6 +854,9 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^unknown_interval\s([0-9]*)/i) { # > 5.1SP2
|
||||
$pa_config->{'unknown_interval'}= safe_input($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^global_alert_timeout\s+([0-9]*)/i) {
|
||||
$pa_config->{'global_alert_timeout'}= clean_blank($1);
|
||||
}
|
||||
} # end of loop for parameter #
|
||||
|
||||
# Set to RDBMS' standard port
|
||||
|
|
|
@ -977,8 +977,18 @@ sub pandora_execute_action ($$$$$$$$$;$) {
|
|||
logger($pa_config, "Executing command '$command' for action '" . safe_output($action->{'name'}) . "' alert '". safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'nombre'}) : 'N/A') . "'.", 8);
|
||||
|
||||
eval {
|
||||
system ($command);
|
||||
logger($pa_config, "Command '$command' for action '" . safe_output($action->{'name'}) . "' alert '". safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'nombre'}) : 'N/A') . "' returned with errorlevel " . ($? >> 8), 8);
|
||||
if ($pa_config->{'global_alert_timeout'} == 0){
|
||||
system ($command);
|
||||
logger($pa_config, "Command '$command' for action '" . safe_output($action->{'name'}) . "' alert '". safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'nombre'}) : 'N/A') . "' returned with errorlevel " . ($? >> 8), 8);
|
||||
} else {
|
||||
my $command_timeout = safe_output($pa_config->{'plugin_exec'}) . " " . $pa_config->{'global_alert_timeout'} . " " . $command;
|
||||
system ($command_timeout);
|
||||
my $return_code = ($? >> 8) & 0xff;
|
||||
logger($pa_config, "Command '$command_timeout' for action '" . safe_output($action->{'name'}) . "' alert '". safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'nombre'}) : 'N/A') . "' returned with errorlevel " . $return_code, 8);
|
||||
if ($return_code != 0) {
|
||||
logger ($pa_config, "Action '" . safe_output($action->{'name'}) . "' alert '" . safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'nombre'}) : 'N/A') . "' exceeded the global alert timeout " . $pa_config->{'global_alert_timeout'} . " seconds" , 8);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ($@){
|
||||
|
|
Loading…
Reference in New Issue