Page 1 of 1

List hosts that don't belong to any hostgroup.

Posted: Tue Feb 09, 2016 2:52 pm
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!

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

Posted: Tue Feb 09, 2016 4:03 pm
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...

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

Posted: Wed Feb 10, 2016 10:21 am
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...

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

Posted: Wed Feb 10, 2016 11:17 am
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!