zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pidLogFile=/var/log/zabbix-agent/zabbix_agentd.logLogFileSize=0EnableRemoteCommands=1Server=lsg-zabbix-01.ezbuy.me,tn-zabbix-1.ezbuy.meServerActive=lsg-zabbix-01.ezbuy.me,tn-zabbix-1.ezbuy.meTimeout=10#Hostname=ihk-ops-2HostnameItem=system.hostnameInclude=/etc/zabbix/zabbix_agentd.conf.d/UserParameter=socket.total_sockets,cat /proc/net/sockstat |grep sockets|awk '{print $3}'UserParameter=socket.tcp_inuse,cat /proc/net/sockstat |grep TCP |awk '{print $3}'UserParameter=socket.tcp_orphan,cat /proc/net/sockstat |grep TCP |awk '{print $5}'UserParameter=socket.tcp_timewait,cat /proc/net/sockstat |grep TCP |awk '{print $7}'UserParameter=socket.tcp_alloc,cat /proc/net/sockstat |grep TCP |awk '{print $9}'UserParameter=socket.tcp_mem,cat /proc/net/sockstat |grep TCP |awk '{print $11}'UserParameter=socket.tcp_estab,ss -s |grep estab|awk '{print $4}'|cut -d',' -f1UserParameter=socket.tcp_synrecv,ss -s |grep synrecv|awk '{print $10}'|cut -d',' -f1UserParameter=socket.udp_inuse,cat /proc/net/sockstat |grep UDP:|awk '{print $3}'UserParameter=socket.udp_mem,cat /proc/net/sockstat |grep UDP:|awk '{print $5}'UserParameter=cpu.load1,uptime | awk -F'[: ,]+' '{print $14}'UserParameter=cpu.load5,uptime | awk -F'[: ,]+' '{print $15}'UserParameter=cpu.load15,uptime | awk -F'[: ,]+' '{print $16}'UserParameter=cpu.count,cat /proc/cpuinfo | grep "processor" | wc -l
userparameter_diskstats.con
cat /etc/zabbix/zabbix_agentd.conf.d/userparameter_diskstats.confUserParameter=custom.vfs.discover_disks,/etc/zabbix/scripts/lld-disks.pyUserParameter=custom.vfs.dev.read.ops[*],awk '{print $$1}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.read.merged[*],awk '{print $$2}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.read.sectors[*],awk '{print $$3}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.read.ms[*],awk '{print $$4}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.write.ops[*],awk '{print $$5}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.write.merged[*],awk '{print $$6}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.write.sectors[*],awk '{print $$7}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.write.ms[*],awk '{print $$8}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.io.active[*],awk '{print $$9}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.io.ms[*],awk '{print $$10}' /sys/class/block/$1/statUserParameter=custom.vfs.dev.weight.io.ms[*],awk '{print $$11}' /sys/class/block/$1/stat
lld-disks.py
cat ../scripts/lld-disks.py
#!/usr/bin/python
import os
import json
if __name__ == "__main__":
# Iterate over all block devices, but ignore them if they are in the
# skippable set
skippable = ("sr", "loop", "ram")
devices = (device for device in os.listdir("/sys/class/block")
if not any(ignore in device for ignore in skippable))
data = [{"{#DEVICENAME}": device} for device in devices]
print(json.dumps({"data": data}, indent=4))
zabbix 权限配置
echo "zabbix ALL=NOPASSWD:ALL" >>/etc/sudoers