List hosts that don't belong to any hostgroup.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Pres-Gas
Posts: 52
Joined: Thu Mar 22, 2012 12:09 pm

List hosts that don't belong to any hostgroup.

Post by Pres-Gas »

Hello,

We are in the process of moving our hosts (1300+) into various hostgroups. I am now at a point where I am trying to find the outliers/orphans; hosts still not in any group.

Is there an easy way to get this shown? I don't see anything immediate when looking.

I am running Nagios XI 5.2.3 on RHEL6 latest.

Thanks!
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: List hosts that don't belong to any hostgroup.

Post by gormank »

There are at least 2 ways to add a host to a hostgroup, add the hostgroup to the host, or add the host to the hostgroup. I do the latter, so it looks like it might be a pain w/o writing a script or oneliner to create a list. Or not :)

grep members /usr/local/nagios/etc/hostgroups.cfg | sed -e 's/members//g' | tr -d '[:blank:]' | tr , '\n' | sort -u

If you put the hostgroup in the host, grep hostgroup /usr/local/nagios/etc/hosts/*.cfg should print a list of host config files that represent the hosts in hostgroups.

Get a list of hosts: ls -1 /usr/local/nagios/etc/hosts/ | sed -e 's/\.cfg//g'

Redirect into files, diff and grep...
Pres-Gas
Posts: 52
Joined: Thu Mar 22, 2012 12:09 pm

Re: List hosts that don't belong to any hostgroup.

Post by Pres-Gas »

Yep, I figured it was going to turn out that way. I figured there would be a nice "shiny" report for management types too. Thanks and consider this resolved (unless someone *does* know of a special shiny report).

Robert
gormank wrote:There are at least 2 ways to add a host to a hostgroup, add the hostgroup to the host, or add the host to the hostgroup. I do the latter, so it looks like it might be a pain w/o writing a script or oneliner to create a list. Or not :)

grep members /usr/local/nagios/etc/hostgroups.cfg | sed -e s/members//g | tr -d '[:blank:]' | tr , "\n" | sort -u

If you put the hostgroup in the host, grep hostgroup /usr/local/nagios/etc/hosts/*.cfg should print a list of host config files that represent the hosts in hostgroups.

Get a list of hosts: ls -1 /usr/local/nagios/etc/hosts/ | sed -e s/\.cfg//g

Redirect into files, diff and grep...
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: List hosts that don't belong to any hostgroup.

Post by lmiltchev »

Pres-Gas, we don't have such a report included by default in XI, so gormank's suggestion would be a way to go. You are welcome to file a feature request on our public tracker here:

http://tracker.nagios.com

I am locking this topic now. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked