Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Zabbix 5 IT Infrastructure Monitoring Cookbook

You're reading from   Zabbix 5 IT Infrastructure Monitoring Cookbook Explore the new features of Zabbix 5 for designing, building, and maintaining your Zabbix setup

Arrow left icon
Product type Paperback
Published in Feb 2021
Publisher Packt
ISBN-13 9781800202238
Length 428 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Brian van Baekel Brian van Baekel
Author Profile Icon Brian van Baekel
Brian van Baekel
Nathan Liefting Nathan Liefting
Author Profile Icon Nathan Liefting
Nathan Liefting
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Chapter 1: Getting Started with Zabbix and User Management 2. Chapter 2: Setting Up Zabbix Monitoring FREE CHAPTER 3. Chapter 3: Working with Triggers and Alerts 4. Chapter 4: Building Your Own Structured Templates 5. Chapter 5: Visualizing Data, Inventory, and Reporting 6. Chapter 6: Using Discovery for Automatic Creation 7. Chapter 7: Setting Up Zabbix Proxies 8. Chapter 8: Integrating Zabbix with External Services 9. Chapter 9: Extending Zabbix Functionality with Custom Scripts and the Zabbix API 10. Chapter 10: Maintaining Your Zabbix Setup 11. Chapter 11: Advanced Zabbix Database Management 12. Chapter 12: Bringing Zabbix to the Cloud with Zabbix Cloud Integration 13. Other Books You May Enjoy

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.

You have been reading a chapter from
Zabbix 5 IT Infrastructure Monitoring Cookbook
Published in: Feb 2021
Publisher: Packt
ISBN-13: 9781800202238
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image