How to Configure Zabbix Monitoring System

How to Configure Zabbix Monitoring System

Zabbix is an open-source enterprise level monitoring system. At the moment Zabbix is one of the most popular and functional free monitoring systems, with its easy installation and configuration. Zabbix server can be used for monitoring large infrastructures with hundreds of servers, as well as for small environment. In this article we will cover how to install and configure free monitoring system Zabbix with Linux Ubuntu based web interface. Install Zabbix agents on Windows and Linux server, and add new hosts to the system for monitoring.

Contents

  • Zabbix structure and functionality
  • Installing Zabbix server on Linux
  • Configuring Zabbix web interface
  • Installing Zabbix agent on Windows
  • Adding a device on a Zabbix server
  • Installing Zabbix agent on Linux

Zabbix Structure and Functionality

Zabbix is rather simple to install and configure. It is written in C++ (server, proxy and agent) and PHP (frontend). Zabbix server and Zabbix proxy can only run on Linux systems. The agent can be installed on many supported operating systems and platforms.

The Zabbix server installation package consists of:

  • Zabbix server binary
  • MySQL (MariaDB)/PostgreSQL databases
  • Apache2/Nginx web server with PHP frontend
  • Frontend files – .php, .js, .css, etc…

The scheme of work looks like this:

  1. The Zabbix agent sends data to the server
  2. The Zabbix server receives and processes the data
  3. If the received data is subject to the specified conditions, a trigger is triggered
  4. An active trigger signals a problem. A notification is displayed on the frontend, the notification emails is sent and needed actions are automatically performed. This depends on the configuration, for example Zabbix agent can restart the service that is being monitored.

Zabbix can work with all known protocols, thanks to a system of external scripts.

Installing Zabbix Server on Linux

In this article we will take a look at an example installation of Zabbix Server on Linux (using Ubuntu Server) through a batch manager.

Go to the download page https://www.zabbix.com/download and select the repository corresponding to your Linux distribution. Ready-made packages are available for all popular distributions.

For example, to install Zabbix 5 on Ubuntu 18.04 you have to select :

Zabbix Version 5 ⇒ OS Distribution (Ubuntu) ⇒ OS Version (18.04 Bionic) ⇒ Database (MySQL) ⇒ Web Server (Nginx or Apache).

Download and add a repository:

wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+bionic_all.deb
dpkg -i zabbix-release_5.0-1+bionic_all.deb
apt update

Now you can install the necessary packages:

apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-agent

Create a database and give the rights to the service account under whom Zabbix will access the database:

mysql -uroot
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'Your Password';
mysql> quit;

Import the Zabbix database. You will need to enter the password that you specified for the zabbix@localhost user.

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p Zabbix

Edit the configuration file /etc/zabbix/zabbix_server.conf, specify the password from the newly created user.

DBPassword=users password

Since in this example the web server is nginx, you need to change nginx.conf by removing “#” from the following lines:


listen 80;

server_name example.com;

Also change “example.com” to the domain name you want to log in to Zabbix web console, in this example it’s “test.zabbix.local“.

Now let’s set the time zone in PHP. In the /etc/zabbix/php-fpm.conf file lets remove “#” from the following line:

php_value[date.timezone] = Europe/Moscow

Additionally, you can set the following PHP settings in /etc/php.ini:

  • memory_limit 128M
  • upload_max_filesize 8M
  • post_max_size 16M
  • max_execution_time 300
  • max_input_time 300
  • max_input_vars 10000

Add the zabbix-server service to autostart and run it:

systemctl enable zabbix-server zabbix-agent nginx php7.2-fpm
systemctl restart zabbix-server zabbix-agent nginx php7.2-fpm

Configuring Zabbix Web Interface

Now you need to configure the frontend (web interface) of Zabbix. Open the previously specified URL of Zabbix server in your browser. In our example it is test.zabbix.local. Do not forget to register it on your DNS server.

Make sure that all installer requirements are OK.

Enter the data to connect to the database. Use the user and password you created earlier.

Enter the name of the Zabbix server. I recommend not to change the standard port – TCP 10051.

Note. The default Zabbix system uses two ports:

  • TCP 10050 is a passive agent port, on which the zabbix server polls clients;
  • TCP 10051 – the port on which zabbix server receives data from clients (active agent).

After that press Next Step and Finish. After successful installation, you will need to log in. Use “Admin” as login and “zabbix” as password, these are the default credentials.

This concludes the installation of the Zabbix Server.

Installing Zabbix Agent on Windows Server

Let’s try to install Zabbix agent on a Windows server and add it to our Zabbix monitoring. Download Zabbix agent for Windows here: https://www.zabbix.com/download_agents.

Select the desired version of the agent for Windows. For this example we will choose the “.msi x64” format (without OpenSSL). If you plan to install zabbix agent on servers/computers via Group Policy or SCCM, you can download the zip archive with binary and configuration files.

Start the installer, accept the license agreement, specify the requested data. Note that in the “Server or Proxy for active checks” field I entered the IP address in “IP:PORT” format. Since I left the port as standard, it will be serverip:10051.

Then click Next and Install.

Now we need to make sure that our agent is installed. The Zabbix agent service should appear in the services.msc list.

On the Windows client Firewall, you need to allow incoming connections from the Zabbix server:

New-NetFirewallRule -DisplayName "Zabbix" -RemoteAddress "ZabbixserverIP" -Direction Inbound -Protocol TCP -LocalPort 10050 -Action Allow

To make sure that the agent is working, you need to add our host to the Zabbix server and assign it checks.

Note. There are two types of checks in the Zabbix:
Passive – the Zabbix server asks for some data from the agent;
Active – the agent sends data to the server;

While installing the agent, we specified a server in IP:PORT format just for active checks.

Adding Device on a Zabbix Server

So We’ve installed the agent, now we need to add it on the monitoring platform via web-interface. Go to Configuration Hosts ⇒ Click Create host and fill in the data. Note that the host’s name must match the host name of the server with the agent or the value of the Hostname parameter in the agent config.

On the Templates tab, add some built-in Windows templates. Templates in Zabbix are sets of values, triggers, graphs and detection rules that can be assigned to one or more hosts.

These integrated templates have “active” in the end, which means that active checks will be used.

Click Add. To avoid waiting for the server and agent to connect with each other (usually takes a couple of minutes), restart the Zabbix Agent service on monitored host and check the agent’s log (C:\Program Files\Zabbix Agent\zabbix_agentd.txt).

The message “started [active checks #1]” indicates that active checks for this host have been found on the server. Now let’s look at the data that came to the Zabbix server from the agent. To do this in Zabbix, go to MonitoringLatest Data and select the desired host in the Hosts field.

This section shows the latest data that came to the server by selected hosts or groups of hosts. Note that there is a notification on the Zabbix dashboard that the BITS service is not running. This notification appears because we have assigned standard templates to our host. One of the templates was monitoring the BITS service and the corresponding trigger, which is triggered if the BITS service is not in status Running.

This concludes the configuration of the Windows Agent.

Installing the Zabbix Agent on Linux

Now let’s install the Zabbix agent on Linux. To install the Zabbix agent in Ubuntu Server using the package manager you need to download and install the Zabbix repository. Then we will install the zabbix agent from the repository:

wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+bionic_all.deb
dpkg -i zabbix-release_5.0-1+bionic_all.deb
apt update
apt install zabbix-agent

Before we run the zabbix agent, we need to edit the /etc/zabbix/zabbix_agentd.conf configuration file. In this file you need to specify the IP address of the Zabbix server for active checks:

Server=ServerIP
ServerActive=IP:10051
Hostname=testagent

After that we need to start the agent service:

service zabbix-agent start

Make sure the agent is successfully launched.

cat /var/log/zabbix/zabbix_agentd.log

Cannot parse list of active checks” string indicates that there are no active checks for this host on the server.

Similar to the Windows agent, you need to add your Linux host to the Zabbix server settings. Note the Hostname parameter in the host configuration in the server’s Zabbix interface must match the Hostname parameter that we specify in the Zabbix config.

Reboot the Zabbix agent and check the log.

Check that the agent data has appeared on the Zabbix server.

This completes the configuration of the Zabbix agent on your Linux system.