zabbix监控硬盘

#!/bin/bash

diskarray=(`cat /proc/diskstats |grep -E "\bsd[a-d][0-9]\b|\bsd[a-z]\b|\bxvd[a-d][0-9]\b|\bxvd[a-d]\b|\bvd[a-d][0-9]\b|\bvd[a-b]\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 "\"{#DISK_NAME}\":\"${diskarray[$i]}\"}"

        if [ $i -lt $[$length-1] ];then

                printf ','

        fi

done

printf  "\n\t]\n"

printf "}\n"


你可能感兴趣的:(zabbix监控硬盘)