Rest API returning Success even when Failed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
optionstechnology
Posts: 234
Joined: Thu Nov 17, 2016 11:26 am

Rest API returning Success even when Failed

Post 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?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Rest API returning Success even when Failed

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
optionstechnology
Posts: 234
Joined: Thu Nov 17, 2016 11:26 am

Re: Rest API returning Success even when Failed

Post by optionstechnology »

That that would work

Thanks
bolson

Re: Rest API returning Success even when Failed

Post by bolson »

May we close this topic?
Locked