Page 1 of 1
capture return value from event handler?
Posted: Mon Oct 06, 2014 10:44 am
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
Re: capture return value from event handler?
Posted: Mon Oct 06, 2014 11:18 am
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.
Re: capture return value from event handler?
Posted: Mon Oct 06, 2014 11:28 am
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
Re: capture return value from event handler?
Posted: Mon Oct 06, 2014 4:20 pm
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.
Re: capture return value from event handler?
Posted: Wed Oct 08, 2014 10:08 am
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
Re: capture return value from event handler?
Posted: Wed Oct 08, 2014 11:46 am
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.