fio数据生成曲线图

1、背景

我们常常在测试fio的时候,一般只会看到最终测试结果。如下所示

[root@localhost zhangyi]# fio --filename=test_file  --direct=1 --rw=randwrite --numjobs=1 --iodepth=16 --ioengine=libaio  --bs=4k --group_reporting --name=zhangyi --log_avg_msec=500 --write_bw_log=test-fio --size=1G
zhangyi: (g=0): rw=randwrite, bs=4K-4K/4K-4K/4K-4K, ioengine=libaio, iodepth=16
fio-2.2.8
Starting 1 process
zhangyi: Laying out IO file(s) (1 file(s) / 1024MB)
Jobs: 1 (f=1): [w(1)] [100.0% done] [0KB/49649KB/0KB /s] [0/12.5K/0 iops] [eta 00m:00s]
zhangyi: (groupid=0, jobs=1): err= 0: pid=3143: Wed Aug 30 15:37:18 2017
write: io=1024.0MB, bw=48438KB/s, iops=12109, runt= 21648msec
slat (usec): min=2, max=8200, avg=59.44, stdev=75.52
clat (usec): min=42, max=17377, avg=1259.63, stdev=847.23
 lat (usec): min=122, max=17383, avg=1319.47, stdev=862.50
clat percentiles (usec):
 |  1.00th=[  580],  5.00th=[  652], 10.00th=[  692], 20.00th=[  780],
 | 30.00th=[  860], 40.00th=[  948], 50.00th=[ 1048], 60.00th=[ 1160],
 | 70.00th=[ 1256], 80.00th=[ 1368], 90.00th=[ 2224], 95.00th=[ 2864],
 | 99.00th=[ 3824], 99.50th=[ 4384], 99.90th=[10688], 99.95th=[13376],
 | 99.99th=[16064]
bw (KB  /s): min=43072, max=52968, per=99.85%, avg=48362.74, stdev=2721.66
lat (usec) : 50=0.01%, 250=0.02%, 500=0.25%, 750=16.72%, 1000=29.09%
lat (msec) : 2=41.80%, 4=11.37%, 10=0.60%, 20=0.14%
 cpu          : usr=1.19%, sys=71.85%, ctx=80337, majf=0, minf=31
 IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=100.0%, 32=0.0%, >=64=0.0%
 submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
 complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.1%, 32=0.0%, 64=0.0%, >=64=0.0%
 issued    : total=r=0/w=262144/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0
 latency   : target=0, window=0, percentile=100.00%, depth=16
 Run status group 0 (all jobs):
 WRITE: io=1024.0MB, aggrb=48437KB/s, minb=48437KB/s, maxb=48437KB/s, mint=21648msec, maxt=21648msec
 Disk stats (read/write):
dm-0: ios=2/263339, merge=0/0, ticks=130/102093, in_queue=102223, util=93.14%, aggrios=2/270086, aggrmerge=0/18, aggrticks=130/100523, aggrin_queue=100545, aggrutil=92.82%

这样只能看到一个结果,而中间过程的IO情况则看不到。所以这里介绍一个方法,可以将fio中间过程的数据抓出来绘制成图的方法。

2、安装gnuplot
sudo yum install gnuplot

最终回安装两个包:

[root@localhost zhangyi]# rpm -qa |grep gnuplot
gnuplot-common-4.6.2-3.el7.x86_64
gnuplot-4.6.2-3.el7.x86_64
3、对一个文件执行fio操作
fio --filename=test_file  --direct=1 --rw=randwrite --
numjobs=1 --iodepth=16 --ioengine=libaio  --bs=4k 
--group_reporting --name=zhangyi --log_avg_msec=500 
--write_bw_log=test-fio --size=1G

这里需要说明下的就是write_bw_log这个参数需要指定,意思就是将fio的输出带宽信息就到文件test-fio中。这里可以指定带宽,IOPS和延时

write_bw_log=fio-test
write_iops_log=fio-test
write_lat_log=fio-test

运行完成后可以生成如下文件:

-rw-r--r--.  1 root root  797 Aug 30 15:37 test-fio_bw.1.log

这个文件就记录了fio运行期间的带宽数据。

[root@localhost zhangyi]# cat test-fio_bw.1.log
500, 50648, 1, 0
1000, 49328, 1, 0
1500, 49096, 1, 0
2000, 49824, 1, 0
2500, 51120, 1, 0
3000, 47472, 1, 0
3500, 49976, 1, 0

这里表示每log_avg_msec=500ms记录一次。这个参数也可以调整。

绘图

将这个test-fio_bw.1.log修改成test-fio_bw.log,因为fio2gnuplot会默认在当前目录下寻找*_bw.log文件。

[root@localhost zhangyi]# fio2gnuplot -b -g
1 files Selected with pattern '*_bw.log'
 |-> test-fio_bw.log
 Running gnuplot Rendering
 Rendering traces are available in the current directory

这里b的意思就是绘制带宽的图,-i则表示绘制iops的图,但是貌似现在gnuplot不支持iops和latency的绘制。不要在乎这些细节。执行完成后会生成如下几个文件:

-rw-r--r--.  1 root root  13K Aug 30 15:51 test-fio_bw-2Draw.png
-rw-r--r--.  1 root root  12K Aug 30 15:51 test-fio_bw-2Dsmooth.png
-rw-r--r--.  1 root root  10K Aug 30 15:51 test-fio_bw-2Dtrend.png
打开文件

这里写图片描述

也可以用fio_generate_plots bw的方式来生成图像

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值