在2.6内核中磁盘IO数据可直接通过内核/proc及/sysfs虚拟文件系统直接查看,方法如下:
sled11:/proc> head -n12 /proc/diskstats
8 0 sda 18231 4485 1115117 373892 6226 13988 161584 502792 0 128360 8765928 1 sda1 17483 838 1103589 355144 6186 13980 161336 499232 0 125808 854292
8 2 sda2 45 1227 1328 1360 4 1 40 988 0 2084 2348
8 3 sda3 498 132 5040 9936 15 6 168 1180 0 10516 11108
8 4 sda4 3 0 6 292 0 0 0 0 0 292 292
8 5 sda5 28 691 726 1184 0 0 0 0 0 1024 1184
8 6 sda6 106 1181 1764 2564 4 1 40 1032 0 2992 3596
8 7 sda7 24 83 856 1240 0 0 0 0 0 948 1240
8 8 sda8 22 280 1208 1384 0 0 0 0 0 1208 1384
8 16 sdb 64 1064 3480 396 0 0 0 0 0 280 396
8 17 sdb1 36 914 2056 308 0 0 0 0 0 196 308
7 0 loop0 0 0 0 0 0 0 0 0 0 0 0
sled11:/sys/block/sda> cat stat
18563 4487 1144725 377560 7897 23784 253296 629596 0 137096 1007064
sled11:/sys/block/sda> cat /sys/block/sda/stat
18563 4487 1144725 377560 7916 23792 253512 629824 0 137312 1007292
sled11:/sys/block/sda> cat /sys/block/sda/sda1/stat
17815 840 1133197 358812 7875 23787 253328 626140 0 134668 984868
域所表示意义如下:(Field 1的 /proc/diskstats的输出中从第4列开始,前面分别为主次设备号及设备名)
less Documentation/iostats.txt
This is the total number of reads completed successfully.
Field 2 -- # of reads merged, field 6 -- # of writes merged
Reads and writes which are adjacent to each other may be merged for
efficiency. Thus two 4K reads may become one 8K read before it is
ultimately handed to the disk, and so it will be counted (and queued)
as only one I/O. This field lets you know how often this was done.
Field 3 -- # of sectors read
This is the total number of sectors read successfully.
Field 4 -- # of milliseconds spent reading
This is the total number of milliseconds spent by all reads (as
measured from __make_request() to end_that_request_last()).
Field 5 -- # of writes completed
This is the total number of writes completed successfully.
Field 7 -- # of sectors written
This is the total number of sectors written successfully.
Field 8 -- # of milliseconds spent writing
This is the total number of milliseconds spent by all writes (as
measured from __make_request() to end_that_request_last()).
Field 9 -- # of I/Os currently in progress
The only field that should go to zero. Incremented as requests are
given to appropriate struct request_queue and decremented as they finish.
Field 10 -- # of milliseconds spent doing I/Os
This field increases so long as field 9 is nonzero.
Field 11 -- weighted # of milliseconds spent doing I/Os
This field is incremented at each I/O start, I/O completion, I/O
merge, or read of these stats by the number of I/Os in progress
(field 9) times the number of milliseconds spent doing I/O since the
last update of this field. This can provide an easy measure of both
I/O completion time and the backlog that may be accumulating.
iostat命今可用于显示磁盘IO情况,iostat命今包含于sysstat包中,SUSE默认没有安装,可通过zypper in systat来安装。
sled11:/sys/block/sda> iostat -d -p
Linux 2.6.32.12-0.7-pae (zmao-sled11) 2013年09月10日 _i686_
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 9.54 406.99 92.66 1144733 260632
sda1 9.26 402.90 92.58 1133205 260384
sda2 0.02 0.47 0.01 1328 40
sda3 0.18 1.79 0.06 5040 168
sda4 0.00 0.00 0.00 6 0
sda5 0.01 0.26 0.00 726 0
sda6 0.04 0.63 0.01 1764 40
sda7 0.01 0.30 0.00 856 0
sda8 0.01 0.43 0.00 1208 0
sdb 0.02 1.24 0.00 3480 0
sdb1 0.01 0.73 0.00 2056 0
sled11:/sys/block/sda> iostat -d -p -x
Linux 2.6.32.12-0.7-pae (zmao-sled11) 2013年09月10日 _i686_
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 1.59 8.64 6.58 2.94 405.95 92.58 52.34 0.36 37.61 5.20 4.95
sda1 0.30 8.64 6.32 2.92 401.86 92.50 53.49 0.35 37.89 5.26 4.86
sda2 0.44 0.00 0.02 0.00 0.47 0.01 27.92 0.00 47.92 42.53 0.07
sda3 0.05 0.00 0.18 0.01 1.79 0.06 10.15 0.00 21.67 20.50 0.37
sda4 0.00 0.00 0.00 0.00 0.00 0.00 2.00 0.00 97.33 97.33 0.01
sda5 0.25 0.00 0.01 0.00 0.26 0.00 25.93 0.00 42.29 36.57 0.04
sda6 0.42 0.00 0.04 0.00 0.63 0.01 16.40 0.00 32.69 27.20 0.11
sda7 0.03 0.00 0.01 0.00 0.30 0.00 35.67 0.00 51.67 39.50 0.03
sda8 0.10 0.00 0.01 0.00 0.43 0.00 54.91 0.00 62.91 54.91 0.04
sdb 0.38 0.00 0.02 0.00 1.23 0.00 54.38 0.00 6.19 4.38 0.01
sdb1 0.32 0.00 0.01 0.00 0.73 0.00 57.11 0.00 8.56 5.44 0.01
sled11:/sys/block/sda> iostat -c
Linux 2.6.32.12-0.7-pae (zmao-sled11) 2013年09月10日 _i686_
avg-cpu: %user %nice %system %iowait %steal %idle
8.81 0.01 2.52 2.27 0.00 86.40
iostat间隔5秒统计3次,iostat命今如下:
sled11:/sys/block/sda> iostat -c -d 5 3
Linux 2.6.32.12-0.7-pae (zmao-sled11) 2013年09月10日 _i686_
avg-cpu: %user %nice %system %iowait %steal %idle
9.54 0.00 2.55 1.93 0.00 85.97
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 7.90 327.23 79.43 1145805 278128
sdb 0.02 0.99 0.00 3480 0
avg-cpu: %user %nice %system %iowait %steal %idle
7.01 0.00 1.75 0.97 0.00 90.26
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 8.40 0.00 72.00 0 360
sdb 0.00 0.00 0.00 0 0
avg-cpu: %user %nice %system %iowait %steal %idle
2.84 0.00 1.47 0.59 0.00 95.10
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 1.00 0.00 17.60 0 88
sdb 0.00 0.00 0.00 0 0
sled11:/sys/block/sda>
首行将显示的为从系统引导后的数据。