Add action information to alert events.

This commit is contained in:
Ramon Novoa 2021-09-13 13:13:46 +02:00
parent eaaab1e250
commit 1344dee2c4
1 changed files with 27 additions and 2 deletions

View File

@ -4225,7 +4225,13 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
my $trap_rcv_full = $trap_oid . " " . $trap_value. " ". $trap_type. " " . $trap_custom_oid;
# Additional execution information for the console.
my $custom_data = {
'actions' => [],
};
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh, $timestamp, \%macros) if (defined ($action));
push(@{$custom_data->{'actions'}}, safe_output($action->{'name'}));
# Generate an event, ONLY if our alert action is different from generate an event.
if ($action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){
@ -4287,11 +4293,30 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
);
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert_action, 1, $other_action, undef, $dbh, $timestamp, \%macros) if (defined ($other_action));
push(@{$custom_data->{'actions'}}, safe_output($other_action->{'name'}));
# Generate an event, ONLY if our alert action is different from generate an event.
if ($other_action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){
pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")",
0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh);
pandora_event (
$pa_config,
"SNMP alert fired (" . safe_output($alert->{'description'}) . ")",
0,
0,
$alert->{'priority'},
0,
0,
'alert_fired',
0,
$dbh,
undef,
undef,
undef,
undef,
undef,
undef,
undef,,
undef,
p_encode_json($pa_config, $custom_data));
}
# Update alert status