1,定义获取值的 disk_stat.conf配置文件
cat disk_stat.conf
UserParameter=custom.vfs.discover_disks,/usr/local/zabbix_agents_3.2.7/scripts/disk_discovery.py
UserParameter=custom.vfs.dev.read.ops[*],awk '{print $$1}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.read.merged[*],awk '{print $$2}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.read.sectors[*],awk '{print $$3}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.read.ms[*],awk '{print $$4}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.write.ops[*],awk '{print $$5}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.write.merged[*],awk '{print $$6}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.write.sectors[*],awk '{print $$7}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.write.ms[*],awk '{print $$8}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.io.active[*],awk '{print $$9}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.io.ms[*],awk '{print $$10}' /sys/class/block/$1/stat
UserParameter=custom.vfs.dev.weight.io.ms[*],awk '{print $$11}' /sys/class/block/$1/stat
2,添加python拉取值得python脚本
disk_discovery.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))
,3,将Include=/usr/local/zabbix_agents_3.2.7/*.conf放入zabbix_agent.conf的最后一行
4,重启zabbix