For I/o-bond-type processes, we often use the Iostat tool to view the number of process IO requests, the time it takes to process IO requests, and to analyze whether there are bottlenecks in IO in the process and operating system interactions.
The following uses an instance of the Iostat command to show you how to use Iostat to view the status of the IO request, the System IO processing capability, and the meaning of the fields in the command execution results.
1. Perform iostat without option
Let's look at the output of the direct execution Iostat:
Linux # Iostat
linux 2.6.16.60-0.21-smp (Linux) 06/12/12
avg-cpu: %user %nice%system %steal %idle
0.07 0.00 0.05 0.06 0.00 99.81 Device
: TPS blk_read/s blk_wrtn/s blk_read blk_wrtn
SDA 0.58 9.95 37.47 6737006 25377400
sdb 0.00 0.00 0.00 824 0
Perform iostat separately, showing the results for statistics from the system boot to the current execution time. In the above output, in addition to the top of the line indicating the system version, hostname, and date, there are two other parts:
AVG-CPU: Overall CPU usage statistics, for multi-core CPUs, here is the average of all CPUs
Device: IO statistics for each disk device
For the CPU statistics line, we mainly look at the value of iowait, which indicates when the CPU is waiting for the IO request to complete. The meanings of the columns in the device are as follows:
Device: Device name displayed as SDX
TPS: Number of IO read and write requests issued per second process
BLK_READ/S: Number of sectors read per second (one sector is 512bytes)
BLK_WRTN/S: Number of write sectors per second
Blk_read: Total number of read sectors in sampling time interval
BLK_WRTN: Total number of write sectors in sampling time interval
We can use the-C option to display the results of the AVG-CPU section separately, using the-D option to display the device part of the information separately.
2. Specify sampling interval and number of samples
As with the SAR command, we can specify the sampling interval and the number of samples of the Iostat command in the form of "iostat interval [count]":
Linux # iostat-d 1 2
linux 2.6.16.60-0.21-SMP (Linux) 06/13/12
Device: TPs blk_read/s Blk_ WRTN/S blk_read blk_wrtn
SDA 0.55 8.93
36.27 6737086 27367728 SDB 0.00 0.00 0.00 928 0
Device: TPs blk_read/s blk_wrtn/s Read blk_wrtn
SDA 2.00 0.00 72.00 0 a SDB 0.00 0.00 0.00 0 0
The above command output device information, sampling time is 1 seconds, sampling 2 times, if not specify the number of samples, then Iostat will always output sampling information, until press "CTRL + C" to exit the command. Note that the 1th sampling information is the same as the effect of performing iostat alone, for statistics from the system boot up to the current execution time.
3. Display read-write information in KB (-K option)
We can use the-k option to specify that the partial output of the iostat is in kilobytes instead of sectors:
Linux # iostat-d-K
linux 2.6.16.60-0.21-SMP (Linux) 06/13/12
Device: TPs kb_read/s Kb_wrtn /s kb_read kb_wrtn
SDA 0.55 4.46
18.12 3368543 13686096 sdb 0.00 0.00 0.00 464 0
In the above output, the values for kb_read/s, KB_WRTN/S, Kb_read, and Kb_wrtn are in kilobytes, compared to the number of sectors, where the value is half of the original value (1KB=512BYTES*2)
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/