Zabbix【部署 03】zabbix-agent2安装配置使用(zabbix-agent2监控docker实例分享)

该文详细介绍了如何在CentOS7系统上安装zabbix-agent2并配置监控Docker。首先,通过yum安装agent2,然后启动并设置开机启动。接着,对Docker进行配置,包括添加zabbix用户到docker组,重启docker服务。在agent2配置中,启用Docker插件并指定endpoint。最后,通过zabbix_get验证配置成功,能获取到Docker的相关信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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模板,具体配置不再赘述。

在这里插入图片描述

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yuanzhengme.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值