Tutorial on using iostat command in Linux

Tutorial on using iostat command in Linux

Preface

It is said that if the people doing operation and maintenance don’t have the skills, they would feel embarrassed to operate the server. Fortunately, I am not an operation and maintenance person. I have always claimed to be a developer. However, the operation and maintenance personnel of my current employer are so incompetent that they want me, who claims to be a developer, to roll up my sleeves and do it myself. Well, there is no way. I have to pick up the previous orders and start again~~~

When it comes to operation and maintenance, monitoring disks are indispensable. When it comes to disk monitoring, we have to talk about the iostat command. This article gives a detailed summary of the iostat command that I was once very familiar with.

Command Details

The iostat in Linux system is the abbreviation of I/O statistics. The iostat tool will monitor the disk operation activities of the system. It features reporting of disk activity statistics, and also reports on CPU usage. Like vmstat, iostat also has a weakness, which is that it cannot perform in-depth analysis on a specific process, but only analyzes the overall situation of the system.

The common command format of iostat is as follows:

iostat [parameter] [time] [number of times]

The command parameters are described as follows:

-c Display CPU usage
-d Display disk usage
-k Display in K units
-m Display in M ​​units
-N Display disk array (LVM) information
-n Display NFS usage
-p can report the usage of each partition of each disk
-t Display terminal and CPU information
-x Display detailed information

The following is a detailed summary of our commonly used usage methods.

Use Case

Command: iostat -x

Description: Refresh the 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/sr/sw/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

Detailed output content:

  • %user: The percentage of time the CPU is in user mode
  • %nice: The percentage of time the CPU is in user mode with a NICE value
  • %system: The percentage of time the CPU is in system mode
  • %iowait: The percentage of time the CPU spends waiting for input and output to complete
  • %steal: The percentage of time a virtual CPU spends waiting unintentionally while the hypervisor is maintaining another virtual processor
  • %idle: CPU idle time percentage

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

  • Device: device name
  • rrqm/s: The number of read requests merged to the device per second
  • wrqm/s: The number of write requests merged to the device per second
  • r/s: The number of read operations initiated to the disk per second
  • w/s: The number of write operations initiated to the disk per second
  • rkB/s: K bytes read per second
  • wkB/s: Write K bytes per second
  • avgrq-sz: average data size per device I/O operation
  • avgqu-sz: average I/O queue length
  • Await: The average waiting time (in milliseconds) for each device I/O operation. Generally, the system I/O response time should be less than 5ms. If it is greater than 10ms, it is relatively large.
  • r_await: The average time required for each read operation; it includes not only the time for the hard disk device to read the operation, but also the time waiting in the kernel queue.
  • w_await: The average time required for each write operation; it includes not only the time for the hard disk device to write, but also the time waiting in the kernel queue.
  • svctm: Average service time (in milliseconds) for each device I/O operation (this data is not credible!)
  • %util: The percentage of time in one second that is used for I/O operations, that is, the percentage of CPU consumed by IO. Generally, if this parameter is 100%, it means that the device is running close to 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

Detailed output content:

  • tps: I/O per second (IOPS, the sum of continuous reads and writes to the disk)
  • kB_read/s: The size of data read from the disk per second, in KB/s
  • kB_wrtn/s: The size of the data written to the disk per second, in KB/s
  • kB_read: The total amount of data read from the disk, in KB
  • kB_wrtn: The total amount of data written to disk, in KB

Performance monitoring indicators

Having said so much and seen so much system output, what fields do we need to pay attention to in daily operation and maintenance? Now let’s talk about the key points of this article. What output content should we pay attention to in order to determine whether this server has an IO performance bottleneck.

  • %iowait: If this value is high, it means that there is an I/O bottleneck on the disk.
  • Await: Generally, the system I/O response time should be less than 5ms. If it is greater than 10ms, it is too long.
  • avgqu-sz: If the I/O request pressure continues to exceed the disk processing capacity, this value will increase. If the queue length of a single disk exceeds 2 continuously, it is generally believed that the disk has I/O performance problems. It should be noted that if the disk is a virtual logical drive of a disk array, the value needs to be divided by the number of actual physical disks that make up this logical drive to obtain the average I/O wait queue length of a single hard disk.
  • %util: Generally, if this parameter is 100%, it means the device is running close to full capacity.

Finally, in addition to focusing on indicators, we also need to analyze in conjunction with the deployed business. For businesses with frequent random disk reads and writes, such as image access, databases, mail servers, etc., tps is the key point. For services with frequent sequential read and write operations that require the transmission of large blocks of data, such as video on demand and file synchronization, the focus is on disk throughput.

Summarize

This concludes the summary of the iostat command. In our daily operation and maintenance work, we need to conduct more analysis based on actual scenarios. As a tool, mastering the basic usage of iostat is the basis. I hope that through this article, everyone can master the basic usage of the iostat command. As for the later sublimation, you need to use it more, explore more and summarize more in your work.

Well, the above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • A detailed introduction to Linux IO
  • Linux IO multiplexing epoll network programming
  • Interesting explanation of Linux's Socket IO model
  • A detailed introduction to the five IO models under Linux
  • Analyzing Linux high-performance network IO and Reactor model

<<:  Example of using setInterval function in React

>>:  Mysql multi-condition query statement with And keyword

Recommend

Use of Linux ipcs command

1. Command Introduction The ipcs command is used ...

Several situations that cause MySQL to perform a full table scan

Table of contents Case 1: Case 2: Case 3: To summ...

How to configure Nginx virtual host in CentOS 7.3

Experimental environment A minimally installed Ce...

js version to realize calculator function

This article example shares the specific code of ...

Is it true that the simpler the web design style, the better?

Original address: http://www.webdesignfromscratch...

Implementation of textarea adaptive height solution in Vue

Table of contents Hidden Problems Solution to ada...

The principle and application of ES6 deconstruction assignment

Table of contents Array destructuring assignment ...

An article to help you learn CSS3 picture borders

Using the CSS3 border-image property, you can set...

WeChat applet calculator example

WeChat applet calculator example, for your refere...

How to implement navigation function in WeChat Mini Program

1. Rendering2. Operation steps 1. Apply for Tence...

Detailed explanation of Vue-Jest automated testing basic configuration

Table of contents Install Configuration Common Mi...

JavaScript data flattening detailed explanation

Table of contents What is Flattening recursion to...