fixed bug in monitoring event creation

This commit is contained in:
alejandro.campos@artica.es 2022-01-14 09:05:50 +01:00
parent 4899d68ec2
commit f9bb085dad

View File

@ -982,14 +982,17 @@ sub pandora_execute_alert ($$$$$$$$$;$$) {
$threshold = $action->{'action_threshold'} if (defined ($action->{'action_threshold'}) && $action->{'action_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); $threshold = $action->{'module_action_threshold'} if (defined ($action->{'module_action_threshold'}) && $action->{'module_action_threshold'} > 0);
if (time () >= ($action->{'last_execution'} + $threshold)) { if (time () >= ($action->{'last_execution'} + $threshold)) {
my $monitoring_event_custom_data = '';
push(@{$custom_data->{'actions'}}, safe_output($action->{'action_name'}));
# Does the action generate an event? # Does the action generate an event?
if (safe_output($action->{'name'}) eq "Monitoring Event") { if (safe_output($action->{'name'}) eq "Monitoring Event") {
$event_generated = 1; $event_generated = 1;
$monitoring_event_custom_data = $custom_data;
} }
pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros); pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros, $monitoring_event_custom_data);
push(@{$custom_data->{'actions'}}, safe_output($action->{'action_name'}));
} else { } else {
if (defined ($module)) { if (defined ($module)) {
logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10); logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10);
@ -1082,9 +1085,9 @@ Execute the given action.
=cut =cut
########################################################################## ##########################################################################
sub pandora_execute_action ($$$$$$$$$;$) { sub pandora_execute_action ($$$$$$$$$;$$) {
my ($pa_config, $data, $agent, $alert, my ($pa_config, $data, $agent, $alert,
$alert_mode, $action, $module, $dbh, $timestamp, $extra_macros) = @_; $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros, $custom_data) = @_;
logger($pa_config, "Executing action '" . safe_output($action->{'name'}) . "' for alert '". safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'nombre'}) : 'N/A') . "'.", 10); logger($pa_config, "Executing action '" . safe_output($action->{'name'}) . "' for alert '". safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'nombre'}) : 'N/A') . "'.", 10);
@ -1642,25 +1645,30 @@ sub pandora_execute_action ($$$$$$$$$;$) {
if ((! defined($alert->{'disable_event'})) || (defined($alert->{'disable_event'}) && $alert->{'disable_event'} == 0)) { if ((! defined($alert->{'disable_event'})) || (defined($alert->{'disable_event'}) && $alert->{'disable_event'} == 0)) {
pandora_event( pandora_event(
$pa_config, $pa_config,
$event_text, $event_text,
(defined ($agent) ? $agent->{'id_grupo'} : 0), (defined ($agent) ? $agent->{'id_grupo'} : 0),
(defined ($fullagent) ? $fullagent->{'id_agente'} : 0), (defined ($fullagent) ? $fullagent->{'id_agente'} : 0),
$priority, $priority,
(defined($alert) (defined($alert)
? defined($alert->{'id_template_module'}) ? defined($alert->{'id_template_module'})
? $alert->{'id_template_module'} ? $alert->{'id_template_module'}
: $alert->{'id'} : $alert->{'id'}
: 0), : 0),
(defined($alert) ? $alert->{'id_agent_module'} : 0), (defined($alert) ? $alert->{'id_agent_module'} : 0),
$event_type, $event_type,
0, 0,
$dbh, $dbh,
$source, $source,
'', '',
$comment, $comment,
$id_extra, $id_extra,
$tags); $tags,
'',
'',
'',
p_encode_json($pa_config, $custom_data)
);
# Validate event (field1: agent name; field2: module name) # Validate event (field1: agent name; field2: module name)
} }
} elsif ($clean_name eq "Validate Event") { } elsif ($clean_name eq "Validate Event") {