[Nagiosplug-devel] Timeouts in BASH Plugins

Olivier 'Babar' Raginel nagios at babar.us
Thu Aug 28 19:11:27 CEST 2008


On Thu, Aug 28, 2008 at 11:55:21AM -0400, Richard Edward Horner wrote:
> 	( sleep $TIMELIMIT; if [ `pgrep -U $USER -f "$SCRIPT" | grep -c ^$$$`
> -gt 0 ] ; then kill -USR1 $$ ; fi; ) &


Did you try to simply "nohup" it, so something like:

( exec >/dev/null;exec 2>&1;exec <&1;sleep $TIMELIMIT; if ...

> So, my questions are:
> 
> 1) Is this no-backgrounding thing an NRPE thing or is it some BASH
> thing that's occurring because there's already no controlling terminal
> or ???
> 
> 2) Can this be made to work in BASH or do I need to use C or Perl
> (both of which I know, just not nearly as well as I know BASH)?

Because I'd think NRPE waits for the tty to be freed, and your 
background process locks it.
Or play with huponexit, but I'm not sure it will work here.

By the way, it works exactly like that in ssh:
$ ssh some.host "(sleep 6)&date"
Takes 6 seconds after date.
$ ssh babar.us "(exec >/dev/null;exec 2>&1;exec <&1;sleep 6)&date"
Returns after date

-- 
Babar.




More information about the Devel mailing list