/proc/diskstats 文件内容记录

[root@~]# cat /proc/diskstats  
 253       0 vda 90144 803 9693933 529654 1066806 130309 44995622 37375467 0 2045108 37904768
 253       1 vda1 90110 803 9689797 529598 1063677 130309 44995622 37374090 0 2043738 37903344
 253      16 vdb 84444 104 35914183 1997564 3078826 706159 130979564 112159744 0 16853898 114154534
 253      17 vdb1 84411 104 35910055 1997496 3076881 706159 130979564 112136786 0 16844558 114136598

这个文件用于显示磁盘、分区和统计信息
/proc/diskstats文件比/sys/block/sda/stat文件多3个域,从左至右分别对应主设备号,次设备号和设备名称。

/proc/diskstats有11(从F4开始)个字段,注意除了第9个字段(F12)之外都是累计值,从系统启动之后一直累加:

  1. (rd_ios)读操作的次数,成功完成读的总次数。
    (number of issued reads. This is the total number of reads completed successfully.)

  2. (rd_merges)合并读操作的次数。如果两个读操作读取相邻的数据块时,可以被合并成一个,以提高效率。合并的操作通常是I/O scheduler(也叫elevator)负责的。
    (number of reads merged)

  3. (rd_sectors)读取的扇区数量。
    (number of sectors read. This is the total number of sectors read successfully.)

  4. (rd_ticks)读操作消耗的时间(以毫秒为单位)。每个读操作从__make_request()开始计时,到end_that_request_last()为止,包括了在队列中等待的时间。
    (number 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()).)

  5. (wr_ios)写操作的次数,成功写完成的总次数。
    (number of writes completed. This is the total number of writes completed successfully.)

  6. (wr_merges)合并写操作的次数,合并写次数。
    (number 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.)

  7. (wr_sectors)写入的扇区数量,成功写扇区总次数。
    (number of sectors written. This is the total number of sectors written successfully.)

  8. (wr_ticks)写操作消耗的时间(以毫秒为单位),所有写操作所花费的毫秒数。
    (number 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()).)

  9. (in_flight)当前未完成的I/O数量。在I/O请求进入队列时该值加1,在I/O结束时该值减1。
    注意:是I/O请求进入队列时,而不是提交给硬盘设备时。
    (number of I/Os currently in progress. The only field that should go to zero. Incremented as requests are given to appropriate request_queue_t and decremented as they finish.)

  10. (io_ticks)该设备用于处理I/O的自然时间(wall-clock time),既花在I/O操作上的毫秒数,这个域会增长只要field 9不为0。
    (number of milliseconds spent doing I/Os. This field is increased so long as field 9 is nonzero.)
    注意io_ticks与rd_ticks(字段#4)和wr_ticks(字段#8)的区别:
    rd_ticks和wr_ticks是把每一个I/O所消耗的时间累加在一起,因为硬盘设备通常可以并行处理多个I/O,所以rd_ticks和wr_ticks往往会比自然时间大。
    而io_ticks表示该设备有I/O(即非空闲)的时间,不考虑I/O有多少,只考虑有没有。
    在实际计算时,字段#9(in_flight)不为零的时候io_ticks保持计时,字段#9(in_flight)为零的时候io_ticks停止计时。

  11. (time_in_queue)输入/输出操作花费的加权毫秒数,对字段#10(io_ticks)的加权值。
    字段#10(io_ticks)是自然时间,不考虑当前有几个I/O,而time_in_queue是用当前的I/O数量(即字段#9 in-flight)乘以自然时间。
    虽然该字段的名称是time_in_queue,但并不真的只是在队列中的时间,其中还包含了硬盘处理I/O的时间。
    iostat在计算avgqu-sz时会用到这个字段

posted @ 2020-04-08 21:15  wshenJin  阅读(348)  评论(0编辑  收藏  举报