check if downtime is scheduled for a host via CGI

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check if downtime is scheduled for a host via CGI

Postby vivekm » Tue May 17, 2016 12:43 pm

How do we check if we have a downtime scheduled for a host via CGI in Nagios Core 4.x??

probably even get the downtime id for it as well...
vivekm
 
Posts: 4
Joined: Tue May 17, 2016 4:19 am

Re: check if downtime is scheduled for a host via CGI

Postby mcapra » Tue May 17, 2016 1:13 pm

The JSON Query Generator is super handy for this sort of thing (where x.x.x.x is your Core install):
http://x.x.x.x/nagios/jsonquery.html

A brief intro to the JSON Query Generator: https://labs.nagios.com/2014/06/19/expl ... -7-part-1/

If you wanted to check if host y.y.y.y has scheduled downtime, you could try the following query (where x.x.x.x is your Core install):

http://x.x.x.x/nagios/cgi-bin/statusjson.cgi?query=downtimelist&formatoptions=whitespace&hostname=y.y.y.y&downtimeobjecttypes=host&downtimetimefield=starttime

downtimelist will be empty if there is no downtime scheduled, otherwise it will contain the downtime id for each scheduled downtime for host y.y.y.y.

Also if you wanted a graphical response, drop the json from the script you are running:

http://x.x.x.x/nagios/cgi-bin/status.cgi?query=downtimelist&formatoptions=whitespace&hostname=y.y.y.y&downtimeobjecttypes=host&downtimetimefield=starttime
Former Nagios employee
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3587
Joined: Thu May 05, 2016 3:54 pm

Re: check if downtime is scheduled for a host via CGI

Postby vivekm » Wed May 18, 2016 5:41 am

Hi

It solved the use-case i was implementing. Thanks a lot for your response. Cheers

Vivek
vivekm
 
Posts: 4
Joined: Tue May 17, 2016 4:19 am


Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 13 guests