Zabbix v6 Docker Monitor
Install Agent 2
Remove Agent v1 (if present) and install version 2:
wget https://repo.zabbix.com/zabbix/5.5/debian/pool/main/z/zabbix-release/zabbix-release_5.5-1+debian11_all.deb
dpkg -i zabbix-release_5.5-1+debian11_all.deb
apt update && apt install zabbix-agent2
Configure the agent according to your server setup. And in addition to that un-comment the following line in /etc/zabbix/zabbix_agent2.conf:
### Option: Plugins.Docker.Endpoint
# Docker API endpoint.
#
# Mandatory: no
# Default: unix:///var/run/docker.sock
Plugins.Docker.Endpoint=unix:///var/run/docker.sock
Error: Configuration file not loaded
After starting systemctl enable zabbix-agent2 --now
the agent is still using the default config and trying to connect to localhost instead of my Zabbix Master:
cat /var/log/zabbix/zabbix_agent2.log
2021/11/11 09:54:39.261862 Zabbix Agent2 hostname: [Zabbix server]
2021/11/11 09:54:40.264710 [101] active check configuration update from [127.0.0.1:10051 Zabbix server] started to fail (dial tcp :0->127.0.0.1:10051: connect: connection refused)
Solution
The service file points to PIDFile=/run/zabbix/zabbix_agent2.pid
:
/usr/lib/systemd/system/zabbix-agent2.service / /lib/systemd/system/zabbix-agent2.service
[Unit]
Description=Zabbix Agent 2
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/etc/zabbix/zabbix_agent2.conf"
EnvironmentFile=-/etc/default/zabbix-agent2
Type=simple
Restart=on-failure
PIDFile=/run/zabbix/zabbix_agent2.pid
KillMode=control-group
ExecStart=/usr/sbin/zabbix_agent2 -c $CONFFILE
ExecStop=/bin/sh -c '[ -n "$1" ] && kill -s TERM "$1"' -- "$MAINPID"
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
I just encountered another issue on a different server - here the variable inside the service file was written
PidFile
instead ofPIDFile
and this lead to the same issue...
But the Agent conf should says PidFile=/var/run/zabbix/zabbix_agent2.pid:
/etc/zabbix/zabbix_agent2.conf
# This is a configuration file for Zabbix agent 2 (Unix)
# To get more information about Zabbix, visit http://www.zabbix.com
############ GENERAL PARAMETERS #################
### Option: PidFile
# Name of PID file.
#
# Mandatory: no
# Default:
# PidFile=/tmp/zabbix_agent2.pid
PidFile=/var/run/zabbix/zabbix_agent2.pid
/usr/lib/tmpfiles.d/zabbix-agent2.conf
d /var/run/zabbix 0755 zabbix zabbix - -
Change the service file to path to /var/run/zabbix/zabbix_agent2.pid
and reload the daemon:
systemctl daemon-reload
systemctl restart zabbix-agent2
Docker Plugin
Add the docker group to the Zabbix user and restart the agent to apply the new user group:
usermod -a -G docker zabbix
systemctl restart zabbix-agent2
Add the Docker Template from the Zabbix Server UI:
And shortly afterwards you should start seeing Docker Data coming in:
Available triggers: