Exclude hostgroup_members

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
jessegto
Posts: 2
Joined: Mon Jul 08, 2013 8:04 pm

Exclude hostgroup_members

Post by jessegto »

Hello everyone,
I am running Nagios Core 3.5 and it appears excluding hostgroup members within hostgroups is not allowed. Here is an example definition of what I am trying to do:

Code: Select all

define hostgroup{
        hostgroup_name          hg-test
        alias                   HG Test
        hostgroup_members       hg1,hg2,!hg3
        }
Whenever I verify the config, I will get this message:
Error: Could not find member group '!hg3' specified in hostgroup

I haven't seen a fix for this when looking through the changelogs, although I haven't tried 4.0 yet to verify.

Does anyone know if there is a patch I could use for Nagios? Is Nagios aware of this bug / missing feature?
Last edited by slansing on Tue Oct 01, 2013 10:20 am, edited 1 time in total.
Reason: Removed mentionings of 3rd party software
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Exclude hostgroup_members

Post by tmcdonald »

If you are trying to exclude a hostgroup, just don't include it in the list. The object definitions function best as whitelists instead of blacklists.

This page is the Nagios Core Object Definitions page and is quite handy for manually editing config files.
Former Nagios employee
DeanM
Posts: 17
Joined: Wed Sep 25, 2013 7:38 am

Re: Exclude hostgroup_members

Post by DeanM »

I have only needed to exclude if I have wild card (*) included in front of my selections.
jessegto
Posts: 2
Joined: Mon Jul 08, 2013 8:04 pm

Re: Exclude hostgroup_members

Post by jessegto »

There is a reason I need to exclude a third host group. The third host group members are also part of the first two host groups.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Exclude hostgroup_members

Post by scottwilkerson »

you can exclude hosts but not exclude hostgroups
http://nagios.sourceforge.net/docs/3_0/ ... ricks.html
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Wunsch
Posts: 2
Joined: Tue Oct 15, 2013 11:58 am

Re: Exclude hostgroup_members

Post by Wunsch »

If you look at the documentation you've linked, it explicitly says that what jessiegto is trying, should work. Unfortunately, it doesn't seem that it does; I'm running into the same issue. I haven't tested Nagios 4.0 yet either, but the documentation that says it should work is for 3.0 (I'm running 3.5.1).
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Exclude hostgroup_members

Post by abrist »

I think what Scott was implying is that you cannot use excludes on the hostgroup object definition, whereas you can on the host definitions.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Wunsch
Posts: 2
Joined: Tue Oct 15, 2013 11:58 am

Re: Exclude hostgroup_members

Post by Wunsch »

abrist wrote:I think what Scott was implying is that you cannot use excludes on the hostgroup object definition, whereas you can on the host definitions.
He might have been implying that, but the documentation he quoted says otherwise.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Exclude hostgroup_members

Post by abrist »

No where in the document does it mention that hostgroup object definitions can have "excludes" defined in them. You can exclude hostgroups from service/host object definitions, but not from hostgroup definitions. In fact, it only specifically mentions excludes on service object configs:
Excluding Hosts:
If you want to create identical services on numerous hosts or hostgroups, but would like to exclude some hosts from the definition, this can be accomplished by preceding the host or hostgroup with a ! symbol.


define service{

host_name HOST1,HOST2,!HOST3,!HOST4,...,HOSTN

hostgroup_name HOSTGROUP1,HOSTGROUP2,!HOSTGROUP3,!HOSTGROUP4,...,HOSTGROUPN

service_description SOMESERVICE

other service directives ...

}
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ChathamDaleJ
Posts: 55
Joined: Tue Jul 02, 2013 10:44 am

Re: Exclude hostgroup_members

Post by ChathamDaleJ »

Actually, the docs do mention excluding hostgrops.

Yes, it is core three, not nagios xi. When I try to use as a static config, xi chokes.

If this does not work, IT IS A BIG DEAL.

https://assets.nagios.com/downloads/nag ... ricks.html

I

Code: Select all

f you want to create identical services on numerous hosts or hostgroups, but would like to exclude some hosts from the definition, this can be accomplished by preceding the host or hostgroup with a ! symbol.

	define service{
		host_name             HOST1,HOST2,!HOST3,!HOST4,...,HOSTN
		hostgroup_name                HOSTGROUP1,HOSTGROUP2,!HOSTGROUP3,!HOSTGROUP4,...,HOSTGROUPN
		service_description   SOMESERVICE
		other service directives ...
		}
Locked