Page 1 of 1

Rest API returning Success even when Failed

Posted: Wed Jul 19, 2017 11:11 am
by optionstechnology
I use the rest API to add hosts via Powershell

Since I am adding a large number of hosts at the same time I add the hosts without restarting the config and when they are all added restart the nagios server with the following-

Code: Select all

Invoke-RestMethod -Method Post -Uri "https://nagiosserver/nagiosxi/api/v1/config/host?apikey=##########" -Body "force=1&applyconfig=1"
This gets the response-
success
-------
Successfully added to the system. Config applied, Nagios Core was restarted.
The problem is that sometimes the Nagios server doesn't restart- sometimes there is a config issue that prevents it- but the API command still returns the success message...

Is there any way to show that the Nagios server has actually restarted successfully?

Re: Rest API returning Success even when Failed

Posted: Wed Jul 19, 2017 3:06 pm
by tgriep
You can use the Get System/Status API and verify that the "program_start_time": "2017-07-19 15:03:46", has changed after the previous API was executed.
Here is the API.

Code: Select all

curl -XGET  "https://nagiosserver/nagiosxi/api/v1/system/status?apikey=######&pretty=1""
Would that work for you?

Re: Rest API returning Success even when Failed

Posted: Mon Aug 21, 2017 8:39 am
by optionstechnology
That that would work

Thanks

Re: Rest API returning Success even when Failed

Posted: Mon Aug 21, 2017 10:44 am
by bolson
May we close this topic?