Page 1 of 1

Assign Contact Group to Host Groups using Host Template

Posted: Wed Oct 02, 2013 2:48 pm
by DonB
I recently did the following post http://support.nagios.com/forum/viewtop ... =6&t=21459

I created a Host Group called hg_test and added a host to that group.
I created contacts and added them to a contact group called cg_test
I created a Host Template and added both hg_test and cg_test to the template.
When I run the custom notification from the host, I do not recieve any notifications. It appears that the host doesn't inherit the host template from the hg_test host group.
I then wanted to test and verify notifications can work by using a template to apply the contact settings, I added the host template to the host and the custom notification will work. I also have group option "standard" set at the host and contact group level on both the template and host.

Is there any additional settings that I need to make so that a host device will inherit the host template that is assign to a host group and will inherit the contact information? I did try using the hostgroup & contactgroup options (+, null, standard). But I'm not sure which settings and where to apply them. Which options should be set at the template level for both host groups and contact group vs at the host level.

Thank you,
Don

Re: Assign Contact Group to Host Groups using Host Template

Posted: Wed Oct 02, 2013 3:39 pm
by tmcdonald
The first issue I see is that you "added both hg_test and cg_test to the template." Hosts/services/groups are not added to templates, they use them. So you need to include the "use" parameter in your hostgroup configs.

http://nagios.sourceforge.net/docs/3_0/ ... tance.html

Second, make sure you include "register 0" to your templates.

Third, it's a good idea not to use a generic template for both contact groups and host groups. You had mentioned using one for both hg_test and cg_test.

Can you post your configs/templates for reference?

Re: Assign Contact Group to Host Groups using Host Template

Posted: Thu Oct 03, 2013 2:45 pm
by DonB
See below the configuration for each object.

I reviewed the object inheritance and object definitions docs and I'm thinking the configuration I'm attempting might not be possable. My goal is to have a host group that when I make a host a member of, it would inhert a host template, being provided by the hostgroup config. The template would provide the contact group(s) for the host to use. Then when we create a new host, I just make it a member of the host group and it would inherit all of the host template settings. But I'm thinking the only time a host inherts a host template, is when the "use" parameter is configured under the host config. It appears that a hostgroup doesn't have the object parameter(s) needed to assign a host template to it's members.

Thank you,
Don

Code: Select all

define host {
	host_name			test1
	alias				test1.richmond.edu
	display_name			test1
	address				141.0.0.11
	hostgroups			contact_don_email
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	check_period			24x7
	notification_interval		60
	notification_period		24x7
	notifications_enabled		1
	icon_image			windowsxp.png
	statusmap_image			windowsxp.png
	register			1
	}


define contact {
	contact_name                  		don_email
	alias                         		Email Only
	host_notifications_enabled    		1
	service_notifications_enabled 		1
	host_notification_period      		24x7
	service_notification_period   		24x7
	host_notification_options     		d,u,r,f,s,
	service_notification_options  		w,u,c,r,f,s,
	host_notification_commands    		notify-host-by-email
	service_notification_commands 		notify-service-by-email
	email                         		[email protected]
	use                           		generic-contact
	}	


define contactgroup {
	contactgroup_name             		cg_don_email
	alias                         		Email Only 24x7
	members                       		don_email
	}	

define hostgroup {
	hostgroup_name                		contact_don_email
	alias                         		Contact - Email Notifications Only
	}	


[b]# HOST TEMPLATE[/b]
define host {
       name                          		notification_don_email
       alias                         		Don's Email Only
       hostgroups                    		contact_don_email
       use                           		notification_don_email
       contact_groups                		cg_don_email
       notification_interval         		60
       notification_period           		24x7
       notification_options          		d,u,r,f,s,
       notifications_enabled         		1
       register                    		0

}

Re: Assign Contact Group to Host Groups using Host Template

Posted: Fri Oct 04, 2013 9:56 am
by lmiltchev
My goal is to have a host group that when I make a host a member of, it would inhert a host template, being provided by the hostgroup config.
I don't believe this can be defined in the hostgroup definition - please, see the documentation:

http://nagios.sourceforge.net/docs/3_0/ ... #hostgroup

Re: Assign Contact Group to Host Groups using Host Template

Posted: Fri Oct 04, 2013 10:12 am
by DonB
Yes, I agree that the hostgroup doesn't appear to have the "use" parameter or one that can apply a host template to a host. What got me a little confused, if you look at the object definitions document and review the host definitions, it does not have the "use" parameter, as well. The document actually needs to be updated. The only reference I found for the "use" parameter was in the Object Inheritance doc. So I thought there might possible be more parameters that were not listed for the hostgroup object.

Missing "use" parameter for hosts objects:
http://nagios.sourceforge.net/docs/3_0/ ... .html#host

The only reference for the "use" parameter and the examples are with the host object.
http://nagios.sourceforge.net/docs/3_0/ ... tance.html

Thank you,
Don

Re: Assign Contact Group to Host Groups using Host Template

Posted: Fri Oct 04, 2013 10:23 am
by tmcdonald
I've been meaning to take a look at some of the documentation. Being the new guy I can't just go in and make changes, but I'll certainly look into it.

Re: Assign Contact Group to Host Groups using Host Template

Posted: Thu Oct 10, 2013 3:08 pm
by DonB
Thank you for your help.
Don

Re: Assign Contact Group to Host Groups using Host Template

Posted: Thu Oct 10, 2013 3:19 pm
by tmcdonald
So was your problem solved? If so, I'd like to lock this thread to keep the forums clean.

Re: Assign Contact Group to Host Groups using Host Template

Posted: Tue Oct 15, 2013 8:49 am
by DonB
Yes, you can lock this thread. Thank you again for everyones assistance.
db