Hello all,
Is there a way to find the hosts that dont belong to any group?
Creating a foo group with all hosts and then excluding the groups does not work
A similar post for group exclusion exists here: https://support.nagios.com/forum/viewto ... =7&t=21500
Any ideas
Thank you
Finding All hosts not in groups
-
- Posts: 140
- Joined: Thu Apr 18, 2013 8:25 am
- Location: libexec
Re: Finding All hosts not in groups
The JSON Query Generator is a good place to start. It can typically be found here in Core 4+:
I'd write a script to first pull hostlist to get a list of every host, then for each host in that list pull hostgrouplist and find values where the response's data.hostgrouplist array is empty.
In pseudocode:
I'm sure a more efficient algorithm could be crafted, but if this is a one-off thing I'd just do the above.
Code: Select all
http://<your_nagios_host>/nagios/jsonquery.html
In pseudocode:
Code: Select all
$hostlist = http://10.35.7.25/nagios/cgi-bin/objectjson.cgi?query=hostlist
for each $host in $hostlist {
$json = http://10.35.7.25/nagios/cgi-bin/objectjson.cgi?query=hostgrouplist&hostgroupmember=$host
if $json.data.hostgrouplist.size() < 1 {
print "$host has no hostgroup"
}
}
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Finding All hosts not in groups
@amprantino, did mcapra's solution work for you? Let us know if you have any more questions.
Be sure to check out our Knowledgebase for helpful articles and solutions!