From 74ae4efa9a0f05c36f55fcaf13da8d8c1062db80 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 13 Sep 2021 13:13:46 +0200 Subject: [PATCH] Add action information to alert events. --- pandora_server/lib/PandoraFMS/Core.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 6f4e16e9fe..bd0206ce9d 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -924,6 +924,13 @@ sub pandora_execute_alert ($$$$$$$$$;$$) { return; } + # Additional execution information for the console. + my $custom_data = { + 'actions' => [], + 'forced' => $forced_alert ? 1 : 0, + 'recovered' => $alert_mode == RECOVERED_ALERT ? 1 : 0 + }; + # Critical_instructions, warning_instructions, unknown_instructions my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'}); my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'}); @@ -950,6 +957,7 @@ sub pandora_execute_alert ($$$$$$$$$;$$) { } pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh, $timestamp, $extra_macros); + push(@{$custom_data->{'actions'}}, safe_output($action->{'name'})); } else { if (defined ($module)) { logger ($pa_config, "Skipping action " . safe_output($action->{'name'}) . " for alert '" . safe_output($alert->{'name'}) . "' module '" . safe_output($module->{'nombre'}) . "'.", 10); @@ -986,7 +994,8 @@ sub pandora_execute_alert ($$$$$$$$$;$$) { '', $critical_instructions, $warning_instructions, - $unknown_instructions + $unknown_instructions, + p_encode_json($pa_config, $custom_data) ); } else { pandora_event ( @@ -1007,7 +1016,8 @@ sub pandora_execute_alert ($$$$$$$$$;$$) { '', $critical_instructions, $warning_instructions, - $unknown_instructions + $unknown_instructions, + p_encode_json($pa_config, $custom_data) ); } }