Event handler and script with sleep does not work

Hi.
I have coded an event handler that basically should reboot a server on a hard critical event.
The code looks something like this:

[code]#!/bin/bash

… code to handle states.

code to power off server
#wait 30 seconds
sleep 30
code to power on server[/code]

Now when I execute the script from a terminal, everything works. If I use it as an eventhandler, then only the lines up to the sleep command gets executed. After the sleep it seems like the script is terminated.

The command to call the event handler looks like this:

# 'Reboot dkxlsrv1' command definition define command{ command_name reboot-sw1 command_line /usr/local/nagios/libexec/eventhandlers/reboot-sw1 $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ & }

Any ideas or input will be greatly appreciated.

Hi

You could try winding up the event_handler_timeout parameter in nagios.cfg. You should see something in the log file if you are running into this threshold…

[blockquote]Format: event_handler_timeout=
Example: event_handler_timeout=60

This is the maximum number of seconds that Nagios will allow event handlers to be run. If an event handler exceeds this time limit it will be killed and a warning will be logged.

There is often widespread confusion as to what this option really does. It is meant to be used as a last ditch mechanism to kill off commands which are misbehaving and not exiting in a timely manner. It should be set to something high (like 60 seconds or more), so that each event handler command normally finishes executing within this time limit. If an event handler runs longer than this limit, Nagios will kill it off thinking it is a runaway processes. [/blockquote] nagios.sourceforge.net/docs/3_0/ … mmand_file

HTH

/S