Web URL Monitoring Using Zabbix

Chris Bassey
6 min readSep 9, 2021

--

In this writeup, we explore web URL monitoring using Zabbix.

What is Zabbix?

Zabbix is open source and free to download and use monitoring tools with support for multiple operating systems platforms.

Features

It has the discovery feature where device resources such as the number of CPUs, file systems/drives, and network interfaces in a server or network device can be detected and data sources automatically created for them.

Infrastructure Requirements

For this write up we will use 2servers with the following details:

  • Webserver 1 with a heavy web page and a simple web page using WordPress — 10.1.1.61
  • Zabbix Server — 10.1.1.43

Prepping the web URLs

NB: you can find resources for installing WordPress on an ubuntu host here [https://www.cloudsigma.com/how-to-install-wordpress-with-lamp-on-ubuntu-20-04/].

On the webserver, we create 2 pages one with lots of images to make it heavy and another without any images to make its load time fast.

Deploying Zabbix

Zabbix is deployed on an Ubuntu 20.04 guest OS using the second server provisioned [10.1.1.43].

  • First, we install Zabbix-server. This installs all Zabbix server components and MySQL for Zabbix.
sudo apt install zabbix-server-mysql
  • Install Zabbix frontend for access to the user interface of Zabbix.
sudo apt install zabbix-frontend-ph
  • We install Zabbix apache configuration that will allow us to run the Zabbix server.
sudo apt install zabbix-apache-conf
  • Install the Zabbix agents so the Zabbix host and guest are monitored as well.
sudo apt install zabbix-agent
  • We proceed to create a Zabbix MySQL user, database and grant the user privileges.
mysql -u root -p
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'qwerty';
grant all privileges on zabbix.* to zabbix@localhost;
  • Now we import the dummy database schema for the Zabbix database
sudo zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
  • The Zabbix configuration file located at /etc/zabbix/zabbix.conf is modified to hold the Zabbix DB user and password.
  • Modify the Zabbix apache.conf file to point to the Zabbix document root and the error logs.
  • We run through prechecks, and specify the DB connection details then we proceed to complete the installation.
  • Now we can proceed to login to the Zabbix monitoring dashboard.
  • Below is the zabbix dashboard

Onboarding a Guest for Monitoring

To set up alerts, we would need to install the Zabbix agent on the guest being monitored. To install it the following steps were taken.

  • The Zabbix deb was pulled and added to the package manager.
wget \ https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.debsudo dpkg -i zabbix-release_5.0–1+focal_all.deb
sudo apt updatesudo apt install zabbix-agent
  • We check the status of the zabbix agent and it is installed.
zabbix_agentd -V
  • Modify the zabbix agent configuration file and add the zabbix server IP address and the client hostname
sudo nano /etc/zabbix/zabbix_agentd.confServer=10.1.1.43 #Zabbix serverHostname=ls4-web #my web server hostname
  • Restart the service and enable it for startup.
sudo systemctl restart zabbix-agentsudo systemctl enable zabbix-agent

To have the webserver show up under the hosts in the zabbix dashboard, we do the following:

  • Under Configuration > hosts, we create a new host. We fill in the hostname group and other details.
  • In the template, we ‘Link New templates‘ field with the Zabbix agent Linux template so we can get some premade monitoring templates and add.
  • The webserver guest adds to Zabbix and now we can see details of the host being sent by the agent.

Setting up Status Alerts against the web URLs

  • Select hosts, choose the host to be monitored that was previously added.
  • Select Web scenarios and proceed to create a scenario

For the simple page:

  • We create a web scenario holding the URL of the simple webpage in the step.
  • Then we add it.
  • After we add it, we click on the web scenario and we can see the response status for the web scenario. Its response time and speed.

Now we create a trigger to alert whenever the simple page is unreachable.

  • Select hosts, choose the host to be monitored that was previously added.
  • Select triggers and proceed to create a trigger
  • Fill in the parameters with the expression
{Chris:web.test.fail[Simple CMS Link].last()}>0

This means whenever the web URL test fails for more than 0 seconds an alert should be triggered.

NB: an expression constructor is also available to use in creating this.

I unpublish the simple page and can see the page go down and alert on the Zabbix dashboard.

For the heavy page:

The same steps used in creating the web scenario for the simple page is used for the heavy page.

Create a trigger to alert whenever the heavy page is unreachable.

The expression used in the trigger is

{Chris:web.test.fail[Heavy CMS].last()}>0

I unpublish the heavy page so it ends as a 404 error and I can see alerts as problems.

We have successfully configured web URL monitoring using Zabbix. It is possible to configure CPU, Disk and other resources usage monitoring as well.

These will be explored in other writeups.

--

--

Chris Bassey
Chris Bassey

Written by Chris Bassey

Cyber security engineer. Infrastructure, software and secured systems enthusiast. I know how to write code.

No responses yet