handle_nagioscore_event

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

handle_nagioscore_event

Post by onegative »

G'day Support,

Can you please explain EXACTLY what this php script is doing when called either from a host or service event? I see that add_event() method/function is being called but I cannot seem to find the function definition within any of the php code thereby allowing me to understand what/where the event data is being written and why...

The reason I am interested is because I want to know if I modify the global_event definition below and replace the xi_host_event_handler & xi_service_event_handler with my own what functionality am I losing in XI?

# GLOBAL EVENT HANDLERS
global_host_event_handler=xi_host_event_handler
global_service_event_handler=xi_service_event_handler
#global_host_event_handler=event_handler_test
#global_service_event_handler=event_handler_test



xi_host_event_handler
/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$

xi_service_event_handler
/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$


Where is the function defined? I would like to see the code if possible...
add_event(EVENTSOURCE_NAGIOSCORE,EVENTTYPE_STATECHANGE,time(),$event_meta);
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: handle_nagioscore_event

Post by ssax »

Here is a list of the main things that they handle:

Code: Select all

XI User Email Notification
Global Event Handlers
SNMP Trap Senders
Nagios IM Component
Nagios Reactor Component
You can read more about global event handlers here:

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

We are unable to provide you with the code as that function resides in code protected by SourceGuardian.
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

Re: handle_nagioscore_event

Post by onegative »

G'day Support,

So I have more questions.

I am attempting to use the enable_environment_macros=1 so that when I create a command the macro variables are already present in the perl script when called without having to pass arguments. I have attempted to utilize System Extension of the Global Event Handlers to call the short name of a command I have defined in the Core. But the System Extension of the Global Event Handlers do not appear to know about the Core's defined commands and therefore never get called. And I have tried to simply call the Perl script defined in the System Extension of the Global Event Handlers but for whatever reason when an event is generated and the additional extension script is called the macro variables are not set to the %ENV hash...so therefore the only way to get the Core command to work with the embedded %ENV hash variables defined are to specify the command in the main nagios.cfg as follows:

# GLOBAL EVENT HANDLERS
global_host_event_handler=my_custom_command
global_service_event_handler=my_custom_command

My question or the help I am seeking refers to being able to perform both calls to the default xi_host_event_handler & xi_service_event_handler commands and my custom commands...can you provide any ideas that I could incorporate to called both internally because the Extension for the Global Event handlers do not function using the %ENV hash...or am I wrong and just missing the boat?

Please let me know and thanks for all your help and suggestions,
Danny
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: handle_nagioscore_event

Post by jdalrymple »

In order to best help I think we need to know what data you need available and at what point you want your perl to run.

When...
Obsessive?
State Change?
Notification?
etc?

What env bits do you need...
check_command it seems?
What else?

Right now what you're trying to achieve is too vague for us to help.

If you can't tell us what you're trying to do, then I'll just offer that your best bet is to try to run your perl with environmental macros enabled using the appropriate command placement.

Notification commands happen when notifications are supposed to occur
Event handlers happen on state change
Obsessive happens all the time

Bear in mind that environmental variables dramatically affect performance. Good luck.
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

Re: handle_nagioscore_event

Post by onegative »

G' day Support,

What I really am trying to understand is what does the php call do when it executes the add_event() function. I need to know EXACTLY what is lost if the php add_event() function is missed or fails...and how can I know it is successfully run.

I have created another event handler which passes the php call to the handle_nagioscore_event.php as the original global event handler did as well perform the external action I wanted performed from the same event handler...

So the only question I really need help with is what does the add_event() function do and how can I verify it is still functioning from my new event handler?

Please let me know and many thanks for your help and patience...
Danny
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: handle_nagioscore_event

Post by jdalrymple »

onegative wrote:What I really am trying to understand is what does the php call do when it executes the add_event() function.
It adds an event to the event queue. Fairly self explanatory.
onegative wrote:I need to know EXACTLY what is lost if the php add_event() function is missed or fails...and how can I know it is successfully run.
The event doesn't make it into the queue. That's as EXACT as we can be regarding the protected source.
onegative wrote:So the only question I really need help with is what does the add_event() function do
Answered as best as I'm allowed to above...
onegative wrote:and how can I verify it is still functioning from my new event handler?
`tail -f /usr/local/nagiosxi/var/eventman.log`
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

Re: handle_nagioscore_event

Post by onegative »

OK!

That is good enough...so I can verify that the eventman.log is being updated as my new event handler fires...that's really all I need to know.

Thanks very much for the help and the POST can be marked Resolved...
Danny
Locked