Page 1 of 1

eventhandler halts Nagios

Posted: Mon Dec 10, 2012 11:54 am
by uplink
In my central Nagios installation, I make use of ConSol*'s check_logfiles script. In some situations, I need to pause regular checking, manually run some cruncher on a remote machine, then restart checking that service.

This is done as event handler, which works well.

However it seems the whole of Nagios (checks, updates to nagios.log, everything) pauses, every time said eventhandler script is run.

I care, because this processing done in an eventhandler can take tens of minutes, during which nothing else happens at the central Nagios site, as well as a check for Nagios' wellbeing triggers, as nagios.log is not updated.

Before I dig deeper .. is this by design?
Am I calling my script wrong?
Should I take care of going into the background myself?

Code: Select all

define command {
        command_name    untangle-check_logfiles-over-ssh
        command_line    $USER2$/untangle-check_logfiles-over-ssh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$ $ARG1$ '$ARG2$'
}

define service {
...
    eventhandler    untangle-check_logfiles-over-ssh!username!'check_logfiles -f check_logfiles.conf --searches=Service.Log'
}
Any help is greatly appreciated!

Rupert

Re: eventhandler halts Nagios

Posted: Mon Dec 10, 2012 1:07 pm
by mguthrie
Event handlers are blocking processes in Nagios, which means all checks, alerts, and otherwise will wait for that event handler to complete execution. So whatever the event handler is, you want it to be very quick to complete execution. What might be better would be to have the event handler either touch a file, or create a job in a database, and then have a cron job or something run the actual process.

Re: eventhandler halts Nagios

Posted: Tue Dec 11, 2012 8:29 am
by uplink
mguthrie wrote:Event handlers are blocking processes in Nagios
that's what I feared. ok, will come up with a nonblocking/external solution.

thanks!

Re: eventhandler halts Nagios

Posted: Tue Dec 11, 2012 10:01 am
by uplink
uplink wrote:will come up with a nonblocking/external solution.
for others' reference: changed my calling some eventhandler to use at .. presto:

Code: Select all

define command {
        command_name    untangle-check_logfiles-over-ssh
        command_line    echo "$USER2$/untangle-check_logfiles-over-ssh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$ $ARG1$ '$ARG2$'" | /usr/bin/at now
}

Re: eventhandler halts Nagios

Posted: Tue Dec 11, 2012 11:38 am
by mguthrie
That actually simplifies something I was trying to get to work a while back, thanks for posting what you did!