EyeDm
EyeDm

Reputation: 13

I can not calculate length of disk queue in Linux

I do not need to use any side tool like "iostat". I need to calculate length of the disk queue by raw data, which can be gathered from "/proc/diskstats" for example.

I investigated the source code of iostat utility to get the way it use to calculate average disk queue length. The utility uses 11-th field of "/sys/block/<device>/stat" file. This field stands for "weighted time spent doing I/Os (ms)". The utility calculates time derivative of the field. I tried to calculate it by myself and compare the result with "iostat" output. I have got different values. What a did:

  1. Execute command "cat /sys/block/sda/stat & iostat -x";
  2. Wait for 10 seconds;
  3. Execute command "cat /sys/block/sda/stat & iostat -x";
  4. Calculate the difference between the 11-th field of "/sys/block/sda/stat" file and divide the result by 10 and then to 1000 (because of milliseconds);
  5. Compare the result with the last output of "iostat -x" command.

Also, I tried to search sources, which could give out information about I/O operations, but I found only information about the amount of I/O operations executed in real-time. Unfortunately, it is not enough to calculate a disk queue length or an average disk queue length.

Upvotes: 0

Views: 228

Answers (1)

EyeDm
EyeDm

Reputation: 13

Actually, my algorithm of calculation was right. I just had to make some load on disk (e.g. copy a big file) to see difference. If someone would try to compare your own result with the output of "iostat", then you better run two terminals because of convenience. One terminal for reading file "/proc/diskstats" and the other terminal for executing "iostat -x 10" (where 10 is how often data updates in seconds).

Upvotes: 0

Related Questions