Sign In
Sign In

Installing and Configuring Zabbix on Ubuntu 22.04

Installing and Configuring Zabbix on Ubuntu 22.04
Hostman Team
Technical writer
Ubuntu
26.07.2024
Reading time: 4 min

Zabbix is a popular open-source tool designed for monitoring servers, networks, services, cloud resources, and business metrics. It consists of several components, including:

  • Zabbix Server: The core component responsible for data storage and network service management.

  • Zabbix Agent: A background utility (daemon) that monitors and collects statistics on resources like RAM, CPU, and application metrics. It supports both active (agent requests data) and passive (agent waits for server requests) modes.

  • Zabbix Proxy: An optional component that distributes the load on the Zabbix server.

  • Web Interface: A web panel for tracking system metrics and configuring both Zabbix and monitored components.

In this tutorial, we'll install Zabbix 6 on Ubuntu 22.04 and connect and configure one agent.

Prerequisites

You will need:

  • Two cloud servers or virtual machines running Ubuntu 22.04: one for the Zabbix server and one for the Zabbix agent.

  • A pre-installed MySQL/MariaDB or PostgreSQL database on the host for the Zabbix server. This tutorial uses PostgreSQL.

Installing the Zabbix Server

All steps should be performed as root or a sudo user.

Add the official Zabbix repository:

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu22.04_all.deb

Install the downloaded package:

dpkg -i zabbix-release_6.0-4+ubuntu22.04_all.deb

Install Zabbix server and dependencies:

apt update && apt -y install zabbix-server-pgsql zabbix-frontend-php php8.1-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent

Create a PostgreSQL user and database for Zabbix:

sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix

Import the Zabbix database schema:

zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix

Edit the Zabbix server configuration:

nano /etc/zabbix/zabbix_server.conf

Find the DBPassword parameter and set the database password.

Image1

Edit the Nginx configuration for Zabbix:

nano /etc/zabbix/nginx.conf

Uncomment and set the listen and server_name parameters.

Restart and enable services:

systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm

Verify the Zabbix server status:

systemctl status zabbix-server

Configuring the Zabbix Server

Further configuration is done via the web interface. Navigate to the domain name and port specified in nginx.conf.

  1. Select the language.

  2. Verify system requirements.

  3. Configure database connection: Enter the database name zabbix, user zabbix, and the password.

Image25

  1. Set Zabbix server name, time zone, and theme.

  2. Review and confirm settings.

Image10

After successful configuration, log in with the default credentials: Admin and zabbix.

Image33

Installing the Zabbix Agent

Switch to the second server for the Zabbix agent installation.

Download the Zabbix repository:

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu22.04_all.deb

Install the downloaded package:

dpkg -i zabbix-release_latest+ubuntu22.04_all.deb

Install the Zabbix agent:

apt update && apt -y install zabbix-agent

Edit the Zabbix agent configuration:

nano /etc/zabbix/zabbix_agentd.conf

Set the parameters: 

  • Server: enter the domain name or IP address of the Zabbix server.
  • ServerActive: enter the same value as above; this parameter is responsible for the active mode, when Zabbix independently requests the necessary data.
  • Hostname: enter the agent hostname exactly as it is specified in the system. You can use the hostname command to check. If the hostname is incorrect, the agent will not be able to connect to the Zabbix server.

Restart and enable the Zabbix agent:

systemctl restart zabbix-agent
systemctl enable zabbix-agent

Verify the agent status:

systemctl status zabbix-agent

Adding the Zabbix Agent in the Zabbix Server Web Interface

  1. Navigate to Configuration > Hosts.

  2. Click on Create host.

  3. Fill in the host details:

    • Host name: set any convenient name for the Zabbix agent to display in the Zabbix server web interface.

    • Groups: create a new group or select an existing one. Groups are used for organizational purposes and to assign access rights to data.

    • Templates: select a template that is used exactly like the agent installed on the server.

    • Interfaces: Add the IP address or domain name of the Zabbix agent host.

If using an IP address, you must enter it in the IP address field and select IP in the Connect to section.

If using a domain name, you must enter the name in the DNS name section and select DNS in in the Connect to section.

  1. Update and verify: The agent will appear in the list and metrics will be available under Monitoring > Hosts > Graphs.

Conclusion

Zabbix provides comprehensive monitoring for hardware, networks, and services, making it suitable for both corporate environments and personal use. With this guide, you have set up a Zabbix server and agent on Ubuntu, and you are now ready to monitor various metrics and ensure the health of your infrastructure.

Ubuntu
26.07.2024
Reading time: 4 min

Do you have questions,
comments, or concerns?

Our professionals are available to assist you at any moment,
whether you need help or are just unsure of where to start
Email us