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

How to use 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--

This article will explain in detail how to use the iostat command in linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

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 examples:

Example 1: show the load of all devices

[root@seaing ~] # iostat

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

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

0.01 0.01 0.08 0.04 0.00 99.86

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 5.97 11.26 65.00 834627 4816664

Sda1 0.00 0.03 0.00 2309 32

Sda2 5.96 11.22 65.00 831281 4816632

Sdb 0.02 0.08 p 1.94 5577 143526

Sdb1 0.00 0.01 0.00 486 0

Sdb2 0.00 0.01 0.00 515 0

Sdc 0.01 0.04 0.00 2607 0

Sdd 3.23 25.59 25.45 1896431 1885832

Sde 0.02 0.06 1.94 4115 144000

Sde1 0.00 0.00 0.00 356 0

Sde2 0.00 0.01 0.00 386 0

Sdf 0.01 0.02 0.00 1607 0

Sdg 0.31 2.45 2.43 181575 180024

Sdh 0.02 0.06 1.94 4115 144000

Sdh2 0.00 0.00 0.00 356 0

Sdh3 0.00 0.01 0.00 386 0

Sdi 0.01 0.02 0.00 1591 0

Sdj 0.30 2.40 2.48 177583 183912

Sdk 0.02 0.06 1.93 4743 143204

Sdk1 0.00 0.00 0.00 356 0

Sdk2 0.00 0.01 0.00 386 0

Sdl 0.01 0.02 0.00 1607 0

Sdm 0.30 2.40 2.38 177599 176000

Dm-0 8.54 11.20 65.00 829946 4816632

Dm-1 0.00 0.01 0.00 896 0

Dm-2 0.00 0.00 0.00 40 0

Dm-3 0.00 0.00 0.00 40 0

Dm-4 2.42 9.66 9.66 715976 715936

Description:

The avg-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.

Device attribute value description

Tps: the number of Ithumb O requests sent per second.

Blk_read / s: the number of block read per second.

Blk_wrtn/s: the number of block written per second.

Blk_read: the total number of block read.

Blk_wrtn: the total number of block written.

Example 2: display all information regularly

[root@seaing ~] # iostat 2 2

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

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

0.01 0.01 0.08 0.04 0.00 99.86

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 5.94 11.20 64.65 834627 4817720

Sda1 0.00 0.03 0.00 2309 32

Sda2 5.93 11.16 64.65 831281 4817688

Sdb 0.02 0.07 1.93 5577 143526

Sdb1 0.00 0.01 0.00 486 0

Sdb2 0.00 0.01 0.00 515 0

Sdc 0.01 0.03 0.00 2607 0

Sdd 3.21 25.45 25.31 1896431 1885832

Sde 0.02 0.06 1.93 4115 144000

Sde1 0.00 0.00 0.00 356 0

Sde2 0.00 0.01 0.00 386 0

Sdf 0.01 0.02 0.00 1607 0

Sdg 0.31 2.44 2.42 181575 180024

Sdh 0.02 0.06 1.93 4115 144000

Sdh2 0.00 0.00 0.00 356 0

Sdh3 0.00 0.01 0.00 386 0

Sdi 0.01 0.02 0.00 1591 0

Sdj 0.30 2.38 2.47 177583 183912

Sdk 0.02 0.06 1.92 4743 143204

Sdk1 0.00 0.00 0.00 356 0

Sdk2 0.00 0.01 0.00 386 0

Sdl 0.01 0.02 0.00 1607 0

Sdm 0.30 2.38 2.36 177599 176000

Dm-0 8.50 11.14 64.65 829946 4817688

Dm-1 0.00 0.01 0.00 896 0

Dm-2 0.00 0.00 0.00 40 0

Dm-3 0.00 0.00 0.00 40 0

Dm-4 2.40 9.61 9.61 715976 715936

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

0.00 0.00 0.25 0.00 0.00 99.75

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 0.00 0.00 0.00 00

Sda1 0.00 0.00 0.00 00

Sda2 0.00 0.00 0.00 00

Sdb 0.00 0.00 0.00 00

Sdb1 0.00 0.00 0.00 00

Sdb2 0.00 0.00 0.00 00

Sdc 0.00 0.00 0.00 00

Sdd 0.00 0.00 0.00 00

Sde 0.00 0.00 0.00 00

Sde1 0.00 0.00 0.00 00

Sde2 0.00 0.00 0.00 00

Sdf 0.00 0.00 0.00 00

Sdg 0.00 0.00 0.00 00

Sdh 0.00 0.00 0.00 00

Sdh2 0.00 0.00 0.00 00

Sdh3 0.00 0.00 0.00 00

Sdi 0.00 0.00 0.00 00

Sdj 0.00 0.00 0.00 00

Sdk 0.00 0.00 0.00 00

Sdk1 0.00 0.00 0.00 00

Sdk2 0.00 0.00 0.00 00

Sdl 0.00 0.00 0.00 00

Sdm 0.00 0.00 0.00 00

Dm-0 0.00 0.00 0.00 00

Dm-1 0.00 0.00 0.00 00

Dm-2 0.00 0.00 0.00 00

Dm-3 0.00 0.00 0.00 00

Dm-4 0.00 0.00 0.00 00

Description: refresh the display every 2 seconds, and display 2 times

Example 3: display specified disk information

[root@seaing] # iostat-d / dev/sda1

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda1 0.00 0.03 0.00 2309 32

Example 4: display all information in M units

[root@seaing] # iostat-m

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

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

0.01 0.01 0.08 0.04 0.00 99.86

Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn

Sda 5.92 0.01 0.03 407 2352

Sda1 0.00 0.00 0.00 1 0

Sda2 5.91 0.01 0.03 405 2352

Sdb 0.02 0.00 0.00 2 70

Sdb1 0.00 0.00 0.00 00

Sdb2 0.00 0.00 0.00 00

Sdc 0.01 0.00 0.00 1 0

Sdd 3.20 0.01 0.01 925 920

Sde 0.02 0.00 0.00 2 70

Sde1 0.00 0.00 0.00 00

Sde2 0.00 0.00 0.00 00

Sdf 0.01 0.00 0.00 00

Sdg 0.31 0.00 0.00 88 87

Sdh 0.02 0.00 0.00 2 70

Sdh2 0.00 0.00 0.00 00

Sdh3 0.00 0.00 0.00 00

Sdi 0.01 0.00 0.00 00

Sdj 0.30 0.00 0.00 86 89

Sdk 0.02 0.00 0.00 2 69

Sdk1 0.00 0.00 0.00 00

Sdk2 0.00 0.00 0.00 00

Sdl 0.01 0.00 0.00 00

Sdm 0.30 0.00 0.00 86 85

Dm-0 8.47 0.01 0.03 405 2352

Dm-1 0.00 0.00 0.00 00

Dm-2 0.00 0.00 0.00 00

Dm-3 0.00 0.00 0.00 00

Dm-4 2.39 0.00 0.00 349 349

Example 5: view TPS and throughput information

[root@seaing] # iostat-d-k 1 1

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn

Sda 5.92 5.58 32.19 417313 2409280

Sda1 0.00 0.02 0.00 1154 16

Sda2 5.91 5.55 32.19 415640 2409264

Sdb 0.02 0.04 0.96 2788 71763

Sdb1 0.00 0.00 0.00 243 0

Sdb2 0.00 0.00 0.00 257 0

Sdc 0.01 0.02 0.00 1303 0

Sdd 3.19 12.67 12.60 948215 942916

Sde 0.02 0.03 0.96 2057 72000

Sde1 0.00 0.00 0.00 178 0

Sde2 0.00 0.00 0.00 193 0

Sdf 0.01 0.01 0.00 803 0

Sdg 0.31 1.21 1.20 90787 90012

Sdh 0.02 0.03 0.96 2057 72000

Sdh2 0.00 0.00 0.00 178 0

Sdh3 0.00 0.00 0.00 193 0

Sdi 0.01 0.01 0.00 795 0

Sdj 0.30 1.19 1.23 88791 91956

Sdk 0.02 0.03 0.96 2371 71602

Sdk1 0.00 0.00 0.00 178 0

Sdk2 0.00 0.00 0.00 193 0

Sdl 0.01 0.01 0.00 803 0

Sdm 0.30 1.19 1.18 88799 88000

Dm-0 8.46 5.54 32.19 414973 2409264

Dm-1 0.00 0.01 0.00 448 0

Dm-2 0.00 0.00 0.00 20 0

Dm-3 0.00 0.00 0.00 20 0

Dm-4 2.39 4.78 4.78 357988 357968

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 the disk and its partitions. Take sda as an example, the total disk TPS is 5.92, and the following 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 6: view device usage (% util), response time (await)

[root@seaing] # iostat-d-x-k 1 1

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

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

Sda 0.17 2.39 0.26 5.64 5.57 32.14 12.77 0.00 0.60 0.32 0.19

Sda1 0.01 0.00 0.00 0.00 0.02 0.00 17.60 0.00 4.79 4.08 0.00

Sda2 0.16 2.39 0.25 5.64 5.55 32.14 12.78 0.00 0.60 0.32 0.19

Sdb 0.03 0.95 0.01 0.01 0.04 0.96 84.29 0.00 1.74 0.39 0.00

Sdb1 0.00 0.00 0.00 18.00 0.00 2.19 1.48 0.00

Sdb2 0.01 0.00 0.00 0.00 16.09 0.00 1.31 1.28 0.00

Sdc 0.00 0.00 0.01 0.00 0.02 0.00 5.94 0.00 0.17 0.18 0.00

Sdd 0.00 3.12 3.16 0.03 12.65 12.58 15.82 0.00 1.47 0.10 0.03

Sde 0.02 0.95 0.01 0.01 0.03 0.96 91.77 0.00 2.39 0.44 0.00

Sde1 0.00 0.00 0.00 19.78 0.00 0.28 0.28 0.00

Sde2 0.00 0.00 0.00 17.55 0.00 0.23 0.23 0.00

Sdf 0.00 0.00 0.01 0.00 0.01 0.00 3.98 0.00 0.08 0.08 0.00

Sdg 0.00 0.30 0.31 0.00 1.21 1.20 15.66 0.00 1.58 0.20 0.01

Sdh 0.02 0.95 0.01 0.01 0.03 0.96 99.67 0.00 44.20 0.54 0.00

Sdh2 0.00 0.00 0.00 19.78 0.00 0.22 0.22 0.00

Sdh3 0.00 0.00 0.00 17.55 0.00 0.09 0.09 0.00

Sdi 0.00 0.00 0.01 0.00 0.01 0.00 3.90 0.00 0.12 0.12 0.00

Sdj 0.00 0.30 0.30 0.00 1.18 1.23 16.00 0.00 3.62 0.14 0.00

Sdk 0.03 0.95 0.01 0.01 0.03 0.96 99.83 0.00 44.21 0.62 0.00

Sdk1 0.00 0.00 0.00 19.78 0.00 0.22 0.22 0.00

Sdk2 0.00 0.00 0.00 17.55 0.00 0.27 0.27 0.00

Sdl 0.00 0.00 0.01 0.00 0.01 0.00 3.98 0.00 0.07 0.07 0.00

Sdm 0.00 0.29 0.30 0.00 1.18 1.17 15.65 0.00 3.52 0.22 0.01

Dm-0 0.00 0.00 0.41 8.04 5.54 32.14 8.92 0.01 1.52 0.23 0.19

Dm-1 0.00 0.00 0.00 0.01 0.00 8.00 0.00 8.08 0.54 0.00

Dm-2 0.00 0.00 0.00 8.00 0.00 0.20 0.20 0.00

Dm-3 0.00 0.00 0.00 8.00 0.00 0.00 0.00

Dm-4 0.00 0.00 1.19 1.19 4.78 4.78 8.00 0.36 151.91 0.07 0.02

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 7: displays the CPU and IO of the disk and its partitions

[root@seaing] # iostat-p sda 2 1

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

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

0.01 0.01 0.08 0.04 0.00 99.86

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 5.88 11.08 63.98 834627 4819912

Sda2 11.29 0.16 1.08 11997 81512

Sda1 0.03 0.01 0.00 1030 375

Example 8: show multiple disk devices

[root@seaing ~] # iostat-d sda sdb sdc dm-4 2 1

Linux 2.6.18-194.el5 (seaing.comsys.com) 10 Accord 27 Universe 2017

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

Sda 5.87 11.07 63.93 834627 4820120

Sdb 0.02 0.07 1.90 5577 143526

Sdc 0.01 0.03 0.00 2607 0

Dm-4 2.37 9.50 9.50 715976 715936

This is the end of the article on "how to use iostat commands in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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