Book Image

Zabbix 5 IT Infrastructure Monitoring Cookbook

By : Nathan Liefting, Brian van Baekel
Book Image

Zabbix 5 IT Infrastructure Monitoring Cookbook

By: Nathan Liefting, Brian van Baekel

Overview of this book

Zabbix offers useful insights into your infrastructure performance and issues and enables you to enhance your monitoring setup with its variety of powerful features. This book covers hands-on, easy-to-follow recipes for using Zabbix 5 for effectively monitoring the performance of devices and applications over networks. The book starts by guiding you through the installation of Zabbix and using the Zabbix frontend. You'll then work your way through the most prominent features of Zabbix and make the right design choices for building a scalable and easily manageable environment. The book contains recipes for building items and triggers for different types of monitoring, building templates, and using Zabbix proxies. As you advance, you’ll learn how to use the Zabbix API for customization and manage your Zabbix server and database efficiently. Finally, you'll find quick solutions to the common and not-so-common problems that you may encounter in your everyday Zabbix monitoring work. By the end of this Zabbix book, you’ll have learned how to use Zabbix for all your monitoring needs and be able to build a solid Zabbix setup by leveraging its key functionalities.
Table of Contents (14 chapters)

Working with calculated and dependent items

Calculated and dependent items are used in Zabbix to produce additional values from existing values. Sometimes, we have already collected a value and we need to do more with the values created by that item. We can do exactly that by using calculated and dependent items.

Getting ready

To work with calculated items and dependent items, we are going to need the Zabbix server and monitored hosts from the previous recipes. We will add the items on the lar-book-agent_passive host and our Zabbix server host, so we already have some items available to calculate and make dependent.

How to do it…

Let's see how we can extend our items by getting started with the calculated items.

Working with calculated items

  1. Let's navigate to our host configuration by going to Configuration | Hosts and clicking on our lar-book-agent_passive host's items. In the filter field named Name, enter memory and you will get the following output:
    Figure 2.24 – Zabbix item page for host lar-book-agent_passive

    Figure 2.24 – Zabbix item page for host lar-book-agent_passive

  2. What we are going to do now is create a calculated item that is going to show us the average memory utilization over a period of 15 minutes. We can use this value to determine how busy our host was during that period, without having to look at the graphs.
  3. Let's click the Create item button and start creating our new calculated item.

    We want our item to have the following values:

    Figure 2.25 – Zabbix item configuration page, average memory used

    Figure 2.25 – Zabbix item configuration page, average memory used

  4. Now if we go to check our Monitoring | Hosts page and select Latest data, we can check out our value. Make sure to filter in the Name field for memory, so we see the correct values:
Figure 2.26 – Zabbix Latest data page for host lar-book-agent_passive, memory items

Figure 2.26 – Zabbix Latest data page for host lar-book-agent_passive, memory items

Now we can clearly see that we are calculating the 15-minute average of the memory utilization on our newly created item.

Working with dependent items

Time to make our first dependent item. I'll use the lar-book-agent_centos host or our (as it's called by default) Zabbix server. Let's say we want to request some variables from our MySQL database in one big batch. We can then create dependent items on top of the first item to further process the data:

  1. Let's start by creating the main check. Navigate to Configuration | Hosts, select our host, and then let's click the Create item button to start creating our first new item. We want an item with the following variables:
    Figure 2.27 – Zabbix item configuration page, database status

    Figure 2.27 – Zabbix item configuration page, database status

    Now, this item is an SSH check that logs in to our Zabbix server machine and executes the code in the script. The code will then log in to our MariaDB database and it will show the status. Make sure to enter your credentials correctly.

    Tip

    SSH checks can be used for a variety of cool scenarios, such as this one. We simply log in to our CLI and execute a piece of code. Perfect for your custom setups.

  2. Go to Monitoring | Hosts and check out the Latest data page for our new check. There should be a long list of MariaDB values. If so, we can continue with our next step of creating the dependent item.
  3. To create the dependent item, navigate to Configuration | Hosts, select our host, and let's click the Create item button. We want this item to get the following variables:
    Figure 2.28 – Zabbix item configuration page, MariaDB aborted clients

    Figure 2.28 – Zabbix item configuration page, MariaDB aborted clients

  4. It's very important to add preprocessing to this item as well, otherwise we will simply get the same data as our master item. So, let's add the following:
Figure 2.29 – Zabbix item preprocessing page, MariaDB aborted clients

Figure 2.29 – Zabbix item preprocessing page, MariaDB aborted clients

The result will be the number of aborted clients for our MariaDB:

Figure 2.30 – Zabbix Latest data page, MariaDB aborted clients

Figure 2.30 – Zabbix Latest data page, MariaDB aborted clients

How it works…

The types we've discussed in this How to do it… section can be quite complicated; let's go over how the items actually work.

Calculated items

Working with calculated items can be a great way to get even more statistics out of your existing data. Sometimes you just need to combine multiple items into one specific value.

What we did just now works by taking several values in a period of 15 minutes of 1 item and calculating the average like this:

Figure 2.31 – Zabbix dependent item diagram

Figure 2.31 – Zabbix dependent item diagram

We're taking those values and calculating the average every 15 minutes. It gives us a nice indication of what we are doing over a set period of time.

Dependent items

Dependent items work simply by taking the data from a master item and processing that data into other data. This way, we can structure our data and keep our check interval for all these items the same:

Figure 2.32 – Dependent item diagram

Figure 2.32 – Dependent item diagram

As seen here, dependent items basically work as duplicators, with additional preprocessing options. Do note that preprocessing must be used to extract data from the master item. Without preprocessing, our data will be exactly the same as the master item.

Tip

Sometimes we do not require our master item to be saved in our database; we already have the information in our dependent items. When we don't want the master item to be saved, we simply select the Do not keep history option.