fio测试和分析
fio测试脚本
#!/bin/bashset -e
ioengine="libaio"
iodepth=128
direct=1
fsync=1
runtime=600
size="10G"
mntdir="/mnt/fio-data/"
mkdir -p /mnt/fio-data
mount /dev/vdb /mnt/fio-data || true
for m in seq rand
do
prefix=""
if [ "$m" == "seq" ] ; then
bs="1024K"
else
bs="4K"
prefix="rand"
fi
for op in read write
do
cat <<EOF >$mntdir/fio-$m-$op.fio
[global]
fsync=$fsync
name=fio-$m-$op
filename=fio-$m-$op
rw=$prefix$op
bs=$bs
direct=$direct
numjobs=1
time_based=1
runtime=$runtime
[file1]
size=$size
ioengine=$ioengine
iodepth=$iodepth
EOF
done
done
docker rm -f $(docker ps -a -q) >/dev/null 2>&1|| true
echo "test case: $c"
outdir=`pwd`/result-`date "+%Y%m%d%H%M"`
mkdir -p $outdir
for p in `ls -1 $mntdir/*.fio`
do
f=`basename $p`
echo 3 > /proc/sys/vm/drop_caches
cmd="docker run --name=$f -v $mntdir:/tmp/fio-data -e JOBFILES=/tmp/fio-data/$f
clusterhq/fiotools-aio bash /opt/run.sh
| tee -a $outdir/$f.log"
echo $cmd
eval $cmd
sleep 1
done
提取iops和bw
#!/usr/bin/python2.7import os
import re
from pathlib import Path
def get_perf(file, type, perf):
m = re.compile("s*{}s*: .* {}=(d+)".format(type, perf))
with open(file) as f:
for line in f.readlines():
g = m.search(line)
if g is not None and len(g.groups()) == 1:
return g.groups()[0]
raise Exception("{} {} not found".format(type, perf))
def parse(dir, perf):
data = []
perf_type = "rand" if perf == "iops" else "seq"
dirs = Path(dir).glob("result-*/")
for d in dirs:
f = os.path.join(d.name, "fio-%s-read.fio.log" % perf_type)
read = get_perf(f, "read", perf)
f = os.path.join(d.name, "fio-%s-write.fio.log" % perf_type)
write = get_perf(f, "write", perf)
data.append((read, write))
return data
if __name__ == "__main__":
cwd = os.path.dirname(os.path.realpath(__file__))
data = parse(cwd, "iops")
with open("iops.txt", "w") as f:
i = 1
for l in data:
f.write("{} {} {}
".format(i, l[0], l[1]))
i = i + 1
data = parse(cwd, "bw")
with open("bw.txt", "w") as f:
i = 1
for l in data:
f.write("{} {} {}
".format(i, l[0], l[1]))
i = i + 1
gunplot画图
- iops
#!/bin/bashdata=iops.txt
pic=iops.png
/usr/local/bin/gnuplot << EOF
set autoscale # scale axes automatically
set xtic 1 # set xtics automatically
set ytic 1000 # set ytics automatically
set title "IOPS over Time"
set xlabel "samples over time"
set ylabel "iops"
set grid
set term png medium
set term png size 953, 620
set key box top left
set output "$pic"
plot "$data" using 1:2 title "read" with linespoints,
"$data" using 1:3 title "write" with linespoints
quit
EOF
以上是 fio测试和分析 的全部内容, 来源链接: utcz.com/z/517533.html