1,iolog的文件格式
root@demo-1:~/flash_seq# cat iolog |head
fio version 2 iolog
/dev/mapper/cachedev add
/dev/mapper/cachedev open
/dev/mapper/cachedev read 0 4096
/dev/mapper/cachedev read 4096 4096
/dev/mapper/cachedev read 8192 4096
/dev/mapper/cachedev read 12288 4096
/dev/mapper/cachedev read 16384 4096
/dev/mapper/cachedev read 20480 4096
/dev/mapper/cachedev read 24576 4096
root@demo-1:~/flash_seq# cat iolog |tail
/dev/mapper/cachedev read 39075840 4096
/dev/mapper/cachedev read 39079936 4096
/dev/mapper/cachedev read 39084032 4096
/dev/mapper/cachedev read 39088128 4096
/dev/mapper/cachedev read 39092224 4096
/dev/mapper/cachedev read 39096320 4096
/dev/mapper/cachedev read 39100416 4096
/dev/mapper/cachedev read 39104512 4096
/dev/mapper/cachedev read 39108608 4096
2,Financial文件格式
root@demo-1:~/flash_seq# cat Financial|head
0,303567,3584,w,0.000000
1,55590,3072,w,0.000000
0,303574,3584,w,0.026214
1,240840,3072,w,0.026214
1,55596,3072,r,0.078643
0,303581,3584,w,0.117964
1,55596,3072,w,0.117964
0,303588,3584,w,0.530841
1,55596,3072,w,0.530841
0,303595,3584,w,0.550502
$1 Application specific unit (ASU) 设备号
$2 Logical block address (LBA) 逻辑块地址
$3 Size 请求的数据长度
$4 Opcode 读请求或者写请求,WebSearch中只有读请求,Financial
$5 Timestamp 请求下达的时间戳
3,解析
统计第一列的磁盘阵列情况
awk 'BEGIN{FS=","};{print $1}' Financial1| sort |uniq -c|head
153566 0
435222 1
779517 10
设备请求最大逻辑块统计
root@demo-1:~/flash_seq# awk 'BEGIN{FS=",";max=0};{if($1==0&&$2>max){max=$2}};END{print max}' Financial1
500363
root@demo-1:~/flash_seq# awk 'BEGIN{FS=",";max=0};{if($1==1&&$2>max){max=$2}};END{print max}' Financial1
1351642016
由此可以推断出:
我们至少需要1351642016×512B的磁盘空间才能满足trace的需求。因为一个扇区512B,换算下来:需要空间就是1351642016/2 (KB)
也就是说给出的地址其实是逻辑扇区地址,而不是真正的物理地址。
请求块大小:
root@demo-1:~/flash_seq# awk 'BEGIN{FS=","};{print $3}' Financial1| sort |uniq -c| head
38 0
679197 1024
9078 10240
1 102912
1467 10752
根据SPC文档的规范,size的单位是byte,例如:65536byte为64k。这样也就说通了。
运行时间:
root@demo-1:~/flash_seq# awk 'BEGIN{FS=",";max=0};{if($5>max){max=$5}};END{print max}' Financial1
43712.242187
或者直接 tail 就行
根据SPC文档的规范,时间的单位为s,可以看到实际上只是系统运行了12小时的纪录。
提取指定列
awk 'BEGIN{FS=","};{print $2, $3, $4 }' Financial1 >>Financial02
396047 3584 w
753921 3072 w
753921 3072 w
68566 3072 w
60382 2560 w
更改指定列
root@demo-1:~/flash_seq# awk 'BEGIN{FS=" "};{if($3~/r/) {$3="read"} else {$3="write"} print }' Financial02 |tail
94970 2048 read
129870 2560 write
145658 2048 write
awk 'BEGIN{FS=" "};{if($3~/r/) {$3="read"} else {$3="write"} print }' Financial02 >>Financial03
格式规划
awk 'BEGIN{FS=" "};{ {$4="/dev/mapper/cachedev"} print $4,$3,$1,$2 }' Financial03 |head
/dev/mapper/cachedev write 303567 3584
/dev/mapper/cachedev write 55590 3072
/dev/mapper/cachedev write 303574 3584
/dev/mapper/cachedev write 240840 3072
/dev/mapper/cachedev read 55596 3072
/dev/mapper/cachedev write 303581 3584
/dev/mapper/cachedev write 55596 3072
/dev/mapper/cachedev write 303588 3584
/dev/mapper/cachedev write 55596 3072
/dev/mapper/cachedev write 303595 3584
awk 'BEGIN{FS=" "};{ {$4="/dev/mapper/cachedev"} print $4,$3,$1,$2 }' Financial03 >>Financial04
添加行首和行尾
awk 'BEGIN{FS=" "};{if(NR==1) {$1="fio";$2="version";$3="2";$4="iolog"} print }' Financial04 |head
awk 'BEGIN{FS=" "};{if(NR==2) {$2="add";$3="";$4=""} print }' Financial04 |head
awk 'BEGIN{FS=" "};{if(NR==3) {$2="open";$3="";$4=""} print }' Financial04 |head
root@demo-1:~/flash_seq# cat Financial04 |wc -l
5334987
root@demo-1:~/flash_seq# awk 'BEGIN{FS=" "};{if(NR==5334987) {$2="close";$3="";$4=""} print }' Financial04 |tail
结束