Determine if a host is in downtime via API?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mbeebe
Posts: 144
Joined: Thu Dec 20, 2018 5:12 pm

Determine if a host is in downtime via API?

Post by mbeebe »

Hello again,

This time, we're trying to determine whether a host is in downtime or not via the API: is this possible?

Thanks as always for your time,


-- Mike Beebe
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Determine if a host is in downtime via API?

Post by npolovenko »

@mbeebe, You can run the object/hoststatus API query and look for the "scheduled_downtime_depth" parameter.
Untitled.png
You can also query a specific host only by adding &host_name=YourHostName at the end of the query.
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mbeebe
Posts: 144
Joined: Thu Dec 20, 2018 5:12 pm

Re: Determine if a host is in downtime via API?

Post by mbeebe »

Thank you for that answer.

We're having another issue, and rather than spawning a dozen threads, I'll keep my questions in this one:

API to submit downtime not working.

POST URL:
http://xxx.xxx.xxx/nagiosxi/api/v1/syst ... services=1

POST to API returns the following:
{ "success": "Schedule downtime command(s) sent successfully.", "scheduled": { "hosts": [ "xxx.xxx.xxx" ], "services": { "xxx.xxx.xxx": [ "ALL" ] } } }

HTTP Access log:
10.194.11.244 - - [01/May/2019:14:57:54 -0700] "POST /nagiosxi/api/v1/system/scheduleddowntime?apikey=xxxxxxxxxxxxxxxxxx&pretty=1&comment=test&start=1556722620&end=1556722740&hosts[]=xxx.xxx.xxx&all_services=1 HTTP/1.1" 200 284 "-" "PostmanRuntime/7.11.0"

However, when we look on the web interface, the server doesn't show as being in downtime. To make matters stickier, this is intermittent.

Any advice on this?


-- Mike Beebe
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Determine if a host is in downtime via API?

Post by npolovenko »

@mbeebe, Let's keep API related questions in this thread but for other non-related questions, please open a new thread.
Is there a pattern when the downtime API command fails? For example, if you submit many commands at once, etc? Is there a specific host that fails most or this happens with different hosts randomly? How are you submitting API commands, what tool are you using?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mbeebe
Posts: 144
Joined: Thu Dec 20, 2018 5:12 pm

Re: Determine if a host is in downtime via API?

Post by mbeebe »

I'll make sure to create new threads for new questions outside of the current API questions.

Here are the answers to your questions:

1. As far as we've tested, there doesn’t seem to be a pattern to the API failures. One command is being submitted at a time.
2. There seems to be no pattern as far as which hosts fails; totally random as far as we can tell.
3. Command is submitted via a PHP web interface that generates the curl statement

Please let me know if you have any other questions. I know this isn't a lot to go on, but we appreciate your help.

-- Mike Beebe
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Determine if a host is in downtime via API?

Post by scottwilkerson »

The difference between your start time and end time were only 2 minutes and depending on what timezone you are in, likely had already passed by the time you made the post.

Can you test it using a time that is well into the future and see if the downtime shows in the list of scheduled downtimes?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mbeebe
Posts: 144
Joined: Thu Dec 20, 2018 5:12 pm

Re: Determine if a host is in downtime via API?

Post by mbeebe »

Hello,

A quick note to let you know we resolved the issue and it was something on our side.

Thanks again for the help,

-- Mike Beebe
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Determine if a host is in downtime via API?

Post by scottwilkerson »

mbeebe wrote:Hello,

A quick note to let you know we resolved the issue and it was something on our side.

Thanks again for the help,

-- Mike Beebe
glad to hear it is resolved!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked