Setting up HTTP agent monitoring using Zabbix

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.

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

1 × one =