From f633745c3c243372a40e0523f43b07f7063e596d Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 30 Nov 2007 20:59:08 +0000 Subject: From: Stephen Gran Heya, So I've recently discovered that running check-libs directly from nagios rather than from nrpe causes it to exit with a wrong exit status. The problem is that exit is wrapped by p1.pl in nagios2, raising die, which is then trapped by the signal handler installed in this script, making a normal exit turn into an unknown exit. git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@311 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- nagios-check-libs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nagios-check-libs b/nagios-check-libs index 0a16b79..f357a73 100755 --- a/nagios-check-libs +++ b/nagios-check-libs @@ -21,12 +21,18 @@ my $UNKNOWN = 3; my $params; Getopt::Long::config('bundling'); + +sub dief { + print STDERR $_; + exit $UNKNOWN; +} + if (!GetOptions ( '--help' => \$params->{'help'}, '--version' => \$params->{'version'}, '--verbose' => \$params->{'verbose'}, )) { - die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose]\n"); + dief ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose]\n"); }; if ($params->{'help'}) { print "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose]\n"; @@ -40,12 +46,6 @@ if ($params->{'version'}) { exit (0); }; -$SIG{'__DIE__'} = sub { - print STDERR @_; - exit $UNKNOWN; -}; - - my %processes; sub getPIDs($$) { @@ -84,11 +84,11 @@ sub inVserver() { my $INVSERVER = inVserver(); print STDERR "Running $LSOF -n\n" if $params->{'verbose'}; -open (LSOF, "$LSOF -n|") or die ("Cannot run $LSOF -n: $!\n"); +open (LSOF, "$LSOF -n|") or dief ("Cannot run $LSOF -n: $!\n"); my @lsof=; close LSOF; if ($CHILD_ERROR) { # program failed - die("$LSOF -n returned with non-zero exit code: ".($CHILD_ERROR / 256)."\n"); + dief("$LSOF -n returned with non-zero exit code: ".($CHILD_ERROR / 256)."\n"); }; for my $line (@lsof) { -- cgit v1.2.3