Page 1 of 1

Json query for empty hostgroups

Posted: Fri Jun 12, 2015 9:01 am
by WillemDH
Hello,

it seems like the json query

curl -s "user:pw@srvnagios01/nagios/cgi-bin/objectjson.cgi?query=hostgrouplist"

is not able to find empty hostgroups. Is this normal behaviour? It kind of messes up some of my script as I'm looking is a hostgroup exists with this, but it might be this hostgroup was very recently created...

Is there some json query that does find all the hostgroups including the empty ones?

Grtz

Willem

Re: Json query for empty hostgroups

Posted: Fri Jun 12, 2015 12:28 pm
by lmiltchev
Nagios Core discards the hostgroups with no members in them and they are not even shown in the web UI. In Nagios XI you see them, as the info is pulled from the database.

I was able to verify that by using the below query:

Code: Select all

curl -s "user:pw@srvnagios01/nagios/cgi-bin/objectjson.cgi?query=hostgrouplist"
you are not going to be able to pull information about "empty" hostgroups. You could however use the Backend API component in XI to do so ("Hostgroups" URL).

Re: Json query for empty hostgroups

Posted: Fri Jun 12, 2015 5:43 pm
by WillemDH
Ok, I'll try the backend api. It would be nice though if it could be added to json, but I guess that would be a core feature requesst.

Re: Json query for empty hostgroups

Posted: Mon Jun 15, 2015 8:46 am
by lmiltchev
Ok, I'll try the backend api.
Let us know if this works out for you.

Re: Json query for empty hostgroups

Posted: Tue Jun 30, 2015 8:18 am
by WillemDH
it doesn't really work out for me.. Seems it's not technically possible to get empty hostgroups with json, which just is not very practical. Please close this thread.