One Linux command a day (42): iostat command

1, Introduction

Iostat under Linux system is the abbreviation of I/O statistics. Iostat tool will monitor the disk operation activities of the system. It is characterized by reporting disk activity statistics and CPU usage. Like vmstat, iostat also has a weakness, that is, it can not deeply analyze a process, but only the overall situation of the system

iostat is also a sysstat package. If it is not installed on the system, you can install it through sudo yum install sysstat.

2, Format description

iostat [ options ] [ <interval> [ <count> ] ]
iostat [parameter] [equipment]

Usage: iostat [ options ] [ <interval> [ <count> ] ]
Options are:
[ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ]
[ -j { ID | LABEL | PATH | UUID | ... } ]
[ [ -T ] -g <group_name> ] [ -p [ <device> [,...] | ALL ] ]
[ <device> [...] | ALL ]

3, Option description

-c	Show only CPU Usage

-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	Display the time when each report is generated, and display the terminal and CPU Information about

-C display CPU Usage

-N Display disk array(LVM) information

-n display NFS Usage

-x Show details

-V display version information

4, Command function

Monitor the usage of system I / O devices and CPU

5, Common usage

5.1 display all equipment loads

# iostat

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.29    0.00    0.28    0.03    0.00   99.41

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               4.49         0.23        38.16    4811702  807627360
scd0              0.00         0.00         0.00       6218          0

explain:
cpu Attribute value Description:

%user: CPU Percentage of time in user mode.

%nice: CPU In zone NICE Value is the percentage of time in user mode.

%system: CPU Percentage of time in system mode.

%iowait: CPU Percentage of time waiting for input and output to complete.

%steal: When the hypervisor maintains another virtual processor, the virtual processor CPU Percentage of unconscious waiting time.

%idle: CPU Percentage of idle time.

Note: if the value of% iowait is too high, it indicates that the hard disk has an I/O bottleneck. If the value of% idle is high, it indicates that the CPU is idle. If the value of% idle is high but the system response is slow, it may be that the CPU is waiting to allocate memory. At this time, the memory capacity should be increased.% n If the idle value is continuously lower than 10, the CPU processing capacity of the system is relatively low, indicating that the most resource to be solved in the system is CPU.

5.2 report every two seconds

# iostat -d 2

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               4.49         0.23        38.16    4811702  807614084
scd0              0.00         0.00         0.00       6218          0

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               0.00         0.00         0.00          0          0
scd0              0.00         0.00         0.00          0          0

5.3 report every 2 seconds for 5 times

# iostat -d 2 5

5.4 display the statistical data of sda and sdc, and report once every 2 seconds for 5 times

# iostat -x sda sdc 2 5

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.29    0.00    0.28    0.03    0.00   99.41

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.75    0.00    0.25    0.13    0.00   98.87

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           2.00    0.00    0.50    0.00    0.00   97.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

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.13    0.00    0.25    0.00    0.00   99.62

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           4.64    0.00    1.76    0.63    0.00   92.97

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util

5.4 display specified disk information

# iostat -d vda

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               4.49         0.23        38.16    4811702  807633036

5.5 display tty and Cpu Information

iostat -t

11/23/2021 06:10:56 PM
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.29    0.00    0.28    0.03    0.00   99.41

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               4.49         0.23        38.16    4811702  807635384
scd0              0.00         0.00         0.00       6218          0

5.6 display all information in M

# iostat -m

Linux 3.10.0-1127.19.1.el7.x86_64 (service-01)  11/23/2021      _x86_64_        (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.29    0.00    0.28    0.03    0.00   99.41

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
vda               4.49         0.00         0.04       4698     788707
scd0              0.00         0.00         0.00          6          0

5.7 viewing TPS and throughput information

# iostat -d -k 1 5

Linux 3.10.0-1127.19.1.el7.x86_64 (service-01)  11/23/2021      _x86_64_        (4 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               4.49         0.23        38.16    4811702  807638408
scd0              0.00         0.00         0.00       6218          0

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               2.00         0.00       132.00          0        132
scd0              0.00         0.00         0.00          0          0

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               0.00         0.00         0.00          0          0
scd0              0.00         0.00         0.00          0          0

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               0.00         0.00         0.00          0          0
scd0              0.00         0.00         0.00          0          0

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               0.00         0.00         0.00          0          0
scd0              0.00         0.00         0.00          0          0

explain

tps: Indicate the number of transfers per second that were issued to the device. "One transmission" means "one I/O request". Multiple logical requests may be merged into one I/O request. The size of the one pass request is unknown.

kB_read/s: the amount of data read from the device (drive expressed) per second;

kB_wrtn/s: the amount of data written to the device (drive expressed) per second;

kB_read: total data read; kB_wrtn: total number of data written;

These units are Kilobytes.

5.8 check equipment utilization (% util) and response time (await)

# iostat -d -x -k 1 5

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.00     2.91    0.01    4.48     0.23    38.16    17.11     0.02    5.14   20.56    5.10   0.32   0.14
scd0              0.00     0.00    0.00    0.00     0.00     0.00   100.29     0.00    0.54    0.54    0.00   0.36   0.00

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               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
scd0              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

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               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
scd0              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

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.00    19.00    0.00    4.00     0.00   124.00    62.00     0.01    2.50    0.00    2.50   1.25   0.50
scd0              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

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               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
scd0              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


rrqm/s:   Per second merge Number of read operations.Namely delta(rmerge)/s

wrqm/s:  Per second merge Number of write operations.Namely delta(wmerge)/s

r/s:   Reads completed per second I/O Equipment times.Namely delta(rio)/s

w/s:   Writes completed per second I/O Equipment times.Namely delta(wio)/s

rsec/s:   Sectors read per second.Namely delta(rsect)/s

wsec/s:  Number of sectors written per second.Namely delta(wsect)/s

rkB/s:   Reads per second K Number of bytes.yes rsect/s Half of,Because the size of each sector is 512 bytes.(Need calculation)

wkB/s:   Write per second K Number of bytes.yes wsect/s Half of.(Need calculation)

avgrq-sz: Average per device I/O Data size of the operation (a sector).delta(rsect+wsect)/delta(rio+wio)

avgqu-sz: average I/O queue length .Namely delta(aveq)/s/1000 (because aveq Is in milliseconds).

await:   Average per device I/O Wait time for operation (millisecond).Namely delta(ruse+wuse)/delta(rio+wio)

svctm:  Average per device I/O Service time of operation (millisecond).Namely delta(use)/delta(rio+wio)

%util:  What percentage of a second is spent I/O operation,Or how much time is there in a second I/O The queue is not empty, i.e delta(use)/s/1000 (because use Is in milliseconds)
If %util Close to 100%,Description generated I/O Too many requests, I/O The system is full, and the disk may have a bottleneck.
idle Less than 70% IO The pressure is large. Generally, the reading speed has more wait. 
At the same time, it can be combined vmstat View view b parameter(Number of processes waiting for resources)and wa parameter(IO Waiting for occupied CPU Percentage of time, higher than 30%Time IO High pressure). 

5.9 viewing cpu status

# iostat -c 2 5

Linux 3.10.0-1127.19.1.el7.x86_64 (service-01)  11/23/2021      _x86_64_        (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.29    0.00    0.28    0.03    0.00   99.41

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.25    0.00    0.13    0.00    0.00   99.62

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.13    0.00    0.00   99.87

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.25    0.00    0.13    0.00    0.00   99.62

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.13    0.00    0.13    0.00    0.00   99.75

Posted on Mon, 29 Nov 2021 10:24:48 -0500 by Verminox