Page 1 of 1

Global Event Handlers

Posted: Mon Mar 13, 2017 8:09 pm
by Fred Kroeger
The nagios.cfg file has two Global event hadlers defined - These commands call

Code: Select all

# GLOBAL EVENT HANDLERS
global_host_event_handler=xi_host_event_handler
global_service_event_handler=xi_service_event_handler
These commands both call /usr/local/nagiosxi/scripts/handle_nagioscore_event.php.
What do they actually do ?

Re: Global Event Handlers

Posted: Tue Mar 14, 2017 10:02 am
by tmcdonald
The easy answer is that they run this:

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=host --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --hostdowntime=$HOSTDOWNTIME$
for a host, and this:

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=service --host="$HOSTNAME$" --service="$SERVICEDESC$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --servicedowntime=$SERVICEDOWNTIME$
for a service. But that doesn't necessarily answer your question.

The basic answer if that if you have global event handlers set up as per this doc:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

then the information saved to the DB by the above two commands is used to run whatever you have configured according to the doc.

Re: Global Event Handlers

Posted: Tue Mar 14, 2017 9:52 pm
by Fred Kroeger
aha - thanks for that.
It also writes it to the event log for every event as well. So for every event we have two log entries - one for the actual event and one from the Global event handler for the same event.
My event log shows 100,000+ entries for the last 24hrs so I was trying to find out if there was anyway to reduce the unnecessary events.

Re: Global Event Handlers

Posted: Wed Mar 15, 2017 10:20 am
by mcapra
Does your nagios.cfg have log_event_handlers set to 1 by chance? Just so I can be sure i'm understanding the problem fully.

Re: Global Event Handlers

Posted: Thu Mar 16, 2017 1:54 am
by Fred Kroeger
Yes log event handlers is on as I have a custom event handler that interfaces to Service Now for all Host events and selected Services.

Re: Global Event Handlers

Posted: Thu Mar 16, 2017 4:55 pm
by ssax
Ah, ok, that's likely what's causing it, I looked at the code and there is not a built in way to ignore them. I created a patch that should do what you're looking for but it requires you to recompile nagios core, which means that you'd need to redo it every time you upgrade XI, let me know what you'd like to do.

Thank you

Re: Global Event Handlers

Posted: Fri Mar 17, 2017 2:23 am
by Fred Kroeger
Thanks for following up. The least amount of customisations the better, so I'll forgo your kind offer of a patch
You can close this up

Re: Global Event Handlers

Posted: Fri Mar 17, 2017 9:15 am
by ssax
I've created a Nagios Core feature request here to add that functionality:

Code: Select all

https://github.com/NagiosEnterprises/nagioscore/issues/349
Locking it up.