--- a/check_exec.pl Tue Dec 21 15:19:21 2010 +0100
+++ b/check_exec.pl Wed Dec 22 08:52:31 2010 +0100
@@ -66,54 +66,7 @@
my @cmd = ($run_file);
- open(OUTPUT, "-|") or do {
- open(STDERR, ">&STDOUT");
- system(@cmd);
- };
-
- my $result = <OUTPUT>;
-
- close(OUTPUT);
-
- if ($? == -1) {
- print "EXEC CRITICAL: Failed to execute: $!\n";
- cleanup($run_file);
- exit $ERRORS{CRITICAL};
- }
- elsif ($? & 127) {
- printf "EXEC CRITICAL: Child died with signal %d, %s coredump\n",
- ($? & 127), ($? & 128) ? 'with' : 'without';
- cleanup($run_file);
- exit $ERRORS{CRITICAL};
- }
- else {
- my $rc = $? >> 8;
- if ($rc == $ERRORS{OK}) {
- print "EXEC OK: $result";
- cleanup($run_file);
- exit $ERRORS{OK};
- }
- elsif ($rc == $ERRORS{WARNING}) {
- print "EXEC WARNING: $result";
- cleanup($run_file);
- exit $ERRORS{WARNING};
- }
- elsif ($rc == $ERRORS{CRITICAL}) {
- print "EXEC CRITICAL: $result";
- cleanup($run_file);
- exit $ERRORS{CRITICAL};
- }
- elsif ($rc == $ERRORS{UNKNOWN}) {
- print "EXEC UNKNOWN: $result";
- cleanup($run_file);
- exit $ERRORS{UNKNOWN};
- }
- elsif ($rc == $ERRORS{DEPENDENT}) {
- print "EXEC DEPENDENT: $result";
- cleanup($run_file);
- exit $ERRORS{DEPENDENT};
- }
- }
+ exec(@cmd) or print "EXEC CRITICAL: Couldn't exec $run_file ($!)";
}
sub cleanup($) {