brief introduction

iostat Mainly used for monitoring system equipment IO Load condition ,iostat Display statistics since system startup when running for the first time , And then run iostat Statistics since the last time the command was run will be displayed . Users can get the required statistics by specifying the number and time of statistics .

 

grammar

iostat [ -c ] [ -d ] [ -h ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [ device [...] | ALL ] [ -p [ device [,...] | ALL ] ] [ interval [ count ] ]

 

Get started with

iostat -d -k 2

Parameters -d Express , Display device ( disk ) Using a state ;-k Some use block Is mandatory for columns of units Kilobytes In units of ;2 Express , The data shows every 2 Refresh every second .

Output is as follows

 

iostat -d -k 1 10
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda              39.29        21.14         1.44  441339807   29990031
sda1              0.00         0.00         0.00       1623        523
sda2              1.32         1.43         4.54   29834273   94827104
sda3              6.30         0.85        24.95   17816289  520725244
sda5              0.85         0.46         3.40    9543503   70970116
sda6              0.00         0.00         0.00        550        236
sda7              0.00         0.00         0.00        406          0
sda8              0.00         0.00         0.00        406          0
sda9              0.00         0.00         0.00        406          0
sda10            60.68        18.35        71.43  383002263 1490928140
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda             327.55      5159.18       102.04       5056        100
sda1              0.00         0.00         0.00          0          0

 

The meaning of the output information

 

tps: Number of transfers per second for this device (Indicate the number of transfers per second that were issued to the device.)." Primary transmission " intend " once I/O request ". Multiple logical requests may be merged into " once I/O request "." Primary transmission " The requested size is unknown .
kB_read/s: Slave devices per second (drive expressed) Amount of data read ;
kB_wrtn/s: Devices per second (drive expressed) Amount of data written ;
kB_read: Total data read ;
kB_wrtn: The total amount of data written ; These units are Kilobytes.

 

In the example above , We can see the disk sda And the statistics of its various partitions , At that time, the total number of disks counted was TPS yes 39.29, Here are the sections TPS.( Because it's instantaneous , So always TPS It's not exactly equal to every partition TPS The sum of )

 

The name of the device to be monitored is sda, The output of this command is exactly the same as the above command .

 iostat -d sda 2

All hard disk devices are monitored by default , Now it's designated to monitor only sda. 

 

-x Parameters

iostat There is also a more commonly used option -x, This option will be used to display and io Relevant extended data .

iostat -d -x -k 1 10
Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          1.56  28.31  7.80 31.49   42.51    2.92    21.26     1.46     1.16     0.03    0.79   2.62  10.28
Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          2.00  20.00 381.00  7.00 12320.00  216.00  6160.00   108.00    32.31     1.75    4.50   2.17  84.20

 

Meaning of output information

 

rrqm/s: How many read requests are related to this device per second Merge 了 ( When system calls need to read data ,VFS Send the request to each FS, If FS It is found that different read requests read the same Block The data of ,FS Will merge this request Merge);wrqm/s: How many write requests are related to this device per second Merge 了 .
rsec/s: Number of sectors read per second ;
wsec/: Number of sectors written per second .
rKB/s:The number of read requests that were issued to the device per second;
wKB/s:The number of write requests that were issued to the device per second;
avgrq-sz  Average request sector size
avgqu-sz  Is the average length of the request queue . without doubt , The shorter the queue, the better .    
await:   every last IO The average processing time of a request ( The units are microseconds in milliseconds ). So this could be interpreted as IO Response time of , General terrestrial system IO Response time should be below 5ms, If it is greater than 10ms It's bigger .
          This time includes queue time and service time , in other words , In general ,await Greater than svctm, The smaller the difference between them , The shorter the queue time , Otherwise, the greater the difference , The longer the queue , There's something wrong with the system .
svctm     Represents the average per device I/O Service time of operation ( In Milliseconds ). If svctm The value of is equal to await Very close to , Almost none I/O wait for , Disk performance is good , If await Is much higher than svctm Value , said I/O The queue is too long ,          Applications running on the system will slow down .
%util:  All processing in statistical time IO Time , Divided by the total statistical time . for example , If the statistical interval 1 second , The device has 0.8 Seconds in the treatment of IO, and 0.2 Seconds to spare , So the device's %util = 0.8/1 = 80%, So this parameter indicates how busy the device is
. In a general way , If the parameter is 100% Means the device is running at close to full capacity ( Of course if you have multiple disks , Even if %util yes 100%, Because of the concurrency of the disk , So disk usage is not necessarily a bottleneck ).

 

 

-c Parameters

iostat It can also be used to obtain cpu Some state values :

iostat -c 1 10
avg-cpu: %user %nice %sys %iowait %idle
1.98 0.00 0.35 11.45 86.22
avg-cpu: %user %nice %sys %iowait %idle
1.62 0.00 0.25 34.46 63.67

 

Common use

iostat -d -k 1 10         # see TPS And throughput information ( The unit of disk read / write speed is KB)
iostat -d -m 2            # see TPS And throughput information ( The unit of disk read / write speed is MB)
iostat -d -x -k 1 10      # View device usage (%util)、 response time (await) iostat -c 1 10 # see cpu state 

 

 

The example analysis

 

ostat -d -k 1 |grep sda10
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda10            60.72        18.95        71.53  395637647 1493241908
sda10           299.02      4266.67       129.41       4352        132
sda10           483.84      4589.90      4117.17       4544       4076
sda10           218.00      3360.00       100.00       3360        100
sda10           546.00      8784.00       124.00       8784        124
sda10           827.00     13232.00       136.00      13232        136

 

See above , The average number of disk transfers per second is about 400; Disk reads about... Per second 5MB, Write about 1MB.

 

iostat -d -x -k 1
Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          1.56  28.31  7.84 31.50   43.65    3.16    21.82     1.58     1.19     0.03    0.80   2.61  10.29
sda          1.98  24.75 419.80  6.93 13465.35  253.47  6732.67   126.73    32.15     2.00    4.70   2.00  85.25
sda          3.06  41.84 444.90 54.08 14204.08 2048.98  7102.04  1024.49    32.57     2.10    4.21   1.85  92.24

You can see the average response time of the disk <5ms, Disk usage >80. The disk is responding normally , But it's already busy .

 

from  http://www.orczhou.com/index.php/2010/03/iostat-detail/