How To Install and Configure Zabbix Agent 5 on Ubuntu 20.04

A Zabbix agent is a program that runs on a remote machine that needs to be monitored through the Zabbix server. The agent collects the data on the remote server and send back to Zabbix server when requested. Zabbix agent must be installed on all the remote systems that need to be monitor through the Zabbix server.

There are two types of checks:

  • Passive Check - Zabbix Agent sent data to server on their request.
  • Active Check - Zabbix Agent sends data periodically to server.

In this article, we will learn how to install the Zabbix agent on Ubuntu 20.04 Server. Checkout this guide on How to Install and Configure Zabbix Server 5 on Rocky Linux/Alma Linux 8.

Also check:

Table of Content

  1. Ensure that the server is up to date
  2. Install the Zabbix Agent
  3. Configure Zabbix Agent
  4. Adjust firewall for Zabbix
  5. Start and enable the Zabbix agent

Ensure that the server packages are up to date

Before proceeding, let us make sure that our server packages are up to date with this command:

1
2
sudo apt update
sudo apt upgrade -y

Let us also install some common packages that we will need

1
sudo apt install -y vim

Install the Zabbix Agent

The Zabbix agent packages are not available under the default Ubuntu repositories. We will need to configure the Zabbix repository in our system before installing the agent.

The latest Zabbix version as at the writing of this article is Zabbix version 5.4. Install the Zabbix version 5.4 repository using this command:

1
2
curl -LO https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+$(lsb_release -sc)_all.deb
sudo dpkg -i ./zabbix-release_5.0-1+$(lsb_release -sc)_all.deb

If you are still working with Zabbix 4.0 LTS version:

1
2
sudo wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+$(lsb_release -sc)_all.deb
sudo dpkg -i zabbix-release_4.0-3+$(lsb_release -sc)_all.deb

Once the repository is installed, we can install the agent. Use this command:

1
sudo apt update && sudo apt install -y zabbix-agent

Confirm the software version installed:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$ apt-cache policy zabbix-agent

zabbix-agent:
  Installed: 1:5.0.19-1+focal
  Candidate: 1:5.0.19-1+focal
  Version table:
 *** 1:5.0.19-1+focal 500
        500 http://repo.zabbix.com/zabbix/5.0/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
     1:4.0.17+dfsg-1 500
        500 http://eu-west-3.ec2.archive.ubuntu.com/ubuntu focal/universe amd64 Packages

Configure Zabbix Agent

Now, you need to configure the Agent service to allow Zabbix server requests. We will also update the Hostname so we know which server we configured the agent on. Edit the Zabbix agent configuration file by adding the Zabbix server IP.

1
sudo vim /etc/zabbix/zabbix_agentd.conf

Add this content:

1
2
3
Server=10.70.5.218
ServerActive=10.70.5.218
Hostname=dev-ubuntusrv

In the “Server” and “ServerActive” parameters put the IP address of your Zabbix server or proxy!

Adjust Firewall for Zabbix

if you have an UFW firewall installed on Ubuntu, you can use this command to permit Zabbix agent TCP port 10050:

1
sudo ufw allow 10050/tcp

Start and enable the Zabbix agent

We can now start the agent. Use this command to start:

1
sudo systemctl start zabbix-agent

Check the status to confirm that it is started.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
$ sudo systemctl status zabbix-agent

 zabbix-agent.service - Zabbix Agent
     Loaded: loaded (/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-01-17 07:18:05 UTC; 8min ago
   Main PID: 16475 (zabbix_agentd)
      Tasks: 6 (limit: 4624)
     Memory: 4.4M
     CGroup: /system.slice/zabbix-agent.service
             ├─16475 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
             ├─16476 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
             ├─16477 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
             ├─16478 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
             ├─16479 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
             └─16480 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Jan 17 07:18:05 dev-ubuntusrv.inv.re systemd[1]: Starting Zabbix Agent...
Jan 17 07:18:05 dev-ubuntusrv.inv.re systemd[1]: Started Zabbix Agent.

From the above output, we can confirm that the agent is running. To enable the agent to start on boot, use this command:

1
sudo systemctl enable zabbix-agent

That is it! You have successfully installed Zabbix Agent on your Ubuntu 20.04. You can now proceed to add host in Zabbix server to be monitored. Checkout this guide How to Add Host in Zabbix Server to Monitor.

Last updated on Oct 14, 2024 11:46 +0300
comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy