Global Event Handlers

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 Handlers

Post 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 ?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Global Event Handlers

Post 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.
Former Nagios employee
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Global Event Handlers

Post 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.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Global Event Handlers

Post 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.
Former Nagios employee
https://www.mcapra.com/
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Global Event Handlers

Post 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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Global Event Handlers

Post 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
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Global Event Handlers

Post 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
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Global Event Handlers

Post 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.
Locked