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

A very detailed explanation of Linux C++ multi-thread synchronization

Table of contents 1. Mutex 1. Initialization of m...

MySQL 5.7.18 version free installation configuration tutorial

MySQL is divided into installation version and fr...

How to solve "Unable to start mysql service error 1069"

Today, when I was on the road, a colleague sent m...

Why TypeScript's Enum is problematic

Table of contents What happened? When to use Cont...

A brief discussion on React native APP updates

Table of contents App Update Process Rough flow c...

WeChat applet calculator example

This article shares the specific code of the WeCh...

Example code for implementing a simple search engine with MySQL

Table of contents Preface Introduction ngram full...

Detailed explanation of javascript knowledge points

Table of contents 1. Basic Introduction to JavaSc...

Introduction to installing and configuring JDK under CentOS system

Table of contents Preface Check and uninstall Ope...

The solution of html2canvas that pictures cannot be captured normally

question First, let me talk about the problem I e...

jQuery implements form validation

Use jQuery to implement form validation, for your...

Summary of some practical little magic in Vue practice

How can you forget lazy loading of routes that al...

Detailed explanation of Vue3 life cycle functions and methods

1. Overview The so-called life cycle function is ...

Realize breadcrumb function based on vue-router's matched

This article mainly introduces the breadcrumb fun...

Summary of Linux system user management commands

User and Group Management 1. Basic concepts of us...