1.2安裝zabbix-agent
現在我們在另外一臺機器上安裝zabbix-agent
1.2.1 yum 安裝
[root@01~]# yum install zabbix22-agent –y
*使用yum安裝即可
1.2.2 修改zabbix_agentd配置文件
[root@01~]# grep ^[^#] /etc/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=ip
ServerActive=ip
Include=/etc/zabbix_agentd.conf.d/
*只要在zabbix_agentd.conf 配置文件裏面配置一些server端ip,自己的日誌、pid信息即可。
1.2.3 啓動zabbix-agent
[root@01~]# mkdir /etc/zabbix_agentd.conf.d
[root@01~]# /etc/init.d/zabbix-agentd start
Zabbix-agent配置完成
2.1添加腳本
以添加tcp連接數爲例,寫好腳本tcp_conn_80.sh
[root@a01zabbix_scripts]# cat tcp_conn_80.sh
#!/bin/bash
netstat-nltupa |awk -F' ' '{print $4}' |grep :80 |wc -c
[root@01zabbix_scripts]# pwd
/data/install/zabbix_scripts
2.2添加配置文件
[root@01zabbix_scripts]# cat /etc/zabbix_agentd.conf.d/tcp_conn.conf
UserParameter=tcp_conn_80,/data/install/zabbix_scripts/tcp_conn_80.sh
[root@01zabbix_scripts]# bash tcp_conn_80.sh
13
2.3用zabbix_get 獲取值
[root@02~]# zabbix_get -s ip -k tcp_conn_80
13