Page 1 of 1

Determine if a host is in downtime via API?

Posted: Wed May 01, 2019 3:39 pm
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

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

Posted: Wed May 01, 2019 3:58 pm
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.

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

Posted: Wed May 01, 2019 5:09 pm
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

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

Posted: Thu May 02, 2019 11:24 am
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?

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

Posted: Thu May 02, 2019 12:41 pm
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

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

Posted: Thu May 02, 2019 2:37 pm
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?

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

Posted: Tue May 07, 2019 12:32 pm
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

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

Posted: Tue May 07, 2019 1:11 pm
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!