Page 1 of 1

Event Handler woes

Posted: Tue Feb 12, 2013 5:42 pm
by lsaspac
Hi all,

I'm trying to implement my first event handler but I cannot get it to trigger. I am following the guide from here to restart a Windows service - http://assets.nagios.com/downloads/nagi ... h_NRPE.pdf

I am running Nagios XI 2011R2.3 on Centos 6.2 on VMWare (the pre-built image available for download), Nagios itself has been upgraded a couple of times

The Event Handler script itself is working fine, I can execute this manually and my windows service will start successfully. Using some logging in the handler script I can determine it is never run, so it must be bad configuration in my nagios instance

I've setup a command as follows...
Command: WindowsService__Restart
Command line: $USER1$/servicestart.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$
Command type: misc command
Active: enabled

The service...
Event handler: WindowsService__Restart
Event handler enabled: on

The service uses a couple of templates, Event Handler is empty and Event handler enabled is skip. There is also a service escalation in use (first notification=1) if relevant

any help would be appreciated, many thanks :-)

Re: Event Handler woes

Posted: Wed Feb 13, 2013 10:21 am
by slansing
I believe you have a typo here:

Code: Select all

Command line: $USER1$/servicestart.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$
It should read:

Code: Select all

 Command line: $USER1$/servicerestart.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$
servicestart should be servicerestart.

Re: Event Handler woes

Posted: Wed Feb 13, 2013 4:50 pm
by lsaspac
Hi slansing

I appear to have deviated slightly from the guide in the naming of my script, though it is consistent in my setup

The command I use to execute the handler manually is

Code: Select all

$ sudo bash ./servicestart.sh CRITICAL 10.10.1.1 vpxd
thanks

Re: Event Handler woes

Posted: Wed Feb 13, 2013 5:04 pm
by scottwilkerson
Can you show us

Code: Select all

ll /usr/local/nagios/libexec/servicestart.sh

Re: Event Handler woes

Posted: Wed Feb 13, 2013 5:45 pm
by lsaspac
Hi Scott,

here is servicestart.sh

Code: Select all

#!/bin/sh
# Event Handler for Restarting Windows Services
echo `date` Event! $1 - $2 - $3 >> output
case "$1" in
        OK)
                echo OK! >> output
                ;;
        WARNING)
                ;;
        UNKNOWN)
                ;;
        CRITICAL)
                /usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c WindowsService__Restart -a $3
                echo Relaunch! >> output
                ;;
esac

exit 0
thanks

Re: Event Handler woes

Posted: Thu Feb 14, 2013 10:54 am
by abrist
Scott was looking for the permissions on the file, not the actual contents. lsaspac - could you run the following command and post the output here?

Code: Select all

ll /usr/local/nagios/libexec/servicestart.sh

Re: Event Handler woes

Posted: Thu Feb 14, 2013 4:47 pm
by lsaspac
sorry guys! linux newb here :-)

Code: Select all

$ ll /usr/local/nagios/libexec/servicestart.sh
-rw-r--r-- 1 root root 318 Feb 15 08:44 /usr/local/nagios/libexec/servicestart.sh

Re: Event Handler woes

Posted: Thu Feb 14, 2013 4:55 pm
by slansing
Please run the following directed at that file:

Code: Select all

chmod +x /usr/local/nagios/libexec/servicestart.sh
This will allow the script to be executable. Your event handler should work now, if this is the only issue we run into :).

Re: Event Handler woes

Posted: Thu Feb 14, 2013 5:07 pm
by lsaspac
Thankyou slansing, scottwilkerson and abrist. My issue is resolved :D

Re: Event Handler woes

Posted: Thu Feb 14, 2013 5:52 pm
by slansing
Excellent, thanks for letting us know!