Added hung check handling
exit $oldstatus;
}
-open CHECK, '-|', $checkcommand;
+my ($pid, $hung, $exitstatus);
+$SIG{ALRM} = sub {
+ kill 9, $pid;
+ $hung = 1;
+};
+alarm 10;
+
+$pid = open CHECK, '-|', $checkcommand;
$status = <CHECK>;
$details = join('', <CHECK>);
close CHECK;
-my $exitstatus = $? >> 8;
+if ($hung) {
+ $status = 'TIMEOUT';
+ $details = 'Check did not complete within ten seconds';
+ $exitstatus = -1;
+} else {
+ $exitstatus = $? >> 8;
+}
if ($exitstatus == 0 && $oldstatus != 0) {
do_command($_) foreach @{$on{success}};