5fcc740558a82127.jpg_fo742.png

#! /bin/bash

diskio=`iostat -d -k | grep -v Linux| grep -v Device | awk '{if($0!="")print}'`
# awk 'BEGIN{sum=0}{sum+=$1}END{print sum}' 
i=1
parent=
capacity=0

for property in $diskio
do
    t=$(($i%6))
    if [ $t = 0 ];then
        str="$str,'kB_wrtn':'$property','os':'linux','name':'(linux)硬盘IO监控模板'"
        str="${str#*,}"
        parent="$parent{$str},"
        str=
        i=0
    else
        case $i in 
            1)
                str="$str,'cpname':'diskio','flag':'$property'"
                #str="$str,'path':'$property'"
            ;;
            2)
                str="$str,'tps':'$property'"
            ;;
            3)
                str="$str,'kB_read/s':'$property'"
            ;;
            4)
                str="$str,'kB_wrtn/s':'$property'"
            ;;
            5)
                str="$str,'kB_read':'$property'"
            ;;
        esac
    fi
    i=$(($i+1))
done

result="[${parent%,*}]"
result=`echo ${result//\'/\"}`
echo $result





发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code