New User: Getting a List of Status Details via Curl

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Groggle
Posts: 1
Joined: Wed Aug 10, 2016 8:02 am

New User: Getting a List of Status Details via Curl

Post by Groggle »

Hi all,

I'm a very new Nagios user and I've been having a hard time figuring out how to do something:

Basically what I need to do is to be able to get stats of about 6 groups of 4 kinds of hosts, by stats I mean things like swap usage, etc and I need to be able to get them via a JSON query. Ideally I'd like to be able to call 6 JSON queries (one for each group). The idea would be to apply a certain service/list of services against a group of hosts. Like if I had 4 Linux servers, I'd like to ideally be able to call the swap check service against all four. I don't think I'm going about it the right way, I'll define my approach below:

My initial attempt has been to define the list of "info" I need in a service group and then call that service group through the JSON query generator. This seems to sort of work but the problem is that I'd have to manually add each host to the service group in order to call the task.

(I am able to call the service list JSON query from curl without issue)

Any help would be wildly appreciated.

EDIT: Just to clarify, what would be the way to get information about a host that is not a "check". Like, let's say I'm monitoring a MongoDB, I just want to get how many collections there are. There is no "good" or "bad" value, I just want to get the info.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: New User: Getting a List of Status Details via Curl

Post by lmiltchev »

You could try using the REST API (see usage under the Help menu). Try something like this:

Code: Select all

curl -XGET "http://x.x.x.x/nagiosxi/api/v1/objects/servicestatus?apikey=xxx&pretty=1&host_name=in:"host1","host2","host3","host4"&name=SWAP%20USAGE"
Is this what you are trying to achieve?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked