[Nagiosplug-devel] Timeouts in BASH Plugins

Thomas Guyot-Sionnest thomas at zango.com
Fri Aug 29 19:26:00 CEST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Richard Edward Horner wrote:
> Babar,
> 
> Thanks for the response. I wasn't able to make any headway on this.
> I'll guess I'll just rewrite my checks in Perl.

You could probably use this (I didn't tested), but it may leave stall
processes behind:

#!/usr/bin/perl

use strict;
use warnings;

$SIG{'ALRM'} = sub {
  print "CRITICAL: foo\n";
  exit 2;
};

alarm(60);
my $text = `/bin/bash /path/to/plugin.sh`;
my $result = $?>>8;
alarm(0);

print $text;
return $result;
__END__

If you need to kill stale processes, it's a bit more complicated - look
at my check_rsync v1.02 plugin for an example.

http://www.nagiosexchange.org/cgi-bin/page.cgi?g=Detailed%2F2094.html;d=1

- --
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIuDEo6dZ+Kt5BchYRAnAeAJ4vFtPdukgoDqfdHgzKM7PW702kVwCePFLI
ENJCFwf3+ZHv9YbR90G7YNk=
=iXQd
-----END PGP SIGNATURE-----




More information about the Devel mailing list