zabbix_agentd.conf

  1. PidFile=/var/run/zabbix/zabbix_agentd.pid
  2. LogFile=/var/log/zabbix-agent/zabbix_agentd.log
  3. LogFileSize=0
  4. EnableRemoteCommands=1
  5. Server=lsg-zabbix-01.ezbuy.me,tn-zabbix-1.ezbuy.me
  6. ServerActive=lsg-zabbix-01.ezbuy.me,tn-zabbix-1.ezbuy.me
  7. Timeout=10
  8. #Hostname=ihk-ops-2
  9. HostnameItem=system.hostname
  10. Include=/etc/zabbix/zabbix_agentd.conf.d/
  11. UserParameter=socket.total_sockets,cat /proc/net/sockstat |grep sockets|awk '{print $3}'
  12. UserParameter=socket.tcp_inuse,cat /proc/net/sockstat |grep TCP |awk '{print $3}'
  13. UserParameter=socket.tcp_orphan,cat /proc/net/sockstat |grep TCP |awk '{print $5}'
  14. UserParameter=socket.tcp_timewait,cat /proc/net/sockstat |grep TCP |awk '{print $7}'
  15. UserParameter=socket.tcp_alloc,cat /proc/net/sockstat |grep TCP |awk '{print $9}'
  16. UserParameter=socket.tcp_mem,cat /proc/net/sockstat |grep TCP |awk '{print $11}'
  17. UserParameter=socket.tcp_estab,ss -s |grep estab|awk '{print $4}'|cut -d',' -f1
  18. UserParameter=socket.tcp_synrecv,ss -s |grep synrecv|awk '{print $10}'|cut -d',' -f1
  19. UserParameter=socket.udp_inuse,cat /proc/net/sockstat |grep UDP:|awk '{print $3}'
  20. UserParameter=socket.udp_mem,cat /proc/net/sockstat |grep UDP:|awk '{print $5}'
  21. UserParameter=cpu.load1,uptime | awk -F'[: ,]+' '{print $14}'
  22. UserParameter=cpu.load5,uptime | awk -F'[: ,]+' '{print $15}'
  23. UserParameter=cpu.load15,uptime | awk -F'[: ,]+' '{print $16}'
  24. UserParameter=cpu.count,cat /proc/cpuinfo | grep "processor" | wc -l

userparameter_diskstats.con

  1. cat /etc/zabbix/zabbix_agentd.conf.d/userparameter_diskstats.conf
  2. UserParameter=custom.vfs.discover_disks,/etc/zabbix/scripts/lld-disks.py
  3. UserParameter=custom.vfs.dev.read.ops[*],awk '{print $$1}' /sys/class/block/$1/stat
  4. UserParameter=custom.vfs.dev.read.merged[*],awk '{print $$2}' /sys/class/block/$1/stat
  5. UserParameter=custom.vfs.dev.read.sectors[*],awk '{print $$3}' /sys/class/block/$1/stat
  6. UserParameter=custom.vfs.dev.read.ms[*],awk '{print $$4}' /sys/class/block/$1/stat
  7. UserParameter=custom.vfs.dev.write.ops[*],awk '{print $$5}' /sys/class/block/$1/stat
  8. UserParameter=custom.vfs.dev.write.merged[*],awk '{print $$6}' /sys/class/block/$1/stat
  9. UserParameter=custom.vfs.dev.write.sectors[*],awk '{print $$7}' /sys/class/block/$1/stat
  10. UserParameter=custom.vfs.dev.write.ms[*],awk '{print $$8}' /sys/class/block/$1/stat
  11. UserParameter=custom.vfs.dev.io.active[*],awk '{print $$9}' /sys/class/block/$1/stat
  12. UserParameter=custom.vfs.dev.io.ms[*],awk '{print $$10}' /sys/class/block/$1/stat
  13. UserParameter=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