From 6aca4be90c552ea91b80701261d1588f6483f32a Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 19 Jul 2022 11:28:34 +0200 Subject: [PATCH] Add an option to control alert queuing. The alertserver_queue configuration option enables or disables alert queuing for the local server. Ref. pandora_enterprise#8762. --- pandora_server/conf/pandora_server.conf.new | 3 +++ pandora_server/lib/PandoraFMS/Config.pm | 4 ++++ pandora_server/lib/PandoraFMS/Core.pm | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index cc62c41324..8911629b2a 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -723,6 +723,9 @@ alertserver_threads 4 # Generate an hourly warning event if alert execution is being delayed more than alertserver_warn seconds. alertserver_warn 180 +# If set to 1, alerts are queued for the Pandora FMS Alert Server.If alertserver is set to 1, alerts are always queued. +alertserver_queue 0 + # Pandora FMS HA MySQL cluster splitbrain auto-recovery (PANDORA FMS ENTERPRISE ONLY) # IMPORTANT! Please understand and configure all settings from pandora_console/index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster&tab=setup # before enable this feature. diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 647c29026b..352b1bceda 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -550,6 +550,7 @@ sub pandora_load_config { $pa_config->{"alertserver"} = 0; # 7.0 756 $pa_config->{"alertserver_threads"} = 1; # 7.0 756 $pa_config->{"alertserver_warn"} = 180; # 7.0 756 + $pa_config->{"alertserver_queue"} = 0; # 7.0 764 $pa_config->{'ncmserver'} = 0; # 7.0 758 $pa_config->{'ncmserver_threads'} = 1; # 7.0 758 @@ -1284,6 +1285,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^alertserver_warn\s+([0-9]*)/i) { $pa_config->{'alertserver_warn'}= clean_blank($1); } + elsif ($parametro =~ m/^alertserver_queue\s+([0-1]*)/i) { + $pa_config->{'alertserver_queue'}= clean_blank($1); + } elsif ($parametro =~ m/^ncmserver\s+([0-9]*)/i){ $pa_config->{'ncmserver'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index f1419da6db..f98919a39e 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -795,7 +795,7 @@ sub pandora_process_alert ($$$$$$$$;$$) { db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id); } - if ($pa_config->{'alertserver'} == 1) { + if ($pa_config->{'alertserver'} == 1 || $pa_config->{'alertserver_queue'} == 1) { pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module, $alert, 0, $timestamp, 0, $extra_macros, $is_correlated_alert]); } else {