Additive inheritance and canceling inheritance issues

Ethan Galstad nagios at nagios.org
Fri Oct 19 00:47:48 CEST 2007


Shad L. Lords wrote:
> Following up on my previous message about additive inhereritance it appears 
> that it only applies to the first used instance.  Here is an example config 
> that fails.  There also appears to be an issue with canceling inheritance.
> 
> define host {
>         name                            default
>         check_command                   check_host_alive
>         max_check_attempts              3
>         check_period                    24x7
>         flap_detection_enabled          1
>         process_perf_data               0
>         retain_status_information       1
>         retain_nonstatus_information    1
>         notification_interval           30
>         notification_options            d,r,f
>         notifications_enabled           1
>         register                        0
>         }
> 
> define host {
>         name            A6
>         hostgroups      +rhg_A6
>         parents         SW-CAB_A6
>         register        0
>         }
> 
> define host {
>         name                    24x7
>         notification_period     24x7
>         register                0
>         }
> 
> define host {
>         name            sec
>         hostgroups      +nhg_sec
>         contact_groups  +cg_sec1
>         register        0
>         }
> 
> define host {
>         use             default,A6,24x7,sec
>         host_name       dwsoms1
>         alias           OMS 1
>         address         theip
>         parents         null
> }
> 
> What I'd like to have the end resulting object be is:
> 
> hostgroups rhg_A6, nhg_sec
> contact_groups cg_sec1
> notification_period 24x7
> no parents defined
> 
> I end up with an object that has:
> 
> hostgroups rhg_A6
> contact_groups cg_sec1
> notification_period 24x7
> parents SW-CAB_A6
> 
> If I add a "hostgroups +nhg_sec" line to the last host then it doesn't add 
> nhg_sec to the hostgroups instead it replaces it and I end up with only 
> nhg_sec.  However if I change the "use default,A6,24x7,sec" to "use 
> A6,default,24x7,sec" then I do get both hostgroups listed.
> 
> Hope this helps track down some potential issues,
> 
> -Shad 
> 

The inheritance cancellation bug you found will be fixed in CVS shortly. 
  Thanks for pointing that out.

The additive inheritance is not working as you expected because I didn't 
design it to work that way.  Right now additive inheritance only works 
when you inherit/add values at each level of template resolution.  For 
example:

define host{
	name		template1
	hostgroups	hg1
	register	0
	}

define host{
	name		template2
	use		template1
	hostgroups	+hg2
	register	0
	}

define host{
	name		template3
	use		template2
	hostgroups	+hg3
	register	0
	}

define host{
	name		realhost
	use		template3
	}

Here are the resolved values for the "hostgroups" directives in each 
host/template definition:

template1:	hg1
template2:	hg1,hg2
template3:	hg1,hg2,hg3
realhost:	hg1,hg2,hg3

The example config entries you provided offer another way to use 
additive inheritance which would definitely be useful.  I'll work on 
getting a patch into CVS in the next day or two to make that work.

Thanks for the feedback and suggestions.


Ethan Galstad,
Nagios Developer
---
Email: nagios at nagios.org
Website: http://www.nagios.org

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/




More information about the Developers mailing list