Template Introduction

Template Introduction

Templates are very powerful when used for the right purposes.

A good example is how the XI Configuration Wizards use templates for the host objects. The host object template has a standard ICMP up/down check. This means if you ever wanted to change the thresholds, you could change the template and then all hosts using that template will get the updated check.

You can use multiple templates in a layering fashion. As Nagios core reads the object definition, it looks at the first template and obtains the settings. It then looks at the next template and layers those settings over the top of the previous settings. This continues and builds the final object. In the Nagios XI GUI, with multiple templates, the template at the bottom of the list will be overwritten by a template above it. Object directives can be set to inherit that setting from a template, or ignore it. Other settings can be additive, like hosts, host groups, contacts, contact groups.

For example you might have a master template that defines the base settings all services should use. However, you have a bunch of service checks that require a specific time period. Create a separate template that uses this time period and put that template at the top of the chain. The final service object that is created will use the specific time period.

You can even create an empty template that uses a combination of other templates, this way you can use the master templates across all your objects and easily add / remove other templates to the master template, in turn reducing your administrative overhead. Be careful not to add more administrative overhead though.

More Information

Managing Host Templates

Managing Services Templates

Managing Contact Templates

Using the CCM for Host Management

Using the CCM for Services Management

Article ID: 908
Created On: Mon, Jun 28, 2021 at 2:45 PM
Last Updated On: Mon, Jun 28, 2021 at 4:48 PM
Authored by: rspielman

Online URL: https://support.nagios.com/kb/article/template-introduction-908.html