1. Principle of Zabbix agent2 monitoring docker container
The implementation principle of zabbix agent2 monitoring docker plug-in is actually to obtain data by calling the docker API. The plug-in directory is located in zabbix-agent2/src/go/plugins/docker. Among them, the client.go file defines the use of the UNIX socket address to communicate between the docker client and the server. The default socket location is /var/run/docker.sock.
Note that to monitor docker containers, zabbix agent2 must be used, and zabbix agent cannot monitor docker.
2. Zabbix agent2 monitors Docker container steps
Install zabbix agent2 on the server that needs to be monitored. Here, take the 172.16.213.226 host as an example.
Modify the zabbix-agent2 configuration file, mainly the following three:
# zabbix server 地址
Server=172.16.213.70
# zabbix Server 地址
ServerActive=172.16.213.70
# 主机名称
Hostname=dockerserver
Add the zabbix user to the docker group, otherwise the data cannot be obtained:
[root@zabbixserver ~]# usermod -aG docker zabbix