查看2222端口
[root@yunwei-ceshi ~]# lsof -i:2222
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 7179 root 4u IPv6 378945139 0t0 TCP *:EtherNet/IP-1 (LISTEN)
查看docker运行junpserver进程名称
[root@yunwei-ceshi ~]# ps -ef | grep docker
root 7179 26590 0 08:04 ? 00:00:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2222 -container-ip 172.17.0.2 -container-port 2222
编辑zabbix配置文件
[root@yunwei-ceshi ~]# cd /usr/local/zabbix/etc/
[root@yunwei-ceshi etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d
[root@yunwei-ceshi etc]# vim zabbix_agentd.conf
找到
UserParameter=
添加:
# UserParameter=
UserParameter=jumpserver,sh /usr/local/zabbix/etc/process_sh/jumpserver.sh
jumpserver//进程名称
sh /usr/local/zabbix/etc/process_sh/jumpserver.sh//执行的脚本
然后进入脚本目录编辑脚本
[root@yunwei-ceshi etc]# mkdir /usr/local/zabbix/etc/process_sh/
[root@yunwei-ceshi etc]# cd /usr/local/zabbix/etc/process_sh/
[root@yunwei-ceshi process_sh]# vim jumpserver.sh
#/bin/bash
lsof -i:2222 | grep docker | wc -l
赋予权限
[root@yunwei-ceshi process_sh]# chmod 755 jumpserver.sh
重启zabbix_agentd
[root@yunwei-ceshi process_sh]# /etc/init.d/zabbix_agentd restart