zabbix-agent2监控docker流程实例
1.安装agent2
# 1.选择合适的安装库
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
# 2.安装zabbix-agent2
yum install -y zabbix-agent2
# 3.启动并设置开启启动
systemctl restart zabbix-agent2
systemctl enable zabbix-agent2
2.配置
2.1 docker配置
# 如果不进行docker配置 zabbix_get 无法获取数据
# zaabix_server 更无法获取数据
[root@tcloud zabbix]# zabbix_get -s 127.0.0.1 -k docker.info
ZBX_NOTSUPPORTED: Unsupported item key.
# 1.查看docker 分组下的所有用户
grep 'docker' /etc/group
# 2.创建用户组
groupadd docker
# 3.将zabbix添加到用户组
usermod -aG docker zabbix
# 4.重启docker服务【重启命令根据实际情况执行】
systemctl restart docker
2.2 agent2配置
● See Zabbix template operation for basic instructions.
# 1.修改配置文件
vim zabbix_agent2.conf
# 服务端IP地址【根据实际情况配置】
Server=127.0.0.1
# 如果部署了agent需要修改agent2的端口号
ListenPort=20050
# 主动注册指向服务端【根据实际情况配置】
ServerActive=127.0.0.1
# 启用Docker插件
Plugins.Docker.Endpoint=unix:///run/docker.sock
● Setup and configure zabbix-agent2 compiled with the Docker monitoring plugin.
● Test availability: zabbix_get -s docker-host -k docker.info
# 2.重启 agent2 服务
systemctl restart zabbix-agent2
[root@tcloud zabbix]# zabbix_get -s 127.0.0.1 -k docker.info
{
"Architecture": "x86_64",
"BridgeNfIP6tables": false,
"BridgeNfIptables": false,
"CPUSet": true,
"CPUShares": true,
"CgroupDriver": "cgroupfs",
"ClusterAdvertise": "",
"ClusterStore": "",
"Containers": 1,
"ContainersPaused": 0,
"ContainersRunning": 1,
"ContainersStopped": 0,
"CpuCfsPeriod": true,
"CpuCfsQuota": true,
"Debug": false,
"DefaultRuntime": "runc",
"DockerRootDir": "/var/lib/docker",
"Driver": "overlay2",
"ExperimentalBuild": false,
"IPv4Forwarding": true,
"Id": "L5FW:CLSE:5QRH:P2FJ:A5UO:CO4R:WLKY:2377:32QY:3IPH:ISR7:KBCV",
"Images": 1,
"IndexServerAddress": "https://index.docker.io/v1/",
"InitBinary": "docker-init",
"KernelMemory": true,
"KernelMemoryTCP": true,
"KernelVersion": "3.10.0-1160.71.1.el7.x86_64",
"LiveRestoreEnabled": false,
"LoggingDriver": "json-file",
"MemTotal": 2095964160,
"MemoryLimit": true,
"NCPU": 1,
"NEventsListener": 0,
"NFd": 32,
"NGoroutines": 45,
"Name": "tcloud",
"OSType": "linux",
"OSVersion": "7",
"OomKillDisable": true,
"OperatingSystem": "CentOS Linux 7 (Core)",
"PidsLimit": true,
"SecurityOptions": [
"name=seccomp,profile=default"
],
"ServerVersion": "20.10.13",
"SwapLimit": true,
"Warnings": [
"WARNING: bridge-nf-call-iptables is disabled",
"WARNING: bridge-nf-call-ip6tables is disabled"
]
}
3.使用
使用Template App Docker
模板,具体配置不再赘述。