Operating System Ubuntu

How to Monitor Remote Servers Using Zabbix on Ubuntu 24.04

Install the Zabbix 8.0 LTS server and frontend on Ubuntu 24.04 and monitor a remote Linux server with Zabbix agent 2.

This guide installs a Zabbix 8.0 LTS server with its web frontend on Ubuntu 24.04 LTS, then adds a second Linux server as a monitored host using Zabbix agent 2. When you finish, CPU, memory, disk, network and service data from the remote server appears in the Zabbix dashboard and problems raise alerts.

Older tutorials on this topic targeted Ubuntu 16.04, which is long out of standard support. Ubuntu 22.04 can use the same Zabbix repository, but its stock MariaDB and PHP packages are older than Zabbix 8.0 requires, so on 22.04 either upgrade to 24.04 or stay on an older Zabbix LTS release.

Requirements

  • An Ubuntu 24.04 server for Zabbix (203.0.113.10 in the examples) and a Linux server to monitor (203.0.113.20).
  • A user with sudo rights on both.
  • Zabbix 8.0 needs PHP 8.2 or later and either MariaDB 10.11 or later or MySQL 8.4 or later. Ubuntu 24.04 ships PHP 8.3 and MariaDB 10.11, which fit. Its mysql-server package is MySQL 8.0, which is too old, so this guide uses MariaDB.

Ubuntu also carries its own zabbix-* packages. They are not maintained by the Zabbix project and lag behind; use the official repository as shown below.

Step 1: Add the Zabbix repository

On the Zabbix server, download and install the repository package, then refresh the package lists:

wget https://repo.zabbix.com/zabbix/8.0/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_8.0+ubuntu24.04_all.deb
sudo dpkg -i zabbix-release_latest_8.0+ubuntu24.04_all.deb
sudo apt update

Step 2: Install the server, frontend, agent and database

sudo apt install -y mariadb-server zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2

This pulls in Apache and PHP as dependencies. The zabbix-agent2 package lets the Zabbix server monitor itself.

Step 3: Create the database

Open a MariaDB shell as root with sudo mysql and run the following. Replace StrongDBPassword with a password of your own:

create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'StrongDBPassword';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;

Import the initial schema and data. Enter the new password when prompted; the import runs for a few minutes without output:

zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

Switch the temporary setting back off:

sudo mysql -e "set global log_bin_trust_function_creators = 0;"

Step 4: Configure and start Zabbix

Open /etc/zabbix/zabbix_server.conf in an editor and set the database password:

DBPassword=StrongDBPassword

Restart the services and enable them at boot:

sudo systemctl restart zabbix-server zabbix-agent2 apache2
sudo systemctl enable zabbix-server zabbix-agent2 apache2

If you use UFW, allow web access and the port on which the server receives data from agents:

sudo ufw allow 80/tcp
sudo ufw allow 10051/tcp

Step 5: Finish the setup in the browser

Open http://203.0.113.10/zabbix. The setup wizard checks the PHP prerequisites, then asks for the database connection: type MySQL, host localhost, database zabbix, user zabbix and the password from step 3. Choose a server name and time zone and finish.

Sign in with the user name Admin and the password zabbix, then change the password straight away under User settings > Profile. The default credentials are public knowledge. Before you expose the frontend to the internet, put it behind HTTPS.

Step 6: Install agent 2 on the remote server

Log in to the server you want to monitor. On Ubuntu 24.04, add the same repository and install the agent:

wget https://repo.zabbix.com/zabbix/8.0/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_8.0+ubuntu24.04_all.deb
sudo dpkg -i zabbix-release_latest_8.0+ubuntu24.04_all.deb
sudo apt update
sudo apt install -y zabbix-agent2

For other distributions, pick the system on the Zabbix download page to get the matching repository package; the rest of this step is identical. Edit /etc/zabbix/zabbix_agent2.conf and change these three lines:

Server=203.0.113.10
ServerActive=203.0.113.10
Hostname=web01
  • Server lists the addresses allowed to query the agent (passive checks). Requests from anywhere else are rejected.
  • ServerActive is the server the agent contacts by itself to send data (active checks).
  • Hostname must be exactly the host name you enter in the frontend in the next step. It is case-sensitive.

Restart the agent and allow the Zabbix server, and only it, to reach port 10050:

sudo systemctl restart zabbix-agent2
sudo systemctl enable zabbix-agent2
sudo ufw allow from 203.0.113.10 to any port 10050 proto tcp

Step 7: Add the host in the frontend

In the Zabbix frontend go to Data collection > Hosts and create a host:

  1. Host name: web01.
  2. Templates: type and select Linux by Zabbix agent. This one template adds the items, triggers and graphs for a typical Linux server.
  3. Host groups: for example Linux servers.
  4. Interfaces: add an Agent interface with the IP address 203.0.113.20.
  5. Click Add.

If the remote server sits behind NAT or a firewall that blocks incoming connections, use the template Linux by Zabbix agent active instead and leave the interface empty. The agent then opens all connections itself, to port 10051 on the Zabbix server.

Verify that data arrives

Open Monitoring > Hosts and click Latest data next to web01. Values start to appear within a few minutes. To test alerting, load the CPU on the remote server for a while and watch Monitoring > Problems:

cat /dev/urandom | md5sum

Stop it with Ctrl+C. If nothing arrives, check these points:

  • On the remote server, sudo systemctl status zabbix-agent2 shows whether the agent runs, and /var/log/zabbix/zabbix_agent2.log shows rejected connections, which usually point to a wrong Server address.
  • On the Zabbix server, /var/log/zabbix/zabbix_server.log reports hosts it cannot reach. A timeout means a firewall is blocking port 10050.
  • For active checks, a mismatch between Hostname and the host name in the frontend is the usual cause.

Maintenance and next steps

  • Regular sudo apt update && sudo apt upgrade keeps Zabbix current within the 8.0 LTS series. Installing extra Zabbix packages with apt can also pull in upgrades of the ones already installed, so plan such changes.
  • To receive e-mail alerts, add your address under User settings > Profile > Media and enable a notification action.
  • Agent traffic is unencrypted by default. When the server and host talk over the public internet, set up a pre-shared key or certificates as described in the Zabbix manual.
  • Back up the zabbix database regularly; it holds both configuration and history.

Frequently asked questions

What is the difference between Zabbix agent and agent 2?

Agent 2 is the newer agent, written in Go, with plugins for software such as databases and Docker. It reads the same main settings and works with the same Linux templates, so it is the sensible default on a new host. The classic agent uses the package zabbix-agent and the file /etc/zabbix/zabbix_agentd.conf.

Should I use passive or active checks?

Passive checks are simpler to debug because the server asks and the agent answers. Active checks suit hosts the server cannot reach directly, since only outbound connections from the host are needed. The collected data is the same.

Can I use PostgreSQL or Nginx instead?

Yes. The official repository has matching packages; choose the database and web server on the Zabbix download page and it shows the package names and commands for that combination.

Does the agent version have to match the server?

Zabbix recommends installing the agent of the same version as the server. Check the server version with zabbix_server -V.

Share story:

Continue reading other guides on How VPS.