代码改变世界

<转>Shell脚本相关

2012-06-26 21:02  Demote  阅读(1552)  评论(0编辑  收藏  举报

转自:Jarvis Wang http://blog.chinaunix.net/uid/20560052.html

FIO测试脚本


FIO是一个UNIX环境下的硬盘和阵列性能测试工具,具有丰富的参数,可以调用各种各样的读写函数进行测试,帮助文档参见:http://www.cse.unsw.edu.au/~aaronc/iosched/doc/fio.1.html

下面是我写的两个FIO测试脚本,一个用于随机I/O测试,一个用于多路顺序I/O测试:

random_io_test.sh
----------------------------------------------------------------------------
target=$1
size=`cat /proc/partitions | grep $target | awk '{print $3}'`
model=`lsscsi | grep $target$ | awk '{printf "%s_%s",$4,$5}'`

echo "CASEID,IOPS,RIOPS,RLAT,WIOPS,WLAT" | tee $model.$target.random.csv
echo '' > $model.$target.random.log

cp libaio.so.1 /lib64/

for read in 0 20 40 60 80 100
do
    for block in 4 8 16 32
    do
        for queue in 1 2 4 8 16
        do
            name=R_${read}R_${block}K_${queue}Q
            ./fio --name=$name --rw=randrw --direct=1 --norandommap --ioengine=libaio --runtime=60s --ioscheduler=noop --size=${size}k --filename=/dev/$target  --rwmixread=$read --bs=${block}k --iodepth=$queue --minimal >> $model.$target.random.log
            tail -2 $model.$target.random.log | awk -F ";" -v BLOCK=$block '/K/{printf "%s,%.2f,%.2f,%.2f,%.2f,%.2f\n",$1,($5+$21)/BLOCK,$5/BLOCK,$13/1000,$21/BLOCK,$29/1000}' | tee -a $model.$target.random.csv

        done #end queue depth
    done #end block size
done #end read percent
----------------------------------------------------------------------------

sequential_io_test.sh
----------------------------------------------------------------------------
target=$1
size=`cat /proc/partitions | grep $target | awk '{print $3}'`
model=`lsscsi | grep $target$ | awk '{printf "%s_%s",$4,$5}'`

echo "CASEID,MBPS,RMBPS,RLAT,WMBPS,WLAT" | tee $model.$target.seqential.csv
echo '' > $model.$target.seqential.log

cp libaio.so.1 /lib64/

for read in 0 20 40 60 80 100
do
    for block in 64 128 256 512
    do
        for stream in 1 2 4 8 16
        do
            name=S_${read}R_${block}K_${stream}S
            ./fio --name=$name -rw=rw --direct=1 --ioengine=libaio --runtime=60s --ioscheduler=noop --filename=/dev/$target --rwmixread=$read --bs=${block}k --iodepth=1 --zonesize=$[size/stream]k --numjobs=$stream --group_reporting --minimal >> $model.$target.seqential.log
            tail -2 $model.$target.seqential.log | awk -F ";" '/K/{printf "%s,%.2f,%.2f,%.2f,%.2f,%.2f\n",$1,($5+$21)/1024,$5/1024,$13/1000,$21/1024,$29/1000}' | tee -a $model.$target.seqential.csv

        done #end queue depth
    done #end block size
done #end read percent
----------------------------------------------------------------------------

 

Shell编程相关资料

Bash新手指南 http://xiaowang.net/bgb-cn/
Linux Shell Scripting Tutorial v1.05r3http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/lsst/
awk使用详细 http://blog.chinaunix.net/u/10047/showart_408156.html
Linux Shell编程 http://tech.sina.com.cn/c/1073.html
Linux系统用户账号的管理 http://it.sohu.com/2004/06/09/67/article220456718.shtml
文件和目录访问权限设置 http://www.linuxsir.org/main/?q=node/112