disk_scan.sh
#!/bin/bash diskarray=(`cat /proc/diskstats |grep -E "sd[abcdefg]|vd[abcdefg]|nvme0n1"|grep -i "$1"|awk '{print $3}'|sort|uniq 2>/dev/null`) length=${#diskarray[@]} printf "{ " printf ' '""data":[" for ((i=0;i<$length;i++)) do printf ' {' printf ""{#DISKNAME}":"${diskarray[$i]}"}" if [ $i -lt $[$length-1] ];then printf ',' fi done printf " ] " printf "} "
mykey.conf
# 磁盘IO UserParameter=io.scandisk[*],/usr/local/zabbix/etc/zabbix_agentd.conf.d/scripts/disk_scan.sh $1 UserParameter=io.rps[*],/usr/bin/tail /tmp/iostat_output |grep "$1"|tail -1|awk '{print $$4}' UserParameter=io.wps[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$5}' UserParameter=io.rKBps[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$6}' UserParameter=io.wKBps[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$7}' UserParameter=io.avgrq-sz[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$8}' UserParameter=io.avgqu-sz[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$9}' UserParameter=io.await[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$10}' UserParameter=io.r_await[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$11}' UserParameter=io.w_await[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$12}' UserParameter=io.svctm[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$13}' UserParameter=io.util[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$14}