Global Event Handler Component

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Global Event Handler Component

Post by Fred Kroeger »

I've configured a Service State Change Handler in the Global Event Handler component but I have not been able to make it work.
And yes I have enabled the Global event Handler (However Notifications are Disabled)

Code: Select all

/usr/local/nagios/local/EventHandlers/Service.sh  "%host%" "%service%"
I have cut it down to an absolute basic script just to prove it

Code: Select all

# cat /usr/local/nagios/local/EventHandlers/Service.sh
#!/bin/sh
# Parameters passed by Nagios

# %host%
# %service%

host=${1}
service=${2}

DATE=`/bin/date`

echo $DATE,$host,$service >> /var/log/events/service-event.txt
Nothing ever gets written to the log file

I can run the command manually and it works fine

Code: Select all

su - nagios -c "/usr/local/nagios/local/EventHandlers/Service.sh HOST-1 SERVICE-A"

# cat /var/log/events/service-event.txt
Wed Nov 11 16:48:47 WST 2015,HOST-1,SERVICE-A
I'm running NagiosXI 5R2.0
Any ideas .... Fred
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Global Event Handler Component

Post by scottwilkerson »

Are these set and un-commented in you nagios.cfg

Code: Select all

global_host_event_handler=xi_host_event_handler
global_service_event_handler=xi_service_event_handler

enable_event_handlers=1
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Global Event Handler Component

Post by scottwilkerson »

Can we also see the following

Code: Select all

ls -l /var/log/events/service-event.txt
ls -l /usr/local/nagios/local/EventHandlers/Service.sh
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Global Event Handler Component

Post by Fred Kroeger »

Thanks Scott - yes the global_host_event_handler & global_service_event_handler entries were commented out in nagios.cfg.
Uncommented them and info is now appearing in my events.txt file OK.
Not sure that I recall seeing anywhere that these variables need to be set for the Global Event Handler Component to work ?
The reason we had it commented out was that we were using a 3rd party app from HP that used used the Global Event Handler to send events to HP's BSM product.
I take it these variables can only be defined once ?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Global Event Handler Component

Post by scottwilkerson »

Fred Kroeger wrote: I take it these variables can only be defined once ?
Correct. However you could change the command that they refer to to run multiple programs, just concatenate the commands.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Global Event Handler Component

Post by Fred Kroeger »

Can you give me an example of concatenating the commands please ?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Global Event Handler Component

Post by ssax »

You would just edit the command like so:

This run the first command and then the second command regardless of the success of Service.sh:

Code: Select all

/usr/local/nagios/local/EventHandlers/Service.sh  "%host%" "%service%"; /your/second/command.sh "%host%" "%service%"
This will run the second command only if the first command is successful:

Code: Select all

/usr/local/nagios/local/EventHandlers/Service.sh  "%host%" "%service%" && /your/custom/hp/command "%host%" "%service%"
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Global Event Handler Component

Post by Fred Kroeger »

Brilliant ! Thanks for this - much apppreciated.
You can close this. Regards.... Fred
Locked