18. October 2022

How to Install and Configure Zabbix Agents on Remote Linux

By H. Cemre Günay

Continuing the Zabbix series, this tutorial will guide you on how you can install and configure Zabbix agents on Linux (Debian-based systems and RHEL-based distros) in order to actively monitor local resources on remote systems.

The main job of Zabbix agents consists in gathering local information from the targets where they run and sending the data to a central Zabbix server to be further processed and analyzed.

If you do not have root priviliges please use sudo infront of every command.

Requirements

You must already have a running Zabbix monitoring appliance, if not, you can find more instructions here:

or for Windows Users:

Step 1: Install Zabbix Agents in Linux Systems

1. Depending on the Linux distribution you are running, go to the Zabbix download page, grab the latest version of the available agent’s binary packages using a tool such as wget or curl and install it on your machine using the distribution-specific package manager – YumRpm or Dpkg.

For Debian/Ubuntu systems (including latest releases) use the following steps to download and install Zabbix Agent:

Install Zabbix Agent in Debian

----------------- On Debian 11 -----------------
wget https://repo.zabbix.com/zabbix/6.2/debian/pool/main/z/zabbix-release/zabbix-release_6.2-2%2Bdebian11_all.deb
dpkg -i zabbix-release_6.2-2+debian11_all.deb
apt update && apt upgrade -y
apt install zabbix-agent

----------------- On Debian 10 -----------------
wget https://repo.zabbix.com/zabbix/6.2/debian/pool/main/z/zabbix-release/zabbix-release_6.2-2%2Bdebian10_all.deb
dpkg -i zabbix-release_6.2-2+debian10_all.deb
apt update && apt upgrade -y
apt install zabbix-agent

Install Zabbix On RHEL-based Systems (incl. CentOS 8)

For RHEL alike systems, download the .rpm packaged for the distribution-specific release number, using the same page as above, and install it using rpm package manager.

In order to automatically manage missing dependency issues and install the agent using one-shot use the yum command followed by the binary package download link, as in the example below used for installing the agent on CentOS 8:

----------------- On RedHat Enterprise 8 // CentOS 8 -----------------
rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/8/x86_64/zabbix-release-6.2-3.el8.noarch.rpm
dnf clean all
dnf install zabbix-agent

Step 2: Configure and Test Zabbix Agent in Linux

1. The next logical step after installing the packages on the system is to open the Zabbix agent configuration file located in /etc/zabbix/ system path on both major distributions and instruct the program to send all the collected information to the Zabbix server in order to be analyzed and processed.

Therefore, open the zabbix_agentd.conf file with your favorite text editor, find the below lines (use the screenshots as a guide), uncomment them and make the following changes:

nano /etc/zabbix/zabbix_agentd.conf

add Zabbix server IP address and hostname as shown below.

Server=IP of Zabbix Server
ServerActive=IP of Zabbix Server
Hostname=use the FQDN of the node where the agent runs
Add Zabbix Server IP Address
Add Zabbix Server Active IP Address
Add Zabbix Agent Hostname

2. Once you’ve finished editing the Zabbix agent configuration file with the required values, restart the daemon using the following command, then use the netstat command to verify if the daemon has been started and operates on the specific port – 10050/tcp:

systemctl restart zabbix-agent
netstat -tulpn|grep zabbix

3. (optional) If your system is behind a firewall then you need to open 10050/tcp port on the system in order to reach through the Zabbix server.

For Debian based systems, including Ubuntu, you can use the ufw tool to open the port and on RHEL-based, you can use Firewalld utility to manage the firewall rules as the below examples:

ufw allow 10050/tcp  # On Debian based systems
firewall-cmd --add-port=10050/tcp --permanent  # On RHEL based systems

4. Finally, in order to test if you can reach Zabbix Agent from Zabbix Server, use Telnet command from Zabbix server machine to the IP addresses of the machines that run the agents, as illustrated below (don’t worry about the thrown error from agents):

telnet zabbix_agent_IP 10050

Step 3: Add Zabbix Agent Monitored Host to Zabbix Server

1. On the next step it’s time to move to the Zabbix server web console and start adding the hosts which run zabbix agent in order to be monitored by the server.

Go to Configuration -> Hosts -> Create Host -> Host tab and fill the Hostname field with the FQDN of the monitored Zabbix agent machine, use the same value as above for the Visible name field.

Next, add this host to a group of monitored servers and use the IP Address of the monitored machine at the Agent interfaces field – alternatively you can also use DNS resolution if it’s the case. Use the below screenshots as a guide.

Add Linux Host to Zabbix Monitoring (upper right)
Hit the Credentials and add the Interface via IP or DNS
Add Host to a group

2. Next, move to the Templates tab and hit Select. A new window with templates should open. Choose Template OS Linux then scroll down and hit on Select button to add it and automatically close the window.

3. Once the template appears to Link the new template box, hit on Add text to link it to Zabbix server, then hit on the lower Add button to finish the process and completely add the monitored host. The visible name of the monitored host should now appear hosts window.

That’s all! Just assure that the host Status is set to Enabled and wait a few minutes in order for the Zabbix server to contact the agent, process the received data, and inform or eventually alert you if something goes bad on the monitored target.

If you have any questions, please use the comment section below. 🙂