The iostat command in Linux uses the tutorial

  • 2020-12-20 03:57:55
  • OfStack

preface

Say to engage in the operation and maintenance of people without two "brush", are embarrassed on the server operation. Fortunately, I am not engaged in operation and maintenance, I have always boasted of being a developer, but now the owner of the operation and maintenance personnel "water" of 1, but also I am the proud of the development of the people roll up their sleeves to play, well, there is no way, regain the previous command, again start ~~~

When it comes to operations, you can't do without monitoring disks. When it comes to disk monitoring, it's hard not to mention the iostat command. This article is a detailed summary of the iostat command that I used to be very familiar with.

The command,

iostat in Linux systems is short for I/O statistics (input/output statistics), and the iostat tool monitors disk operation activity on the system. It features reporting disk activity statistics as well as CPU usage. Like vmstat1, iostat also has a weakness in that it does not provide in-depth analysis of a process, but only of the system as a whole.

Common iostat command formats are as follows:

[

iostat [parameter] [time] [frequency]

]

Command parameters are explained as follows:

[

-ES36en shows CPU usage
-ES39en displays disk usage
-k displayed in K
-m displayed in M
-N displays disk array (LVM) information
-ES50en shows the usage of NFS
-ES53en can report the usage of each partition per disk
-t displays terminal and CPU information
-ES58en displays details

]

The following is a detailed summary of our common usage.

Using the instance

Command: iostat -x

Description: refresh display every 2 seconds and display 3 times

Output:


[user1@Test_Server ~]$ iostat -x
Linux 3.10.0-693.2.2.el7.x86_64 (jellythink) 01/05/2019 _x86_64_ (1 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
  1.83 0.00 0.31 0.09 0.00 97.77

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.03 0.78 0.24 1.38 12.64 20.67 41.01 0.02 10.98 55.50 3.17 0.71 0.12

Details of output content:

%user: Percentage of time CPU is in user mode %nice: The percentage of time that CPU is in user mode with NICE values %system: Percentage of time that CPU is in system mode %iowait: Percentage of time that CPU waits for input/output to complete %steal: Percentage of virtual CPU's unconscious wait time while the hypervisor maintains another virtual processor %idle: Percentage of CPU free time

Of course, the point of the iostat command is not to look at CPU, but to monitor disk performance.

Device: Device name rrqm/s: Number of read requests per second merged into the device wrqm/s: Number of write requests per second merged into the device r/s: Number of read operands initiated to disk per second w/s: Number of write operations per second initiated to disk rkB/s: Number of K bytes read per second wkB/s: Number of K bytes written per second avgrq-sz: Average data size per device I/O operation avgqu-sz: Average I/O queue length await: Average wait time (ms) for each device I/O operation, like 1, system I/O response time should be lower than 5ms, larger than 10ms r_await: Average time required per read operation; This includes not only the time the hard disk device reads, but also the time it waits in the kernel queue w_await: Average time required per write operation; This includes not only the time spent writing to the hard disk device, but also the time spent waiting in the kernel queue svctm: Average service time (milliseconds) per device I/O operation (this data cannot be trusted!) %util: What percentage of the time in 1 second is used for I/O operation, that is, the percentage of CPU consumed by IO, like 1, if the parameter is 100%, the device is running at nearly full capacity

Command: iostat -d 2 3

Output:


[jelly@jellythink ~]$ iostat -d 2 3
Linux 3.10.0-693.2.2.el7.x86_64 (jellythink) 01/05/2019 _x86_64_ (1 CPU)

Device:  tps kB_read/s kB_wrtn/s kB_read kB_wrtn
vda  1.62 12.64 20.67 337375593 551756524

Device:  tps kB_read/s kB_wrtn/s kB_read kB_wrtn
vda  1.00  0.00  8.00  0  16

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

Details of output content:

tps: the number of I/O per second (IOPS). Sum of continuous read and write on disk) kB_read/s: The size of data read from disk per second, in KB/s kB_wrtn/s: the size of the data written to disk per second, in KB/s kB_read: Total amount of data read from disk, KB kB_wrtn: Total amount of data written to disk, KB

Performance monitoring index

Having said so much and seen so many system outputs, which fields should we pay attention to in daily operation and maintenance? Here's the main point of this article, which output to focus on to determine if there is an IO performance bottleneck on this server.

%iowait: A high value indicates an I/O bottleneck on the disk await: like 1, system I/O response time should be lower than 5ms, larger than 10ms avgqu-sz: This value increases if the I/O request pressure continues to exceed disk processing capacity. An I/O performance problem is generally considered if the queue length of a single disk continues to exceed 2,1. Note that if the disk is a virtual logical drive for a disk array, you need to divide this value again by the actual number of physical disks that make up the logical drive to get the average I/O wait queue length for a single hard disk %util: 1 like, if this parameter is 100%, the device is running near full capacity

Finally, in addition to focusing on metrics, we need to analyze it in conjunction with the deployed business. tps is the key for services with frequent random reads and writes on disk, such as image access, databases, mail servers, etc. For services with frequent sequential reads and writes, where large chunks of data need to be transferred, such as video-on-demand and file synchronization, the focus is on disk throughput.

conclusion

This concludes the summary of the iostat command. In the daily operation and maintenance work, we need to analyze more according to the actual scene. As a tool, iostat can master the basic usage of iostat, which is the foundation. I hope you can master the basic usage of iostat command through this article. As for the later sublimation, you need to make more use, exploration and summary in your work.


Related articles: