获取磁盘IOPS数值[shell]
#!/bin/sh DISK="vdc1" function getIops(){ READ1=`cat /proc/diskstats |grep "${DISK} "|awk '{print $4}'` WRIT1=`cat /proc/diskstats |grep "${DISK} "|awk '{print $8}'` sleep 10 READ2=`cat /proc/diskstats |grep "${DISK} "|awk '{print $4}'` WRIT2=`cat /proc/diskstats |grep "${DISK} "|awk '{print $8}'` REAdioPS=$(( ($READ2-$READ1)/10 )) WRITIOPS=$(( ($WRIT2-$WRIT1)/10 )) echo DISK: $DISK,READ IOPS: $REAdioPS echo DISK: $DISK,WRIT IOPS: $WRITIOPS } getIops