Using multiple templates

There are two monitored hosts now. They both have some services monitored and linked to the same template. Suddenly, the situation changes: one of the hosts gets a new function and the email server is removed. Our options from the Zabbix viewpoint include simply disabling email-related items for that host, or creating a separate template for it and removing email-server-related entities from the main template, instead leaving them on the other server. There's a better approach, though: splitting email-server-related entities into a separate template.

Navigate to Configuration | Templates, then click on the Create template button. Enter C_Template_Email in the Template name field, select Custom templates in the Groups box if it's not already selected, then click on Add:

Now, let's populate this template:

  1. Select Custom templates in the Group drop-down and click on Items next to C_Template_Linux
  2. Mark the checkboxes next to SMTP server status and Testfile in the Name column, then click on the Copy button at the bottom
  3. In the next screen, select Templates in the Target type drop-down, and Custom templates in the Group drop-down
  4. Mark the checkbox next to C_Template_Email, then click on Copy

That deals with the items—now let's take care of the triggers:

  1. Click on Triggers in the navigation bar above the Items list
  2. Mark the checkboxes next to SMTP service is down and Testfile is missing in the Name column. Then click on the Copy button
  3. In the next screen, select Templates in the Target type drop-down, Custom templates in the Group drop-down and mark the checkbox next to C_Template_Email, then click on Copy
We also have to pull in our test file item and trigger, as the SMTP trigger depends on the test file trigger. We could not copy the SMTP trigger, as that would leave an unsatisfied dependency.

We now have a simple dedicated email server template that we can link to the hosts. It has the same item and trigger regarding the SMTP service as our custom Linux template. There's a problem though—as they both have an item with the same key, we cannot link these templates to the same host; it would fail. Attempting to do so would probably result in a message such as this:

We will perform some steps to change the template linkage:

  • Unlink C_Template_Linux from A test host and Another host
  • Remove SMTP related items and triggers from C_Template_Linux
  • Link C_Template_Email to them both
  • Link C_Template_Linux back to both hosts

This way, SMTP-related items and triggers will become templated from the email template, while preserving all collected data. If we deleted those items from the Linux template and then linked in the email template, we would also remove all collected values for those items.

Go to Configuration | Hosts, mark the checkboxes next to A test host and Another host, then click on Mass update. Switch to the Templates tab and mark the Link templates checkbox and the Replace checkbox. This will unlink the linked templates, but keep the previously templated entities as directly-attached ones:

We will discuss host mass update in more detail later in the chapter in the Using mass update section.

Click on Update. Now we will modify the Linux template to remove SMTP related items and triggers.

Navigate to Configuration | Templates, click on Items for C_Template_Linux, and mark the checkboxes next to SMTP server status and Testfile exists in the Name column. At the bottom, click on the Delete button and confirm the popup. If you expand the details, you will see that the triggers that were depending on these items got deleted, too—we did not have to delete them manually:

Now we are ready to link in our new email template, and link back the modified Linux template. We can even do that in one step and we will again use the mass update function to do that. Go to Configuration | Hosts, mark the checkboxes next to A test host and Another host, then click on Mass update. Switch to the Templates tab, mark the Link templates checkbox, and type C_ in the input field. Both of our templates will show up; click on one of them, then type C_ again, and click on the other template:

Click on the Update button. Take a look at the template-linkage list in Configuration | Templates after this operation. Each of the custom templates now has two hosts linked:

A single host can be linked against multiple templates. This allows for a modular configuration where each template only provides a subset of entities, thus a server can be configured to have any combination of basic Linux, email server, web server, file server, and any other templates.

Of course, with a single item and trigger, this process seems too complex, but usually the email server would have more parameters, such as mail-server process counts, SMTP, IMAP, POP3 service status, spam and virus filter status, and queue length. At that point, the ability to quickly make a collection of metrics monitored on a machine with a couple of clicks is more than welcome.

The method of unlinking, redesigning, and linking back is a common and suggested approach to changing template configurations. Just be careful not to change item keys while templates are unlinked, or to delete items while they are linked.
..................Content has been hidden....................

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