API: H/T determine service status

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

API: H/T determine service status

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: API: H/T determine service status

Post 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
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
mbeebe
Posts: 144
Joined: Thu Dec 20, 2018 5:12 pm

Re: API: H/T determine service status

Post by mbeebe »

That worked -- thanks!

Please feel free to close this thread.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API: H/T determine service status

Post by scottwilkerson »

mbeebe wrote:That worked -- thanks!

Please feel free to close this thread.
Excellent!

Locking
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked