disk_scan.shios
#!/bin/bash diskarray=(`cat /proc/diskstats |grep -E "\bsd[abcdefg]\b|\bvd[abcdefg]\b|\bnvme0n1\b"|grep -i "\b$1\b"|awk '{print $3}'|sort|uniq 2>/dev/null`) length=${#diskarray[@]} printf "{\n" printf '\t'"\"data\":[" for ((i=0;i<$length;i++)) do printf '\n\t\t{' printf "\"{#DISKNAME}\":\"${diskarray[$i]}\"}" if [ $i -lt $[$length-1] ];then printf ',' fi done printf "\n\t]\n" printf "}\n"
mykey.confbash
# 磁盤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 "\b$1\b"|tail -1|awk '{print $$4}' UserParameter=io.wps[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$5}' UserParameter=io.rKBps[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$6}' UserParameter=io.wKBps[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$7}' UserParameter=io.avgrq-sz[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$8}' UserParameter=io.avgqu-sz[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$9}' UserParameter=io.await[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$10}' UserParameter=io.r_await[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$11}' UserParameter=io.w_await[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$12}' UserParameter=io.svctm[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$13}' UserParameter=io.util[*],/usr/bin/tail /tmp/iostat_output |grep "\b$1\b" |tail -1|awk '{print $$14}