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)

Setting up HTTP agent monitoring

With the Zabbix HTTP agent, we can monitor a web page or API by retrieving data from it. For instance, if there's a counter on a web page and we want to keep an eye on that counter value, we can do so with Zabbix HTTP monitor.

Getting ready

We are going to need a web page to monitor and we will need our Zabbix server. For your convenience, we've added a page to our own website to retrieve a value from. Here's the page: https://oicts.com/book-page/.

Please also note that your Zabbix server will need an active internet connection for this recipe.

How to do it…

Let's poll this special web page we've created for you for the visitor count that's currently configured on it. This is a real counter for the number of times (unique) visitors have opened the URL:

  1. Navigate to your Zabbix frontend and navigate to Configuration | Hosts, then click the host called lar-book-agent_simple. Now go to Items; we want to create a new item here by clicking the Create item button. Now we are going to need to create an HTTP agent item as shown in the following screenshot:
    Figure 2.44 – Zabbix Item configuration page, visitor count on oicts.com page

    Figure 2.44 – Zabbix Item configuration page, visitor count on oicts.com page

    Use the following preprocessing steps:

    Figure 2.45 – Zabbix Item preprocessing page

    Figure 2.45 – Zabbix Item preprocessing page

  2. Now navigate to Monitoring | Hosts and open the Latest data page for our lar-book-agent_simple host. If everything is working as it should, we should now be requesting this page's visitor count every 15 minutes as follows:
Figure 2.46 – Zabbix Latest data page

Figure 2.46 – Zabbix Latest data page

How it works…

What we do here is request the complete web page from Zabbix by navigating to the page with the HTTP agent and downloading it. When we have the complete content of the page, in this case, an HTML/PHP page, we can process the data:

Figure 2.47 – Diagram showing Zabbix HTTP agent communication

Figure 2.47 – Diagram showing Zabbix HTTP agent communication

We ask our preprocessor via a regex to go through the requested code and only show the number behind where it says Total Page Visits:.

All that's left is the number, ready for us to use in graphs and other types of data visualization.