ubuntu 中 /proc/diskstats 的输出

ubuntu 中 /proc/diskstats 的输出

有人能告诉我 /proc/diskstats 中的第 11 个字段吗?文档说它是执行 I/O 所花费的毫秒数的加权值。它是否像每秒执行 DiskIO 所花费的毫秒数?

我每 200 毫秒减去前一个值,记录一次这个值,结果发现这个值高达 7000。我需要绘制一个显示磁盘 IO 速率的图表。脚本如下:

#!/bin/bash

PREV_TOTAL=0

echo "" >> $1
while true; do

  numbers=( $(tail -3 < /proc/diskstats | head -2 | awk '{print $14}' ) )  ; 
  let "TOTAL=$((${numbers[0]} + ${numbers[1]}))"
  let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
  time=`date +%s%N`
  echo "$time $DIFF_TOTAL" >> $1
  PREV_TOTAL="$TOTAL"
# Wait before checking again.
  sleep 0.2
done

有人能解释一下这个领域吗?

答案1

来自文档

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.

该字段的增量为执行 IO 所花费的时间乘以正在进行的 IO 请求数,因此它是按活动请求数加权的时间。它考虑了 IO 队列的大小。

例如,一台机器在最后一秒不断进行 IO,但队列从未超过 1 个请求,其值为 1000。一台机器在最后一秒也不断进行 IO,但平均队列长度为 10 个请求,其值为 10 000。

答案2

从: http://www.mjmwired.net/kernel/Documentation/iostats.txt

字段 11 — 执行 I/O 所花费的加权毫秒数:

    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.

相关内容