Event Handler woes

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lsaspac
Posts: 9
Joined: Mon Feb 27, 2012 8:23 pm

Event Handler woes

Post 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 :-)
Last edited by lsaspac on Thu Feb 14, 2013 5:12 pm, edited 1 time in total.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Event Handler woes

Post 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.
lsaspac
Posts: 9
Joined: Mon Feb 27, 2012 8:23 pm

Re: Event Handler woes

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Event Handler woes

Post by scottwilkerson »

Can you show us

Code: Select all

ll /usr/local/nagios/libexec/servicestart.sh
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lsaspac
Posts: 9
Joined: Mon Feb 27, 2012 8:23 pm

Re: Event Handler woes

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Event Handler woes

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
lsaspac
Posts: 9
Joined: Mon Feb 27, 2012 8:23 pm

Re: Event Handler woes

Post 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
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Event Handler woes

Post 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 :).
lsaspac
Posts: 9
Joined: Mon Feb 27, 2012 8:23 pm

Re: Event Handler woes

Post by lsaspac »

Thankyou slansing, scottwilkerson and abrist. My issue is resolved :D
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Event Handler woes

Post by slansing »

Excellent, thanks for letting us know!
Locked