Templates

Writing a full object definition for every single service in your infrastructure can be a tiresome and error-prone process. Therefore, Nagios supports the use of templates. A template is a partial definition for a type of object. For example, you may have a host template defined for all your switches. By using this template, you can easily change the overall monitoring behavior of a switch by changing the template instead of each object definition for all switches. The switch object definition “pulls” in the parameters defined in the template it uses. It has the option, however, to override any parameters.

A template can also pull in parameters from another template. It is because of this fact that properly designing your template hierarchy is the best way to decrease the effort needed to maintain your Nagios configuration files. We’ll use simple templates for the following sample configuration.

Sample Configuration

After looking at all the configuration files that are involved with Nagios, it’s best that we put it all into context. Let’s describe a fictional company, Widgets Incorporated. The company has grown over the years and has gained a decent sized IT infrastructure. Being the company’s network administrator, we want to monitor our company’s network and have the individuals in our IT staff be notified of any failures of systems they are responsible for. Let’s take a look at our network topology.

Network topology for Widgets Incorporated

Get Network Monitoring with Nagios now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.