19 Mar 2022
Zabbix is an extremely powerful enterprise-class open source and free of cost distributed monitoring solution capable of monitoring a network and the health and integrity of servers, virtual machines, applications, services, databases, websites, the cloud and more.
Zabbix natively, fully supports VMware and IoT devices with MQTT and Modbus. Able to integrate with Active Directory or OpenLDAP with SAML support for modern authentication.
Zabbix can remediate problems with trigger-able commands, scripts (JavaScript based) and actions, perform testing such as web scenarios and report upon the results.
Zabbix can be highly available and capable of distributed monitoring with use of Proxies.
Zabbix can automatically add devices, create items, triggers and graphs using Low-level discovery (LLD), Zabbix also gathers trend data each hour.
The benefit of open-source is a huge community that is actively working together, this is shown with Zabbix Share where community templates are hosted and can be easily added to your own environment. Another benefit is that open-source projects tend to play nicely with other great projects, such as Grafana.
For smooth installation, check what operating system versions are supported by Zabbix before hand.
The available choices are MySQL or PostgreSQL.
Advantages of MySQL:
Advantages of PostgreSQL:
The choices are Apache or NGINX.
Apache:
NGINX:
I will be using a Debian container with Zabbix 6.0 LTS, I have selected to use MySQL (MariaDB) due to my environment being small, its ease of use and better use of system resources. I have also chosen NGINX due to its performance over Apache, and I have no requirement for additional configurations.
My environment will only be small with no requirement for proxies. Below are suggestions from the Zabbix documentation.
Name | CPU/Memory | Database | Monitored hosts |
---|---|---|---|
Small | Virtual Appliance | MySQL InnoDB | 100 |
Medium | 2 CPU cores/2GB | MySQL InnoDB | 500 |
Large | 4 CPU cores/8GB | RAID10 MySQL InnoDB or PostgreSQL | >1000 |
Very large | 8 CPU cores/16GB | Fast RAID10 MySQL InnoDB or PostgreSQL | >10000 |
Parameter | Formula for required disk space (in bytes) |
---|---|
Zabbix configuration | Fixed size. Normally 10MB or less. |
History | days x (items/refresh rate) x 24 x 3600 x bytes |
Trends | days x (items/3600) x 24 x 3600 x bytes |
Events | days x events x 24 x 3600 x bytes |
The total required disk space can be calculated as: Configuration + History + Trends + Events
I will be creating a container with the following spec:
Zabbix requires InnoDB engine, which is default in MySQL and “recommends using the MariaDB Connector/C library for building server/proxy.” - MariaDB Connector/C is used to connect applications developed in C/C++ to MariaDB and MySQL databases.
It is also very important to have correct system time on the Zabbix server, so NTP is recommended.
I have placed step-by-step screenshots of the container creation below.
Provide a name, un-check nesting as we will not require it and provide a password for the root account.
EDIT: Enable nesting for Debian containers otherwise there will be a delay after console/shell/SSH login.
Select the Debian 11 container template.
Configure a 30 GB disk, I have placed this on my ZFS Solid State Disks (SSD).
Configured the container to have 2 CPU cores.
Configured the container to have 2048 MB of RAM (2 GB)
Set a static IP address for this container as its a server and should have a fixed address.
All my containers use the Proxmox configured DNS server.
After creation, ensure the “Start at boot” option is enabled.
LXC use root when we login, therefore there is no requirement to prefix sudo
.
Always start by ensuring that the repositories and packages are up to date by using the below command.
apt update && apt upgrade -y
Check the installed locales
locale -a
Add the “en_US.utf8” locale, if missing. Edit the locale.gen file
nano /etc/locale.gen
Uncomment the following, then save and exit.
en_US.UTF-8 UTF-8
Generate the new locale by using the following command
locale-gen
Install the Zabbix repository
wget https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-1+debian11_all.deb
dpkg -i zabbix-release_6.0-1+debian11_all.deb
apt update
Clean up
rm zabbix-release_6.0-1+debian11_all.deb
Install mySQL server
apt install -y default-mysql-server
run the Secure Installation tool
mysql_secure_installation
Install Zabbix server, front-end and agent
apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
Create initial database
Log into MySQL (MariaDB)
mysql -u root -p
Create a database and user, granting all permissions on that database to the user.
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'AwCSze9v7Fitsztq';
grant all privileges on zabbix.* to zabbix@localhost;
quit;
Import the Zabbix schema and initial data
zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -u zabbix -p zabbix
Provide the password for the zabbix SQL user, which in this demonstration is AwCSze9v7Fitsztq
.
Configure the zabbix server conf with our SQL DB password. Start by editing the zabbix_server.conf
.
nano /etc/zabbix/zabbix_server.conf
then add the DB password, as shown in the example below.
DBPassword=AwCSze9v7Fitsztq
Configure the Nginx server, this can be done via the nginx.conf
file in the Zabbix directory.
nano /etc/zabbix/nginx.conf
Uncomment both the listen
and server_name
and change the server name
listen 80;
server_name example.com;
To add multiple server names, use a space as a delimiter and close with a semi-colon.
server_name 192.168.1.10 zabbix.domain.com monitoring.yourdomain.com;
Restart the Zabbix services and enable services to start on boot
systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm
systemctl enable zabbix-server zabbix-agent nginx php7.4-fpm
Restart the server, this is to apply any updates and locale changes.
reboot
Visit the Zabbix front-end
http://192.168.1.10/
The next few steps are the welcome wizard.
The first is to set the default language, as “en_GB” is not supported my only option is “en_US”.
The pre-requisites check should show “OK” for all components and options, if this does not then pause, resolve the issue then continue.
On the configure DB connection page, enter the SQL user password then continue.
The last page is to set a server name, default time zone and theme. I have configured my server name as “Zabbix”, the timezone to London and changed from the default “Blue” theme to “Dark”.
Default login credentials
At this point the container is using on average; 1% CPU, 212 MB RAM and 619 MB Storage.
If you see issues regarding ‘Locale for language “en_US” is not found on the web server’.
Open a shell or SSH connect to your Zabbix server, then list installed locales using the command below
locale -a
If “en_US.utf8” is not listed then we’ll need to add it. Edit the locale.gen file
nano /etc/locale.gen
Uncomment the following, then save and exit.
en_US.UTF-8 UTF-8
Generate the new locale by using the following command
locale-gen
To apply, restart the Zabbix server.
reboot
Within the documentation there is a section called Quickstart, this is a good place to start exploring Zabbix and I’d highly recommend this be the first place you visit. The Quickstart consists of: