Viewing drive load in Linux environment

Statistics on I/O operations for disk drives can be viewed with the help of iostat and pidstat commands. This will help to understand what processes expose the disk subsystem to the greatest load.

To work with these utilities, additional packages need to be installed. Installation guide:

1) Debian\Ubuntu:

apt install sysstat

2) CentOS:

yum install sysstat

'iostat' command

To view general I/O statistics for disk drives, the following command may be used:

iostat -xtc

Example command output:

$ iostat -xtc 
Linux 4.4.0-36-generic (ubuntu)         11/01/17        _x86_64_        (1 CPU)

11/01/17 17:12:42
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.75    0.09    3.40    1.83    0.00   93.93

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
fd0               0.00     0.00    0.00    0.00     0.00     0.00     8.00     0.00   60.00   60.00    0.00  60.00   0.00
sda               0.04     1.78    5.37    1.16   163.85   369.65   163.56     0.17   25.35    8.31  104.33   4.26   2.78
dm-0              0.00     0.00    5.02    2.91   156.09   369.65   132.48     0.20   25.26    8.56   54.04   3.39   2.69
dm-1              0.00     0.00    0.10    0.00     2.32     0.00    47.65     0.00    4.96    4.96    0.00   3.68   0.04

Important columns are:

  • r/s        The number of disk reads per second
  • w/s       The number of writes per disk per second
  • rkB/s   The number of kilobytes read per second
  • wkB/s   The number of kilobytes written per second

'pidstat' command

Statistics by processes can be viewed in interactive mode using the command:

pidstat -dl 5

Example command output:

$ pidstat -dl 5 Linux 4.10.0-38-generic (mad) 01.11.2017 _x86_64_ (3 CPU) 17:28:03 UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command 17:28:08 1000 1248 0,00 0,80 0,00 0 /usr/bin/plasmashell --shut-up 17:28:08 1000 1336 0,00 0,80 0,00 0 /usr/lib/chromium-browser/chromium-browser --ppapi-flash-path=/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so --ppapi-f 17:28:08 UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command 17:28:13 1000 1283 0,00 0,80 0,00 0 /usr/bin/yakuake 17:28:13 UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command 17:28:18 1000 1283 0,00 0,80 0,00 0 /usr/bin/yakuake 17:28:18 1000 1336 0,00 19,20 0,00 0 /usr/lib/chromium-browser/chromium-browser --ppapi-flash-path=/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so --ppapi-f 17:28:18 UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command 17:28:23 1000 1283 0,00 3,20 0,00 0 /usr/bin/yakuake 17:28:23 1000 1336 0,00 13,60 0,00 0 /usr/lib/chromium-browser/chromium-browser --ppapi-flash-path=/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so --ppapi-f 17:28:23 UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command 17:28:28 1000 1336 0,00 17,60 0,00 0 /usr/lib/chromium-browser/chromium-browser --ppapi-flash-path=/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so --ppapi-f 17:28:28 1000 3353 0,00 22,40 0,00 0 /usr/lib/thunderbird/thunderbird

Important columns are:

  • UID  The ID of the user on whose behalf the process is running
  • PID         Process ID
  • kB_rd/s Speed in kilobytes per second at which the process reads from the disk
  • kB_wr/s Speed in kilobytes per second at which the process writes to the disk