Software, electronics and anything else

Setting up Zabbix – Zabbix Agent


In this post, I’ll go over how to set up Zabbix for a SMTP mail server. I assume you have already followed my previous post and have a running Zabbix server.


To install the Zabbix agent on a Ubuntu based system, you need to follow step 2.a. from their download instructions. That is, execute

dpkg -i zabbix-release_5.0-1+focal_all.deb
apt update 

on the mail server.

root@smtp:~# wget
 --2021-03-04 19:40:15--
 Resolving (… 2604:a880:2:d0::2062:d001,
 Connecting to (|2604:a880:2:d0::2062:d001|:443… connected.
 HTTP request sent, awaiting response… 200 OK
 Length: 4244 (4.1K) [application/octet-stream]
 Saving to: 'zabbix-release_5.0-1+focal_all.deb'
 zabbix-release_5.0-1+focal_al 100%[=================================================>]   4.14K  --.-KB/s    in 0s
 2021-03-04 19:40:16 (429 MB/s) - 'zabbix-release_5.0-1+focal_all.deb' saved [4244/4244]
 root@smtp:~# dpkg -i zabbix-release_5.0-1+focal_all.deb
 Selecting previously unselected package zabbix-release.
 (Reading database … 38747 files and directories currently installed.)
 Preparing to unpack zabbix-release_5.0-1+focal_all.deb …
 Unpacking zabbix-release (1:5.0-1+focal) …
 Setting up zabbix-release (1:5.0-1+focal) …
 root@smtp:~# apt update
 Get:1 focal InRelease [4930 B]
 Hit:2 focal InRelease
 Hit:3 focal InRelease
 Get:4 focal-updates InRelease [114 kB]
 Get:5 focal/main Sources [1193 B]
 Get:6 focal-security InRelease [109 kB]
 Get:7 focal/main amd64 Packages [3226 B]
 Get:8 focal-updates/main amd64 Packages [841 kB]
 Get:9 focal-updates/main Translation-en [201 kB]
 Get:10 focal-updates/main amd64 c-n-f Metadata [12.8 kB]
 Get:11 focal-updates/universe amd64 Packages [747 kB]
 Get:12 focal-updates/universe Translation-en [155 kB]
 Fetched 2189 kB in 2s (1014 kB/s)
 Reading package lists… Done
 Building dependency tree
 Reading state information… Done

Install Packages

Now you can install the agent itself:

root@smtp:~# apt install zabbix-agent
 Reading package lists… Done
 Building dependency tree
 Reading state information… Done
 The following NEW packages will be installed:
 0 upgraded, 1 newly installed, 0 to remove and 16 not upgraded.
 Need to get 201 kB of archives.
 After this operation, 806 kB of additional disk space will be used.
 Get:1 focal/main amd64 zabbix-agent amd64 1:5.0.9-1+focal [201 kB]
 Fetched 201 kB in 0s (524 kB/s)
 Selecting previously unselected package zabbix-agent.
 (Reading database … 38753 files and directories currently installed.)
 Preparing to unpack …/zabbix-agent_1%3a5.0.9-1+focal_amd64.deb …
 Unpacking zabbix-agent (1:5.0.9-1+focal) …
 Setting up zabbix-agent (1:5.0.9-1+focal) …
 Created symlink /etc/systemd/system/ -> /lib/systemd/system/zabbix-agent.service.
 Processing triggers for man-db (2.9.1-1) …
 Processing triggers for systemd (245.4-4ubuntu3.4) …

The agent is now installed, and must be configured. Being a mail server, it is accessible from the internet, so we do not need to deviate from default settings too much. You will need to make sure that whatever firewall you use has port 10050 open or forwarded via NAT as necessary to the server. You could also use a Zabbix proxy server on your firewall if you have more than one machine that must talk behind that firewall, but I won’t cover that in this post.


In /etc/zabbix/zabbix_agentd.conf; find and modify the following lines as appropriate for your server: #Zabbix server to connect to #Zabbix server to allow connections from #name of the machine to be monitored

You will also want to use TLS encryption when using Zabbix over the internet. Generate a pre-shared key, similar to what you use when setting up a home WiFi network:

sh -c "openssl rand -hex 32 > /etc/zabbix/zabbix_agentd.psk"

and remember the value of that key. For example,


Open /etc/zabbix/zabbix_agentd.conf again and modify the following lines:


Access your Zabbix server and add the host (Configuration → Hosts → Create Host). Set the hostname as you did in /etc/zabbix/zabbix_agentd.conf and assign it a group, such as Linux Servers.

Zabbix Host Configuration

Also critical is using a template to have Zabbix actually monitor something. In this example we’ll use the template Template OS Linux by Zabbix agent.


Lastly, you need to configure the encryption on this side too. Use the same settings as with the agent; you need the preshared key you selected earlier, along with the PSK identity:

Click add, and you should be done! Now just restart the zabbix agent on the mail server to get your settings working…

systemctl restart zabbix-agent

You can check in Monitoring → Latest Data and filter by Hosts to see if the Zabbix server is receiving data from the agent.

Leave a Reply

Your email address will not be published. Required fields are marked *