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:

Linux 2.6.32-042stab128.2 ()   10/17/18        _x86_64_        (32 CPU)

04:42:57      UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s iodelay  Command
04:43:02        0       234     40.00      0.00      0.00       2  /usr/sbin/cron -f
04:43:52      106       232      0.00      1.60      0.00       0  /usr/sbin/rsyslogd -n

Average:      UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s iodelay  Command
Average:      106       232      0.00      0.11      0.00       0  /usr/sbin/rsyslogd -n
Average:        0       234      2.67      0.00      0.00       0  /usr/sbin/cron -f

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