Page 1 of 1

New User: Getting a List of Status Details via Curl

Posted: Thu Aug 18, 2016 12:10 pm
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.

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

Posted: Thu Aug 18, 2016 1:19 pm
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?