Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of the iostat command in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what is the use of the iostat command in Linux. I hope you will get something after reading this article. Let's discuss it together.

Iostat in the Linux system is an acronym for input / output statistics, and the iostat tool monitors the disk operation activity of the system.

It is characterized by reporting disk activity statistics as well as CPU usage. Like vmstat, iostat has a weakness that it cannot analyze a process in depth, only the overall situation of the system. Iostat belongs to the sysstat software package. It can be installed directly with yum install sysstat.

1. Command format:

Iostat [parameters] [time] [times]

2. Command function:

Through iostat, it is convenient to view the activity and load information of CPU, Nic, tty devices, disks, CD-ROM and other devices.

3. Command parameters:

-C shows CPU usage

-d displays disk usage

-k is displayed in KB

-m is displayed in M units

-N display disk array (LVM) information

-n display NFS usage

-p [disk] shows the disk and partition

-t display terminal and CPU information

-x display details

-V displays version information

4. Use an example:

Example 1: displays the load of all devices

Command: iostat

Output:

[root@CT1186 ~] # iostat

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Avg-cpu:% user nice% system% iowait% steal% idle

8.30 0.02 5.07 0.17 0.00 86.44

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 22.73 43.70 487.42 674035705 7517941952

Sda1 0.00 0.00 0.00 2658 536

Sda2 0.11 3.74 3.51 57721595 54202216

Sda3 0.98 0.61 17.51 9454172 270023368

Sda4 0.00 0.00 0.00 6 0

Sda5 6.95 0.12 108.73 1924834 1677123536

Sda6 2.20 0.18 31.22 2837260 481488056

Sda7 12.48 39.04 326.45 602094508 5035104240

Description:

The cpu attribute value description:

The percentage of time user:CPU spent in user mode.

The percentage of time nice:CPU spent in user mode with nice value.

The percentage of time system:CPU spent in system mode.

Percentage of time that iowait:CPU waits for input and output to complete.

% steal: the percentage of unconscious wait time of the virtual CPU when the hypervisor maintains another virtual processor.

% idle:CPU percentage of idle time.

Note: if the value of% iowait is too high, it means that the hard disk has an Icano bottleneck, and a high value of% idle means that CPU is idle. If the value of% idle is high but the system response is slow, it is possible that CPU is waiting to allocate memory. At this time, the memory capacity should be increased. If the% CPU value is consistently lower than 10, then the system's CPU processing capacity is relatively low, indicating that the resource that needs to be solved most in the system is CPU.

The disk attribute value description:

Rrqm/s: the number of merge reads per second. That is rmerge/s

Wrqm/s: the number of merge writes per second. That is wmerge/s

Rdyne s: the number of times the read of the Iripple O device was completed per second. That is rio/s

Wthumb s: the number of writes completed by the I _ swap O device per second. That is wio/s

Rsec/s: read sectors per second. That is rsect/s

Wsec/s: the number of sectors written per second. That is wsect/s

RkB/s: read K bytes per second. Is half the rsect/s because the size of each sector is 512 bytes.

WkB/s: write K bytes per second. It's half of wsect/s.

Avgrq-sz: the average data size (sector) per device Istroke O operation.

Avgqu-sz: average Imax O queue length.

Await: the average wait time (in milliseconds) for each device Istroke O operation.

Svctm: the average service time (in milliseconds) for each device Istroke O operation.

% util: how many percent of the time in a second is spent on the cpu O operation, that is, the percentage of cpu consumed by io

Note: if the% util is close to 100%, it means that too many requests have been generated and the system is fully loaded, and there may be a bottleneck on the disk. If the svctm is close to the await, it means that there is almost no waiting time for the await O; if the await is much larger than the svctm, the queue is too long and the io response is too slow, so necessary optimizations are needed. If the avgqu-sz is large, it also means that there is an equivalent io waiting.

Example 2: regularly displays all information

Command: iostat 2 3

Output:

[root@CT1186 ~] # iostat 2 3

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Avg-cpu:% user nice% system% iowait% steal% idle

8.30 0.02 5.07 0.17 0.00 86.44

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 22.73 43.70 487.42 674035705 7517947296

Sda1 0.00 0.00 0.00 2658 536

Sda2 0.11 3.74 3.51 57721595 54202216

Sda3 0.98 0.61 17.51 9454172 270023608

Sda4 0.00 0.00 0.00 6 0

Sda5 6.95 0.12 108.73 1924834 1677125640

Sda6 2.20 0.18 31.22 2837260 481488152

Sda7 12.48 39.04 326.44 602094508 5035107144

Avg-cpu:% user nice% system% iowait% steal% idle

8.88 0.00 7.94 0.19 0.00 83.00

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 6.00 0.00 124.00 0 248

Sda1 0.00 0.00 0.00 00

Sda2 0.00 0.00 0.00 00

Sda3 0.00 0.00 0.00 00

Sda4 0.00 0.00 0.00 00

Sda5 0.00 0.00 0.00 00

Sda6 0.00 0.00 0.00 00

Sda7 6.00 0.00 124.00 0 248

Avg-cpu:% user nice% system% iowait% steal% idle

9.12 0.00 7.81 0.00 0.00 83.07

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 4.00 0.00 84.00 0 168

Sda1 0.00 0.00 0.00 00

Sda2 0.00 0.00 0.00 00

Sda3 0.00 0.00 0.00 00

Sda4 0.00 0.00 0.00 00

Sda5 0.00 0.00 0.00 00

Sda6 4.00 0.00 84.00 0 168

Sda7 0.00 0.00 0.00 00

Description:

Refresh the display every 2 seconds and display 3 times

Example 3: displays the specified disk information

Command: iostat-d sda1

Output:

Linux iostat command details and usage examples (disk operation monitoring tool)

[root@CT1186] # iostat-d sda1

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda1 0.00 0.00 0.00 2658 536

Example 4: display tty and Cpu information

Command: iostat-t

Output:

[root@CT1186 ~] # iostat-t

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Time: 14:58:35

Avg-cpu:% user nice% system% iowait% steal% idle

8.30 0.02 5.07 0.17 0.00 86.44

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 22.73 43.70 487.41 674035705 7517957864

Sda1 0.00 0.00 0.00 2658 536

Sda2 0.11 3.74 3.51 57721595 54202216

Sda3 0.98 0.61 17.51 9454172 270024344

Sda4 0.00 0.00 0.00 6 0

Sda5 6.95 0.12 108.73 1924834 1677128808

Sda6 2.20 0.18 31.22 2837260 481488712

Sda7 12.48 39.04 326.44 602094508 5035113248

Example 5: displays all information in M units

Command: iostat-m

Output:

[root@CT1186] # iostat-m

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Avg-cpu:% user nice% system% iowait% steal% idle

8.30 0.02 5.07 0.17 0.00 86.44

Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn

Sda 22.72 0.02 0.24 329119 3670881

Sda1 0.00 0.00 0.00 1 0

Sda2 0.11 0.00 0.00 28184 26465

Sda3 0.98 0.00 0.01 4616 131848

Sda4 0.00 0.00 0.00 00

Sda5 6.95 0.00 0.05 939 818911

Sda6 2.20 0.00 0.02 1385 235102

Sda7 12.48 0.02 0.16 293991 2458553

Example 6: view TPS and throughput information

Command: iostat-d-k 1 1

Output:

[root@CT1186] # iostat-d-k 11

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn

Sda 22.72 21.85 243.71 337017916 3758984340

Sda1 0.00 0.00 0.00 1329 268

Sda2 0.11 1.87 1.76 28860797 27101108

Sda3 0.98 0.31 8.75 4727086 135012508

Sda4 0.00 0.00 0.00 3 0

Sda5 6.95 0.06 54.37 962481 838566148

Sda6 2.20 0.09 15.61 1418630 240744712

Sda7 12.48 19.52 163.22 301047254 2517559596

Description:

Tps: the number of transmissions per second for the device (Indicate the number of transfers per second that were issued to the device.). "one transfer" means "one Icano request". More than one logical request may be merged into an Ihop O request. The size of the one transfer 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 amount of data read; kB_wrtn: total amount of data written

These units are all Kilobytes.

In the above example, we can see the statistics of disk sda and its partitions. At that time, the total disk TPS was 22.73. below is the TPS of each partition. (because it is instantaneous, the total TPS is not strictly equal to the sum of the TPS of each partition.)

Example 7: view device utilization (% util), response time (await)

Command: iostat-d-x-k 1 1

Output:

[root@CT1186] # iostat-d-x-k 11

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Device: rrqm/s wrqm/s rUnip s wdeband s rkB/s wkB/s avgrq-sz avgqu-sz await svctm% util

Sda 0.44 38.59 0.40 22.32 21.85 243.71 23.37 0.04 1.78 4.20 9.54

Sda1 0.00 0.00 0.00 18.90 0.00 8.26 6.46 0.00

Sda2 0.36 0.43 0.11 0.01 1.87 1.76 63.57 0.01 63.75 1.94 0.02

Sda3 0.00 1.24 0.04 0.95 0.31 8.75 18.42 0.04 39.77 8.73 0.86

Sda4 0.00 0.00 0.00 2.00 0.00 19.67 19.67 0.00

Sda5 0.00 6.65 0.00 6.94 0.06 54.37 15.67 0.26 36.81 4.48 3.11

Sda6 0.00 1.71 0.01 2.19 0.09 15.61 14.29 0.03 12.40 5.84 1.28

Sda7 0.08 28.56 0.25 12.24 19.52 163.22 29.28 0.27 21.46 5.00 6.25

Description:

Rrqm/s: the number of merge reads per second. Namely delta (rmerge) / s

Wrqm/s: the number of merge writes per second. Namely delta (wmerge) / s

Ripple s: the number of reads completed per second on the I _ swap O device. Namely delta (rio) / s

Wthumb s: the number of writes completed per second by the I Universe O device. Namely delta (wio) / s

Rsec/s: read sectors per second. Namely delta (rsect) / s

Wsec/s: write the number of sectors per second. Namely delta (wsect) / s

RkB/s: read K bytes per second. Is half of rsect/s, because each sector size is 512 bytes. (need to calculate)

WkB/s: write K bytes per second. It's half of wsect/s. (need to calculate)

Avgrq-sz: average data size (sector) for each device Istroke O operation. Delta (rsect+wsect) / delta (rio+wio)

Avgqu-sz: the average length of the queue. That's delta (aveq) / aveq 1000 (because it's in milliseconds).

Await: the average waiting time (milliseconds) for each device Istroke O operation. That is, delta (ruse+wuse) / delta (rio+wio)

Svctm: the average service time (milliseconds) for each device Istroke O operation. That is, delta (use) / delta (rio+wio)

% util: how many percent of the time in a second is spent on the use O operation, or how much time in a second the I use O queue is not empty, i.e. delta (use) / 1000 (because the time is in milliseconds)

If the% util is close to 100%, it means that too many requests have been generated, the system is fully loaded, and there may be a bottleneck on the disk.

When the idle is less than 70%, the IO pressure is higher, and generally the read speed has more wait.

At the same time, you can check parameter b (number of processes waiting for resources) and wa parameter (percentage of CPU time spent by IO waiting) in conjunction with vmstat. IO pressure is high when it is higher than 30%.

In addition, the parameters of await should also be referred to by svctm. If the difference is too high, there must be a problem with IO.

Avgqu-sz is also a place to pay attention to when doing IO tuning. This is the size of the data directly for each operation. If there are many times, but the data is small, the IO will also be very small. If the data is large, the data of IO will be high. It can also be called avgqu-sz × (r _ or _ s _ or _ _ s) = rsec/s or wsec/s. In other words, the reading speed is determined by this.

Svctm is generally less than await (because the waiting time of requests waiting at the same time is calculated repeatedly), the size of svctm is generally related to disk performance, the load of CPU/ memory will also affect it, and too many requests will indirectly lead to the increase of svctm. The size of the await generally depends on the service time (svctm) as well as the length of the Imax O queue and the mode in which the Imax O request is issued. If svctm is close to await, it means that there is almost no waiting time for await; if await is much larger than svctm, the queue is too long, and the response time of the application becomes slower. If the response time exceeds the range allowed by users, you can consider replacing faster disks, adjusting kernel elevator algorithm, optimizing applications, or upgrading CPU.

Queue length (avgqu-sz) can also be used as an index to measure the load of the system, but because the avgqu-sz is according to the average per unit time, it can not reflect the instantaneous flood.

The metaphor of the image:

R/s+w/s is similar to the total number of payers

The average queue length (avgqu-sz) is similar to the average number of people in queue per unit time.

The average service time (svctm) is similar to the cashier's speed of collection.

The average waiting time (await) is similar to the average waiting time per person.

The average avgrq-sz is similar to what the average person buys.

The% util is similar to the percentage of time someone queued in front of the cashier.

IO operation of the device: total IO (io) / s = r io s (read) + w max s (write) = 1.46 + 25.28mm 26.74

On average, it takes only 0.36 milliseconds for each device Icano operation to complete, but now it takes 10.57 milliseconds to complete, because there are too many requests (26.74 requests per second). If the requests are sent at the same time, the average waiting time can be calculated as follows:

Average wait time = time for a single Ithumb O server * (1 / 2 requests. + Total requests-1) / total requests

There are a lot of Iamp 0 requests per second, but the average queue is 4, indicating that these requests are uniform and most of them are processed in a timely manner.

Example 8: view cpu status

Command: iostat-c 1 3

Output:

[root@CT1186] # iostat-c 1 3

Linux 2.6.18-128.el5 (CT1186) 28 December 2012

Avg-cpu:% user nice% system% iowait% steal% idle

8.30 0.02 5.07 0.17 0.00 86.44

Avg-cpu:% user nice% system% iowait% steal% idle

8.64 0.00 5.38 0.00 0.00 85.98

Avg-cpu:% user nice% system% iowait% steal% idle

7.62 0.00 5.12 0.50 0.00 86.75

After reading this article, I believe you have a certain understanding of "what is the use of iostat commands in Linux". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report