check if downtime is scheduled for a host via CGI

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

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: 3601
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 Community Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 18 guests