Page 1 of 1

API: H/T determine service status

Posted: Tue May 14, 2019 1:32 pm
by mbeebe
Hello,

Another API question: how can we determine the status of a service via the API? We'd like to be able to determine if a service is either OK, Warn or Critical.

Thanks,

-- Mike Beebe

Re: API: H/T determine service status

Posted: Tue May 14, 2019 2:03 pm
by lmiltchev
You could use GET objects/hoststatus and objects/servicestatus.

Code: Select all

https://x.x.x.x/nagiosxi/api/v1/objects/hoststatus?apikey=xxx&pretty=1
http://x.x.x.x/nagiosxi/api/v1/objects/servicestatus?apikey=xxx&pretty=1
Example from the CLI:

Code: Select all

curl -s "http://x.x.x.x/nagiosxi/api/v1/objects/servicestatus?apikey=xxx&pretty=1&host_name=localhost&name=Total%20Processes" | grep current_state
        "current_state": "2",
This service is in CRITICAL state ( "current_state": "2").
example01.PNG

Re: API: H/T determine service status

Posted: Wed May 15, 2019 9:25 am
by mbeebe
That worked -- thanks!

Please feel free to close this thread.

Re: API: H/T determine service status

Posted: Wed May 15, 2019 2:55 pm
by scottwilkerson
mbeebe wrote:That worked -- thanks!

Please feel free to close this thread.
Excellent!

Locking