Chapter 8. Simplifying Complex Configurations with Templates

Our current setup has two hosts with similar enough environments, so we copied items from one over to another. But what do we do when there are a lot of hosts with similar parameters to monitor? Copying items manually is quite tedious. It's even worse when something has to be changed for all the hosts, such as an item interval or a process name. Luckily, Zabbix provides a means to configure these things in a unified fashion with the templating system.

Identifying template candidates

Templates allow a Zabbix administrator to reduce their workload and streamline the configuration. But to deploy the templates properly we have to first identify use cases that require or benefit from them. Or, to put it short—we have to identify what templates in Zabbix actually are.

When we created the second monitored Linux host, we manually copied items from the first host. If we wish, we can also copy over triggers. Such copying around isn't the best job ever, so instead we can create items and triggers for a template, which are then linked to the host in question. As a result of the linkage, the host immediately gets all the items and triggers defined in the template. Later, when we want to change some item parameters for all the hosts, we only have to do it once. Changes made to the template propagate to the linked hosts. So templates make the most sense for items and triggers that you want to have on multiple hosts, such as those Linux machines. Even if you have only a single device of a certain class, it might be worth creating a template for it in case new devices appear that could benefit from the same configuration.

For example, if we had Apache httpd and MySQL running on a host, we could split all items and triggers that are relevant for each of these services in to separate templates:

Identifying template candidates

Modifying an item in the MySQL template would propagate those changes downstream in the Host. Adding more hosts would be simple—we would just link them to the appropriate templates. Making a change in the template would apply that change to all the downstream hosts.

While the snmptraps host we created seems like a good candidate for directly created objects, we could have a situation where SNMP agents send in traps that are properly distributed between configured hosts in Zabbix, but every now and then a device would send in a trap that wouldn't have a host or corresponding SNMP item configured. If we still wanted traps like that to get sorted in corresponding items in our generic trap host, we would again use templates to create such items for corresponding hosts and our generic host.

Templates are a valuable tool in Zabbix configuration. That all sounds a bit dry, though, so let's set up some actual templates.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.112.79