Learn a Linux command every day (109): iostat

Time:2021-9-19

Command introduction

The iostat command is used to count system IO status information.

Syntax format

iostat [options]

Option description

-c   # Show CPU usage only
-d   # Show device utilization only
-k   # Display status in kilobytes per second instead of blocks per second
-m   # Display status in megabytes per second
-p   # Displays only the status of block devices and all other partitions used
-t   # Displays the time when each report was generated
-V   # Display version number and exit
-x   # Show extended status

Application examples

View the IO status information of the specified device

[[email protected] ~]# iostat -x /dev/sda1
Linux 3.10.0-1127.18.2.el7.x86_64 (centos7)  03/28/2021  _x86_64_ (1 CPU)
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.59    0.00    0.55    0.05    0.00   97.81
Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sda1              0.00     0.00    0.04    0.00     0.15     0.05     8.82     0.00    1.07    0.73   63.50   1.02   0.00

Result field description

Device   # Name of monitoring equipment
rrqm/s   # Number of read requirements per second
wrqm/s   # Number of write requirements per second
r/s      # Number of actual read requirements per second
w/s      # Number of actual write requirements per second
rsec/s   # Number of read segments per second
wsec/s   # Number of extents written per second
rkB/s    # The size actually read per second, in kilobytes
wkB/s    # The size of the actual writes per second, in kilobytes
avgrq-sz   # Average size segment of demand
avgqu-sz   # Average queue length of demand
await      # Average waiting time for I / O (milliseconds)
svctm      # Average time to complete I / O requirements
%util      # Percentage of CPU consumed by I / O requirements

Overall system IO status information

[[email protected] ~]# iostat
Linux 3.10.0-1127.18.2.el7.x86_64 (centos7)  03/28/2021  _x86_64_ (1 CPU)
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.58    0.00    0.55    0.05    0.00   97.82
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.25         7.39         1.84     316339      78930
sdb               0.00         0.06         0.00       2592          0
scd0              0.00         0.02         0.00       1028          0
dm-0              0.21         7.11         1.80     304267      76862
dm-1              0.00         0.05         0.00       2204          0

Other examples

#Displays only the IO status of the CPU
[[email protected] ~]# iostat -c
Linux 3.10.0-1127.18.2.el7.x86_64 (centos7)  03/28/2021  _x86_64_ (1 CPU)
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.58    0.00    0.55    0.05    0.00   97.82
#Only the usage status of the device is displayed
[[email protected] ~]# iostat -d
Linux 3.10.0-1127.18.2.el7.x86_64 (centos7)  03/28/2021  _x86_64_ (1 CPU)
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.25         7.38         1.84     316339      78930
sdb               0.00         0.06         0.00       2592          0
scd0              0.00         0.02         0.00       1028          0
dm-0              0.21         7.09         1.79     304267      76862
dm-1              0.00         0.05         0.00       2204          0
#Display in kilobytes per second
[[email protected] ~]# iostat -k
Linux 3.10.0-1127.18.2.el7.x86_64 (centos7)  03/28/2021  _x86_64_ (1 CPU)
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.58    0.00    0.55    0.05    0.00   97.82
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.25         7.37         1.84     316339      78930
sdb               0.00         0.06         0.00       2592          0
scd0              0.00         0.02         0.00       1028          0
dm-0              0.21         7.09         1.79     304267      76862
dm-1              0.00         0.05         0.00       2204          0
#In megabytes per second
[[email protected] ~]# iostat -m
Linux 3.10.0-1127.18.2.el7.x86_64 (centos7)  03/28/2021  _x86_64_ (1 CPU)
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.58    0.00    0.55    0.05    0.00   97.82
Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sda               0.25         0.01         0.00        308         77
sdb               0.00         0.00         0.00          2          0
scd0              0.00         0.00         0.00          1          0
dm-0              0.21         0.01         0.00        297         75
dm-1              0.00         0.00         0.00          2          0

Learn a Linux command every day (106): OpenSSL

Learn a Linux command every day (107): SAR

Learn a Linux command every day (108): iptraf