Nagios Object Inheritance

Nagios object inheritance can be a very confusing and/or tricky topic.  First you should read the official documenation on nagios object inheritance here.  Below is a very simple and straightforward example to illustrate a common application of inheritance you may want to use in your environment.

Your host/service definition entry uses a template...

use          app-server

The app-server template has two contact groups configured...

contactgroup_name          it,dev

Let's see what we can do in the host/service definition.  Here are some examples and how they should work.

contactgroup_name          +support

Using the "+" sign, the host/service definition uses the data in the template -and- adds the support group to the alerts.

contactgroup_name          !dev

Using the "!" sign, the host/service definition uses the data in the template -and- will remove the dev group from the alerts.  If dev was not specified in the template, this would have no effect.

contactgroup_name          support

Using no modifier will override the template values and only the support group will receive these alerts. 

contactgroup_name          +support,!dev

You can use combinations of modifiers to get the desired results as well.  Remember too if you use multiple templates you apply them in order.  The nagios official documentation have a very useful flow chart on this to help you understand.

Some may ask why not a line like below to add a contact group line like this to the host/service definition:

contactgroup_name          it,dev,finance

The negative to the above is when you want to add another contact group to ALL systems using the template, you then have to remember which systems have explicitly defined values.