groups of hostgroups?

Paul M. Dubuc work at paul.dubuc.org
Fri Jun 25 23:11:03 CEST 2010


Litwin, Matthew wrote:
> It doesn't appear that there is a way to have a way to include hostgroups
> in other hostgroups, but is there some other way to get this behavior?
> Since my environment has several dozen types of servers in our environment,
> it would be helpful to define a "class" of host somehow rather than having
> servers be listed explicitly in multiple hostgroups. Any ideas?

I use templates to add hosts and services to groups.  If the definition
inherits from more than one template the 'hostgroups' or 'servicegroups'
specifier will replace whatever was specified previously unless you prefix
the group name with a plus sign (+).  Then it adds the group to whatever other 
groups are specified:

define hostgroup{

     hostgroup_name       HG_ALPHA
...
}


define host{

     name                        alpha-host

     register                    0   ; this is a template


     hostgroups               +HG_ALPHA
...
}

define hostgroup{

     hostgroup_name       HG_BETA
...
}

# # Nagios service definition template used by services in this config file
#
define host{

     name                        beta-host

     register                    0   ; this is a template


     use                         alpha-host

     hostgroups               +HG_BETA
}

Now any host that uses the beta-host template is put in both the HG_BETA 
hostgroup and the HG_ALPHA hostgroup.  This effectively puts the HG_BETA group
within the HG_ALPA group.

Hope this helps.

Same thing can be done with servicegroups of course.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list