[icinga-checkins] icinga.org: icinga-core/test/cgis: core: add useful message to p1. pl when epn plugin does not call exit() (Sven Nierlein) #2431

git at icinga.org git at icinga.org
Wed Aug 1 03:00:11 CEST 2012


Module: icinga-core
Branch: test/cgis
Commit: 20db17122ae79ca05975034827e512e06dbfdfaf
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=20db17122ae79ca05975034827e512e06dbfdfaf

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Fri Jul  6 19:38:41 2012 +0200

core: add useful message to p1.pl when epn plugin does not call exit() (Sven Nierlein) #2431

refs #2431

---

 Changelog |    1 +
 p1.pl.in  |   10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Changelog b/Changelog
index 981ee71..91a8863 100644
--- a/Changelog
+++ b/Changelog
@@ -11,6 +11,7 @@ ENHANCEMENTS
 * core: try the most common macros ($ARGn$, $USERn$) first (Andreas Ericsson) #2674
 * core: handle passive checks via external commands the same way as active checks, bypassing the temp check result file and reaper (Andreas Ericsson) #2687
 * core: use binary search when looking up macro names, instead of insane strcmp() loops (Andreas Ericsson) #2675
+* core: add useful message to p1.pl when epn plugin does not call exit() (Sven Nierlein) #2431
 
 * idoutils: change hasfunc to use sdbm algorithm for hashing precached objects #2792
 * icinga.spec: add devel package #2634
diff --git a/p1.pl.in b/p1.pl.in
index 0b7dff9..8e24641 100644
--- a/p1.pl.in
+++ b/p1.pl.in
@@ -266,9 +266,9 @@ sub run_package {
 	my ($filename, undef, $plugin_hndlr_cr, $plugin_args) = @_;
 								# Second parm (after $filename) _may_ be used to wallop stashes.
 
+	my $has_exit	= 0 ;
 	my $res		= 3 ;
-	my $ts		= localtime(time()) 
-				if DEBUG_LEVEL ;
+	my $ts		= localtime( time() ) if DEBUG_LEVEL ;
      
 	local $SIG{__WARN__}	= \&throw_exception ;
 	my $stdout		= tie (*STDOUT, 'OutputTrap');
@@ -283,9 +283,9 @@ sub run_package {
 	if ($@) {
 								# Error => normal plugin termination (exit) || run time error.
 		$_			= $@ ;
-		/^ExitTrap: (-?\d+)/	? $res = $1 :
+		/^ExitTrap: (-?\d+)/	? do { $has_exit = 1; $res = $1 } :
 								# For normal plugin exit, $@ will  always match /^ExitTrap: (-?\d+)/
-		/^ExitTrap:  /		? $res = 0  :	do {
+		/^ExitTrap:  /		? do { $has_exit = 1; $res = 0 }  : do {
 								# Run time error/abnormal plugin termination.
 	
 								chomp ;
@@ -304,6 +304,8 @@ sub run_package {
 	undef $stdout ;
 	untie *STDOUT;
 
+	$plugin_output = "**ePN $filename: plugin did not call exit()\n".$plugin_output if $has_exit == 0;
+
 	print LH qq($ts run_package: "$filename $plugin_args" returning ($res, "$plugin_output").\n) 
 		if DEBUG_LEVEL & LEAVE_MSG ;
 





More information about the icinga-checkins mailing list