Monitoring Linux Host in Zabbix

In previous article, i share how to install zabbix server, in this tutorial i want monitor my Linux host and add it into Zabbix.
Zabbix-Server | Host Linux (blog.pramudika.my.id) |
---|---|
10.8.13.103 | 10.8.13.2 |
What we need?
- Zabbix-Agent
My Linux host is Ubuntu Server 22.04, so lets install with same step
Update system
Make sure your system package is up to-date
sudo apt-get update && apt-get upgrade -y
Install Zabbix-Agent
Swith to root user
sudo -i
Add Zabbix repository
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu22.04_all.deb
dpkg -i zabbix-release_latest_7.0+ubuntu22.04_all.deb
apt update
Install Zabbix-Agent2
apt install zabbix-agent2 -y
Configure Zabbix-Agent
Change server configuration in zabbix agent
vi /etc/zabbix/zabbix_agent2.conf
In line 82 change to your server IP, and set keep default for other configuration
Server=10.8.13.103
Restart and Enable Zabbix Agent
systemctl restart zabbix-agent2 && systemctl enable --now zabbix-agent2
Verify zabbix agent by checking listen port (default port is 10050)
root@blog:~# ss -tulpn | grep 10050
tcp LISTEN 0 4096 *:10050 *:* users:(("zabbix_agent2",pid=816108,fd=7))
If you want secure zabbix agent (not exposed from public), you can use firewall to access list that port 10050 allowed from Zabbix-Server only
Use IPTables
apt install iptables-persistent -y
Allow TCP port 10050 from 10.8.13.103 (Zabbix Server)
iptables -A INPUT -p tcp --dport 10050 -j ACCEPT -s 10.8.13.103
#other rules-here
iptables -P INPUT -j DROP
iptables-save > /etc/iptables/rules.v4
Use UFW
ufw allow from 10.8.13.103 to any port 10050 proto tcp
Or use Security-Group/FirewallD and etc, same concept.
Test connection from Zabbix Server to Host
nc -v -z 10.8.13.2 10050
Connection to 10.8.13.2 10050 port [tcp/zabbix-agent] succeeded!
Add Host In Zabbix
Access Zabbix Web-UI -> Data collection -> Hosts -> Create host -> Insert host detail -> Add.
Insert host details: Host names, Templates (Linux by Zabbix agent), Host groups (Linux servers) , Interfaces (Agent 10.8.13.2 with port 10050)

You can custom for Host groups, its grouping server, for example you create grouping hosts: Production Server, Staging Server, etc.
Wait until ZBX icon is green


Verify host monitored by get latest data collected from host.
Go to Monitoring -> Latest data -> Hosts (filter with your host) -> Apply
You will get latest data monited on your host (CPU,Memory,Disk,Network, and etc.)

Conclusion
We have successfully add linux host to Zabbix Server, and for other operating system the concept are same, install Zabbix Agent, connect to Zabbix Server , and add host to Zabbix UI.
In next article i will share how to create alerting in Zabbix server and integrate with telegram or discord platform. Stay tuned!