From b657138fad6f477c96c87ea22f3c873ff8609736 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 5 Feb 2021 13:07:54 +0100 Subject: [PATCH] Changed exit code so error modules are created --- pandora_server/lib/PandoraFMS/PluginTools.pm | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 91d113b464..827feebc02 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.752"; -my $pandora_build = "210205"; +my $pandora_build = "210202"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); @@ -959,7 +959,7 @@ sub print_error { if (is_enabled($conf->{'as_server_plugin'})) { print STDERR $msg . "\n"; print $value . "\n"; - exit 1; + exit 0; } print_module($conf, { @@ -968,7 +968,7 @@ sub print_error { value => $value, desc => $msg, }); - exit 1; + exit 0; } ################################################################################ @@ -991,16 +991,17 @@ sub logger { my ($conf, $tag, $message) = @_; my $file = $conf->{'log'}; - print_error($conf, "[ERROR] Log file is not defined.", 0, 1) unless defined($file); - - # Log rotation - if (defined($file) && -e $file && (stat($file))[7] > 32000000) { - rename ($file, $file.'.old'); + print_error($conf, "[ERROR] Log file is not defined. exit 1; } - my $LOGFILE; - if ($log_aux_flag == 0) { - # Log starts - if (! open ($LOGFILE, "> $file")) { + + print_module($conf, { + name => (empty($conf->{'global_plugin_module'})?"Plugin execution result " . $0:$conf->{'global_plugin_module'}), + type => "generic_proc", + value => $value, + desc => $msg, + }); + exit 1; + { print_error ($conf, "[ERROR] Could not open logfile '$file'", 0, 1); } $log_aux_flag = 1;