summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2007-11-30 20:59:08 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2007-11-30 20:59:08 +0000
commitf633745c3c243372a40e0523f43b07f7063e596d (patch)
treedc2a7c4abca61d391d948f6ca65f373f9767f5d8
parente24f55442793d346df02f8621a46e8afe2d630a6 (diff)
From: Stephen Gran <sgran@debian.org>
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
-rwxr-xr-xnagios-check-libs18
1 files 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=<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) {