Page 1 of 1

Notifications by hostgroup_name

Posted: Mon Jun 04, 2012 5:40 pm
by chrisjx
Nagios core 3. We are looking at various ways to narrow down the notifications we're receiving.

How do we add service notifications to services associated with a given host group without duplicating every service for that host group? We don't want to send notifications for every host group; for now, just one; later, a selected list.

It seems that to do what we want is to have the full compliment of services defined for every service for every group to which we want notifications. This would mean a huge jump in the number of service definitions with the associated problematic overlap and increased editing that might occur when adding/removing objects.

I suppose I want to find the method to add a service notification (or contact_groups) to a hostgroup_name definition. Another way of looking at it is that we don't want to know about all our hard disks, just the ones associated with a hostgroup_name (a group of hosts).


We have service groups that are simply hollow definitions:

Code: Select all

define servicegroup {
	servicegroup_name	HDPartition1
	alias			Hard Disk Partitions 1
}
We have host groups (defined via simple regex):

Code: Select all

define hostgroup{
        hostgroup_name  c_dev2          ; The name of the hostgroup
        alias           Devlopment II               ; Long name of the group
        members         \.dev2\.
        }
We have services that refer to the multiple host groups:

Code: Select all

define service{
		use generic-service 
		hostgroup_name hostgroup1, hostgroup2, c_dev2
		servicegroups HDPartition1
		service_description HD Partition 1 
		check_command check_nrpe!check_sda1
}
generic-service defines the contact_group, etc...


Thanks for any tips...

Re: Notifications by hostgroup_name

Posted: Mon Jun 04, 2012 8:08 pm
by jsmurphy
Unfortunately there's not really a way around configuring a separate service if you need to split up the contacts based on host group... you can however reduce the amount of required config to something much less administratively taxing using template's and inheritance overrides where appropriate.

You could set everything you need within a template and have two service definitions, one that contains hostgroups and a contact definition and one that contains hostgroups and no contact. Your service definitions would probably end up something like:

define service {
use generic-service
name sda1_template
service_description HD Partition 1
check_command check_nrpe!check_sda1
register 0
}

define service {
use sda1_template
hostgroup_name hostgroup1, hostgroup2
}

define service {
use sda1_template
hostgroup_name hostgroup3, hostgroup4
contact_groups !contactgroup1 #The ! symbol allows you to void an inherited object from a template
}

Sure it's slightly more administrative overhead but it's not a whole lot.