A linux command per day (47): iostat command

The iostat in Linux system is the abbreviation of I/O statistics (input/output statistics). The iostat tool will monitor the disk operation activities of the system. It is characterized by reporting disk activity statistics, as well as CPU usage. Like vmstat, iostat also has a weakness, that is, it cannot conduct in-depth analysis of a process, but only analyzes the overall situation of the system. iostat belongs to the sysstat package. It can be installed directly with yum install sysstat.
1. Command format:
iostat[parameter][time][time]
2.Command function:
  It is convenient to view the activity and load information of CPU, network card, tty device, disk, CD-ROM and other devices through iostat.
3. Command parameters:
-C display CPU usage
-d display disk usage
#p#page header #e#-k display in KB
-m display in M ​​units
-N display disk array (LVM) information
-n display NFS usage Situation
-p [disk] Display disk and partition situation
-t Display terminal and CPU information
-x Display detailed information
-V Display version information
4.Example of use:
Example 1: Displaying the load of all devices
Command :
iostat
Output: #p#Page title#e#
Copy code
[root@CT1186 ~]# iostat
Linux 2.6.18-128.el5 (CT1186)   2012年12月28日

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 #p#Page title#e#
Copy code

Description :
cpu attribute value description:
%user: The percentage of time the CPU is in user mode.
%nice: The percentage of time the CPU is in user mode with NICE value.
%system: The percentage of time the CPU is in system mode.
%iowait: The percentage of time the CPU waits for input and output to complete.
%steal: Percentage of unintentional wait time of a virtual CPU while the hypervisor is maintaining another virtual processor.
%idle: The percentage of CPU idle time.

Note: If the value of %iowait is too high, it means that the hard disk has an I/O bottleneck. If the value of %idle is high, it means that the CPU is idle. If the value of %idle is high but the system response is slow, it may be that the CPU is waiting to allocate memory. Increase the memory capacity. If the value of %idle is continuously lower than 10, the CPU processing power of the system is relatively low, indicating that the most important resource in the system is the CPU. #p#Page title#e#

Disk attribute value description:
rrqm/s: The number of merge read operations per second. That is, rmerge/s
wrqm/s: The number of merge write operations per second. That is, wmerge/s
r/s: The number of read I/O devices completed per second. i.e. rio/s
w/s: The number of write I/O devices completed per second. That is, wio/s
rsec/s: the number of sectors read per second. That is, rsect/s
wsec/s: the number of sectors written per second. That is, wsect/s
rkB/s: the number of K bytes read per second. is half of rsect/s because each sector size is 512 bytes.
wkB/s: Kbytes written per second. is half of wsect/s.
avgrq-sz: Average data size (sectors) per device I/O operation.
avgqu-sz: Average I/O queue length. #p#Page Title#e#
await: Average wait time (milliseconds) for each device I/O operation.
svctm: Average service time (milliseconds) per device I/O operation.
%

util At full capacity, the disk may be bottlenecked. If svctm is close to await, it means that I/O has almost no waiting time; if await is much larger than svctm, it means that the I/O queue is too long and the io response is too slow, and necessary optimizations are needed. If avgqu-sz is relatively large, it also means that there is equivalent io waiting.

Example 2: Display all information regularly
Command :
iostat 2 3
Output:
#p#Page title#e#Copy code
[root@CT1186 ~]# iostat 2 3
Linux 2.6.18-128.el5 (CT1186)   2012年12月28日

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#p#分页标题#e#

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          0          0
sda2              0.00         0.00         0.00          0          0
sda3              0.00         0.00         0.00          0          0
sda4              0.00         0.00         0.00          0          0
sda5              0.00         0.00         0.00          0          0
sda6              0.00         0.00         0.00          0          0
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#p#分页标题#e#
sda1              0.00         0.00         0.00          0          0
sda2              0.00         0.00         0.00          0          0
sda3              0.00         0.00         0.00          0          0
sda4 0.00 0.00 0.00 0 0 sda5
0.00 0.00 0.00 0 0
sda6 4.00 0.00 84.00 0 168
sda7 0.00 0.00 0.00 0 0Copy
code

Description :
Refresh the display every 2 seconds, and display 3 times

#p#page title #e#Example 3: Display Specify disk information
Command :
iostat -d sda1
Output:
[root@CT1186 ~]# iostat -d sda1
Linux 2.6.18-128.el5 (CT1186) December 28, 2012

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda1 0.00 0.00 0.00 2658 536

Description:

Example 4: Display tty and Cpu information
Command :
iostat -t#p#page title#e#
output:
copy code
[root@CT1186 ~]# iostat -t
Linux 2.6.18-128.el5 (CT1186) Dec 28, 2012

Time: 14:58:
35avg -cpu:% System User% Nice%%% iowait IDLE Steal%
           8.30 0.02 5.07 0.17 0.00 86.44

Device: TPS Blk_read / Blk_wrtn S / S Blk_read Blk_wrtn SDA
22.73 43.70 487.41 674 035 705 7517957864
sda1 0.00 0.00 0.00 2658 536
sda2 0.11 3.74 3.51 57,721,595 54,202,216
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 1,677,128,808
sda6 2.20 0.18 31.22 2.83726 million 481 488 712 # P # tab title # E #
sda7 and a 12.48 39.04 RMB32.644 602 094 508 5,035,113,248
copy the code
Description :

Example 5: units of M display all information
command : the
iostat -m
Output:
copy the code
[root @CT1186 ~]# iostat -m
Linux 2.6.18-128.el5 (CT1186) Dec 28, 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#p#page title#e#
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 131 848
sda4 0.00 0.00 0.00 0 0
sda5 6.95 0.00 0.05 939 818 911
sda6 2.20 0.00 0.02 1385 235
102 sda7 and a 12.48 0.02 0.16 293 991 2,458,553
copy the code
Description :

Example 6: View TPS and throughput info
#p#page header#e#Command:
iostat -d -k 1 1
Output:
Copy code
[root@CT1186 ~]# iostat -d -k 1 1
Linux 2.6.18-128.el5 (CT1186) December 28, 2012

Device: tps kB_read / S kB_wrtn / S kB_read kB_wrtn
sda 22.72 21.85 243.71 337 017 916 3,758,984,340
sda1 0.00 0.00 0.00 1329 268
sda2 0.11 1.87 1.76 28,860,797 27,101,108
sda3 0.98 0.31 8.75 4727086 135012508 SDA5
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 ​​# p # page title # e #
SDA7 12.48 19.52 163.22 301047254 2517559596
Copy code

Description:
tps: The number of transfers per second that is issued to the device. (Indicate the number of transfers per second that were issued to the device.). "One transfer" means "one I/O request". Multiple logical requests may be combined into "one I/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: the total amount of data read; kB_wrtn: written The total amount of data;
these units are Kilobytes.
In the above example, we can see the statistics of the disk sda and its various partitions. The total TPS of the disk at that time was 22.73, and the following is the TPS of each partition. (Because it is an instantaneous value, the total TPS is not strictly equal to the sum of the TPS of each partition)

#p#Page title#e#Example 7: View device usage (%util), response time (await)
Command:
iostat -d -x -k 1 1
output:
copy code
[root@CT1186 ~]# iostat -d -x -k 1 1
Linux 2.6.18-128.el5 (CT1186) December 28, 2012

Device: rrqm/s wrqm/sr/ sw/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 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 # P # 分页 Title # e #
SDA4 0.00 0.00 0.00 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.06
0.00 1.71 0.01 2.09 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
Copy code

Description :
rrqm/s: The number of read operations for merge per second. That is, delta(rmerge)/s
wrqm/s: The number of write operations for merge per second. delta(wmerge)/s
r/s: The number of read I/O devices completed per second. That is, delta(rio)/s
#p#page title#e#w/s: The number of write I/O devices completed per second .ie delta(wio)/s
rsec/s: number of sectors read per second.ie delta(rsect)/s
wsec/s: number of sectors written per second.ie delta(wsect)/s rkB/s
: per second Read Kbytes. It is half of rsect/s, because the size of each sector is 512 bytes. (Need to calculate)
wkB/s: Write Kbytes per second. It is half of wsect/s. (Need to calculate)
avgrq-sz: Average data size (sectors) per device I/O operation. delta(rsect+wsect)/delta(rio+wio)
avgqu-sz: Average I/O queue length. That is, delta(aveq)/ s/1000 (because the unit of aveq is milliseconds).
await: the average waiting time of each device I/O operation (milliseconds). That is, delta(ruse+wuse)/delta(rio+wio)#p#page title#e#
svctm: The average service time of each device I/O operation (milliseconds). That is, delta(use)/delta(rio+wio)
%util: What percentage of the time is used for I/O operations in a second, or Say how much time the I/O queue is non-empty in one second, that is, delta(use)/s/1000 (because the unit of use is milliseconds).

If %util is close to 100%, it means that there are too many I/O requests. The /O system is fully loaded and the disk may be bottlenecked.
If the idle is less than 70%, the IO pressure is large, and the general reading speed has more waits.
At the same time, you can combine vmstat to view the b parameter (the number of processes waiting for resources) and the wa parameter (the percentage of CPU time occupied by IO waiting, and the IO pressure is high when it is higher than 30%).
#p#Pagination title#e#In addition, the parameters of await should also be referenced with svctm. If the difference is too high, there must be an IO problem.
avgqu-sz is also a point to pay attention to when doing IO tuning. This is the size of the data directly operated each time. If the number of times is large, but the data is small, the IO will actually be small. If the data is large, the IO data will be high. It is also possible to pass avgqu-sz × ( r/s or w/s ) = rsec/s or wsec/s. In other words, the reading speed is determined by this.
svctm is generally smaller than await (because the waiting time of requests that are waiting at the same time is recalculated), the size of svctm is generally related to disk performance, and the load of CPU/memory will also affect it, and too many requests will indirectly lead to svctm Increase. The size of the await generally depends on the service time (svctm) and the length of the I/O queue and the issuing mode of the I/O request#p#page title#e#. If svctm is close to await, it means that there is almost no waiting time for I/O; if await is much larger than svctm, it means that the I/O queue is too long, and the response time obtained by the application is slow. If the response time exceeds the range that the user can tolerate, then Consider replacing faster disks, tweaking kernel elevator algorithms, optimizing applications, or upgrading CPUs.
Queue length (avgqu-sz) can also be used as an indicator to measure system I/O load, but since avgqu-sz is an average per unit time, it cannot reflect instantaneous I/O floods.

       Image metaphor:
       r/s+w/s is similar to the total number of payers and the
      average queue length (avgqu-sz) is similar to the average number of queues per unit time
#p#page title#e# Average service time (svctm) Similar to the cashier's collection speed
      Average waiting time (await) is similar to the average waiting time per person
      Average I/O data (avgrq-sz) is similar to the average number of things bought per person How much
       I/O operation rate (%util ) is similar to the amount of time someone is queuing in front of the checkout counter proportional to

       device IO operations: total IO(io)/s = r/s (read) + w/s (write) = 1.46 + 25.28 = 26.74
      On average, each device I/O operation takes only 0.36 milliseconds to complete, but now it takes 10.57 milliseconds to complete because there are too many requests (26.74 per second). If the requests are issued at the same time, the average waiting time can be calculated as follows:
      Average waiting time Time=Single I/O server time*(1+2+...+Total number of requests-1)/Total number
       of requests There are many I/0 requests issued per second, but the average queue is 4, which means that these requests are relatively uniform, and most of them Processing is relatively timely.

   Example 8: View cpu status
   Command:
    iostat -c 1 3
   Output:
#p#Page title#e#
Copy code
[root@CT1186 ~]# iostat -c 1 3
Linux 2.6.18-128.el5 (CT1186) December 2012 Jan 28

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


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326901912&siteId=291194637