#! /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