The iostat command is used for monitoring system input/output device loading by observing the time that the physical disks are active in relation to their average transfer rates. This information can be used to change system configuration to better balance the input/output load between physical disks and adapters.
Below is a sample output when you run the iostat command without any arguments.
# iostat Linux 3.10.0-514.2.2.el7.x86_64 (geeklab) 11/07/2017 _x86_64_ (128 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.36 0.00 1.07 0.24 0.00 98.32 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 17.26 8.80 242.60 3795176 104664988 sdb 0.52 5.66 36.17 2440242 15603348 sdc 0.02 0.34 0.00 147313 0 sdd 0.01 0.09 0.00 39527 0 sde 0.01 0.10 0.00 41189 0 sdf 0.01 0.09 0.00 39025 0 .....
The first line displays the Linux kernel version, host name, current date, architecture, and number of CPUs on your system.
The iostat utility report has the following sections:
– CPU utilization
– Device utilization
CPU Utilization Report
The next two lines display CPU statistics. For multiprocessor systems, the CPU values are global averages among all processors. The columns are defined as follows:
%user | The percentage of CPU used while executing applications at the user level |
%nice | The percentage of CPU used while executing at the user level with nice priority |
%system | The percentage of CPU used while executing at the system (kernel) level |
%iowait | The percentage of time the CPU(s) were idle while the system had an outstanding disk I/O request |
%steal | The percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor |
%idle | The percentage of time that the CPU was (or the CPUs were) idle and the system did not have an outstanding disk I/O request |
Device Utilization Report
The remaining lines in the example display statistics on a per–physical device or per-partition basis. You can include block devices and partitions as arguments to the iostat command. If no arguments are included, the report displays all devices that the kernel has statistics for. The columns are defined as follows:
Device | Device or partition name as listed in the /dev directory |
tps | Number of transfers (I/O request) per second issued to the device |
kB_read/s | Amount of data read from the device expressed in number of kilobytes per second. |
kB_wrtn/s | Amount of data written to the device expressed in number of kilobytes per second |
kB_read | Total number of kilobytes read |
kB_wrtn | Total number of kilobytes written |
More detailed statistics can be included by providing different options to the iostat command. Some of the command-line options are listed:
-c | Display the CPU utilization report. |
-d | Display the device utilization report. |
-m | Display statistics in megabytes per second. |
-x | Display extended statistics. |
Multiple reports can be run at different intervals by using interval and count arguments. The following example displays 6 reports at 2-second intervals for all devices:
# iostat –d 2 6
Example of iostat command
Example 1 – iostat command
To view the statistics of the CPU and the input/output device’s utilization, use the following command:
# iostat Linux 3.10.0-693.21.1.el7.x86_64 (jamiericho1.mylabserver.com) 03/16/2018 _x86_64_ (1 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 5.90 0.00 2.60 1.76 2.87 86.87 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn xvda 68.90 947.14 1117.86 340222 401546 xvdf 2.76 55.51 0.00 19940 0
The first output from iostat is the sum of information since system startup. We have not specified any interval for the iostat command to run, so it will show summary informatio since the system startup by default.
Example 2 – iostat with interval
To be able to see a trend in the statistics or continuously display the statistics at a regular interval, use the iostat command with interval provided. For example, to report statistics every 5 seconds:
# iostat 5
You can also limit the number of times the statistics to be generated by providing a number of interval. For example to run the iostat command at an interval of 5 seconds with 3 intervals only:
# iostat 5 3
Example 3 – Display only CPU statistics
To display only the CPU statistics of the system use the “-c” option with iostat.
# iostat -c Linux 3.10.0-693.21.1.el7.x86_64 (jamiericho1.mylabserver.com) 03/16/2018 _x86_64_ (1 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 2.64 0.00 1.20 0.78 1.34 94.03
Example 4 – Display Disk statistics
Another useful option to use with iostat is “-d” which only shows the disk statistics of the system.
# iostat -d Linux 3.10.0-693.21.1.el7.x86_64 (jamiericho1.mylabserver.com) 03/16/2018 _x86_64_ (1 CPU) Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn xvda 28.82 389.03 465.87 340222 407421 xvdf 1.14 22.80 0.00 19940 0
Example 5 – Display Extended statistics
To display an extended statistics with iostat use the “-x” option. For example,
# iostat -x Linux 3.10.0-693.21.1.el7.x86_64 (jamiericho1.mylabserver.com) 03/16/2018 _x86_64_ (1 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 1.52 0.00 0.71 0.45 0.83 96.50 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util xvda 0.03 1.57 11.38 6.75 242.60 288.58 58.59 0.17 9.13 0.91 23.00 0.42 0.76 xvdf 0.00 0.00 0.70 0.00 14.10 0.00 40.16 0.00 2.84 2.84 0.00 2.15 0.15
Example 6 – Combining various options
You can always combine several options from the exampeles shown above. With this you can display a extended disk utilization report at an interval of 2 seconds for 3 intervals, as shown in the example below.
# iostat -xdt 2 3 Linux 3.10.0-693.21.1.el7.x86_64 (jamiericho1.mylabserver.com) 03/16/2018 _x86_64_ (1 CPU) 03/16/2018 04:57:55 AM Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util xvda 0.03 1.45 10.47 6.23 223.11 265.50 58.53 0.15 9.12 0.91 22.93 0.42 0.70 xvdf 0.00 0.00 0.65 0.00 12.96 0.00 40.16 0.00 2.84 2.84 0.00 2.15 0.14 03/16/2018 04:57:57 AM Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util xvda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 03/16/2018 04:57:59 AM Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util xvda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Here,
-t – display the timestamp of the interval