From 5b52fc2385cb6222e01f38878d9a1c9d516b986e Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 26 Sep 2023 16:46:39 +0200 Subject: [PATCH] Add support for critical_on_error. The critical_on_error option adds improved error detection capabilities to the Pandora FMS Enterprise ICMP Server (and maybe other servers in the future). --- pandora_server/conf/pandora_server.conf.new | 3 +++ pandora_server/lib/PandoraFMS/Config.pm | 4 ++++ pandora_server/lib/PandoraFMS/PluginServer.pm | 1 + 3 files changed, 8 insertions(+) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 816fcc4244..7aba09011f 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -220,6 +220,9 @@ icmp_checks 1 # Number of ICMP packets to send per request. icmp_packets 2 +# If set to 1 (the default), when the executions of certain checks fail (not the checks themselves) the modules go to critical. If set to 0, they will end up going to unknown. +critical_on_error 1 + # tcp specific options : # tcp_checks: number of tcp retries if first attempt fails. # tcp_timeout: specific timeout for tcp connections diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index e378fd1e61..32bf401eba 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -265,6 +265,7 @@ sub pandora_load_config { $pa_config->{"keepalive_orig"} = $pa_config->{"keepalive"}; $pa_config->{"icmp_checks"} = 1; # Introduced on 1.3.1 $pa_config->{"icmp_packets"} = 1; # > 5.1SP2 + $pa_config->{"critical_on_error"} = 1; # > 7.0.774 $pa_config->{"alert_recovery"} = 0; # Introduced on 1.3.1 $pa_config->{"snmp_checks"} = 1; # Introduced on 1.3.1 $pa_config->{"snmp_timeout"} = 8; # Introduced on 1.3.1 @@ -830,6 +831,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^icmp_packets\s+([0-9]*)/i) { $pa_config->{"icmp_packets"} = clean_blank($1); } + elsif ($parametro =~ m/^critical_on_error\s+([0-1])/i) { + $pa_config->{"critical_on_error"} = clean_blank($1); + } elsif ($parametro =~ m/^snmpconsole\s+([0-9]*)/i) { $pa_config->{"snmpconsole"} = clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index 370cd2c2b9..9751372d04 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -272,6 +272,7 @@ sub data_consumer ($$) { $module_data = `$command`; if ($? < 0) { logger($pa_config, "Error executing command from module # $module_id. Probably out of memory.", 10); + pandora_timed_event(300, $pa_config, "Cannot process monitoring data. plug-in module \#$module_id failed to execute on server " . $pa_config->{'servername'}, 0, 0, 6, 0, 0, 'system', 0, $dbh); } };