capture return value from event handler?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
JoyBush
Posts: 3
Joined: Mon Oct 06, 2014 10:03 am

capture return value from event handler?

Post by JoyBush »

How can I get an event handler to change (set) the state of a dummy host?

I have been stuck for a week trying to do something like this. Any help greatly appreciated!

Thank you very much!

Joy
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: capture return value from event handler?

Post by abrist »

Well, you usually configure the output of the dummy plugin in the config. So you would have to change the config and restart nagios. You could have the event handler submit a passive check for the object instead of trying to change the dummy state.
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.
JoyBush
Posts: 3
Joined: Mon Oct 06, 2014 10:03 am

Re: capture return value from event handler?

Post by JoyBush »

Thank you for the response, but my problem is a little different ... some clarification:

We need to be able to continually change the status of a dummy host on the fly - not by shutting Nagios down and restarting - based on the status of various hosts/services that are checked within the event handler.

Joy
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: capture return value from event handler?

Post by abrist »

Gotcha. I still think the best method is to submit a passive check to set the state of the object. You can do so from the cli through the command pipe, or through an external call to the cgi with a get request. You would want to turn off freshness checking and active checks on the object so that only the passive checks will effect its state.
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.
JoyBush
Posts: 3
Joined: Mon Oct 06, 2014 10:03 am

Re: capture return value from event handler?

Post by JoyBush »

Thank you for your response. I understand, I think, that I can set the state of the dummy host via having my event handler write a PROCESS_SERVICE_CHECK_RESULT command to the nagios.cmd file. However, I do not understand your reference to a "get request". Could you please give me some more information on what you meant by that?

Thanks!
Joy
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: capture return value from event handler?

Post by abrist »

The cmd.cgi can accept commands through an http get request. For example, to submit a passive check for a host, you can do a wget or curl on the following url:

Code: Select all

http://<nagios server ip>/nagios/cgi-bin/cmd.cgi?cmd_typ=87&cmd_mod=2&host=<hostname>&plugin_state=<state id: 0,1,2>&plugin_output=TEST%20Output&performance_data=&btnSubmit=Commit
Make sure to change <nagios server ip>, <hostname>, and <state id: 0,1,2> as you see fit. The url needs to be url encoded, that is why the space in the plugin_output is encoded as %20.
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.
Locked