One Linux command per day (PNS)--iostat command

Source: Internet
Author: User
Tags disk usage

The Iostat in a Linux system is an abbreviation for I/O statistics (input/output statistics), and the Iostat tool monitors the system's disk operation activity. It is characterized by the reporting of disk activity statistics, as well as the reporting of CPU usage. Like Vmstat, Iostat also has a weakness, that is, he can not analyze a process in depth, only the overall situation of the system to analyze. Iostat belongs to the Sysstat package. Can be installed directly with Yum install Sysstat.

1. Command format:

iostat[parameter] [TIME] [times]

2. Command function:

Through the Iostat convenient to view the CPU, network card, TTY device, disk, CD-ROM and so on the activity of equipment, load information.

3. Command parameters:

-C Display of CPU usage

-D Display disk usage

-K displays in kilobytes

-m displays in units of M.

-N Display of disk array (LVM) information

-N Display of NFS usage

-p [Disk] displays disk and partition conditions

-t display terminal and CPU information

-X to display detailed information

-V Display version information

4. Usage examples:

Example 1: Show all device load conditions

Command: Iostat

Description: CPU Attribute Value Description

%user:cpu percentage of time in user mode

%nice:cpu percentage of time in user mode with nice value

%system:cpu percentage of time in System mode

%iowait:cpu the percentage of time to wait for the input output to finish

%steal: Managing the Hypervisor Another virtual processor, the percentage of the unconscious wait time for the dummy CPU

%IDLE:CPU Idle time percentage

Note: If the value of%iowait is too high, indicating that there is an I/O bottleneck on the hard disk, the%idle value is high, the CPU is idle, if the%idle value is higher than the single system response is slow, it is possible that the CPU waits to allocate memory, the memory capacity should be increased. If the%idle value continues below 10, the system's CPU processing power is relatively low, indicating that the most resource to be addressed in the system is the CPU.

Disk Property Value Description:

RRQM/S: The number of read operations per second for the merge. namely RMERGE/S

R/S: Number of Read I/O devices completed per second. namely RIO/S

W/S: Number of write I/O devices completed per second. namely WIO/S

RSEC/S: Number of Read sectors per second. namely RSECT/S

WSEC/S: Number of Write sectors per second. namely WSECT/S

rkb/s: Reads K bytes per second. Is rsect/s, because the size of each sector is 512 bytes.

wkb/s: Writes K bytes per second. Is the general of wsect/s.

Avgrq-sz: Average data size Per device I/O operation (Sector)

Avgqu-sz: Average I/O Queue Length

Await: Average wait time per device I/O operation (MS)

SVCTM: Average service time Per device I/O operation (MS)

%util: How much time in a second is spent on I/O operations, which is the percentage of CPU consumed by IO

Note: If%util is close to 100%, it indicates that there are too many I/O requests and that the I/O system is full, the disk may have bottlenecks. If the SVCTM is closer to await, it indicates that I/O has almost no wait time, and if the await is much larger than SVCTM, indicating that the I/O queue is too long and the IO response is too slow, the necessary optimizations are required. If the Avgqu-sz is larger, it also indicates that there is an equivalent IO waiting.

Example 2: Timed display of all information

Command: Iostat 2 3 Refreshes the display every 2 seconds and displays 3 times. ------This can be written as a monitoring script and refreshed periodically.

Example 3: Displaying specified disk information

Command: iostat-d sda1

Example 4: Displaying TTY and CPU information

Command: IOSTAT-T

Example 5: Display all information in M

Command: Iostat-m

Example 6: Viewing TPS and throughput information

Command: iostat-d-K 1 1

Description

TPS the number of times the device is transferred per second (indicate, transfers per second, were issued to the devices). " One transmission "means" one I/O request ". Multiple logical requests may be merged 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: The total amount of data written.

These units are kilobytes.

In the example above, we can see statistics on the disk SDA and its partitions, when the total disk TPS for statistics is 22.73, and the following is the TPS for each partition. (because it is an instantaneous value, the total TPS is not strictly equal to the sum of each partition TPs)

Example 7: Viewing device utilization (%UTIL), Response time (await)

Command: iostat-d-x-k 1 1

Description

RRQM/S: The number of read operations per second for the merge. Delta (rmerge)/s

WRQM/S: The number of write operations per second for the merge. Delta (wmerge)/s

R/S: Number of Read I/O devices completed per second. Delta (RIO)/s

RSEC/S: Number of Read sectors per second. Delta (rsect)/s

WSEC/S: Number of Write sectors per second. Delta (wsect)/s

rkb/s: Reads K bytes per second. is half the rsect/s because the sector size is 512 bytes (calculation required)

wkb/s: Writes K bytes per second. Is the general of wsect/s. (Calculation required)

Avgrq-sz: The average data size (sector) per device I/O operation. Delta (rsect+swect)/delta (Rio+wio)

Avgqu-sz: Average I/O queue length. That is Delta (AVEQ)/s/1000 (because the Aveq is in milliseconds).

Await: The average service time (in milliseconds) per device I/O operation. Delta (ruse+wuse)/delta (Rio+wio)

SVCTM: The average service time (in milliseconds) per device I/O operation. Delta (use)/delta (RIO+WIO)

%util: How much time per second is spent on I/O operations, or how much time in a second I/O queues are non-empty, that is, Delta (use)/s/1000 (because the use is in milliseconds)

If%util is close to 100%, it indicates that there are too many I/O requests, the I/O system is full, and the disk may have bottlenecks.

Idle less than 70% io pressure is larger, the general reading speed has more wait.

You can also combine vmstat to see the B parameter (number of processes waiting for a resource) and WA see (Percentage of CPU time that IO waits, higher than 30% when IO pressure is high)

In addition to await the parameters are more and SVCTM to reference. If the difference is too high, there must be an IO problem.

Avgqu-sz is also an IO tuning need to pay attention to, this is the direct operation of the size of the data, if the number of times, but the small amount of data, in fact, the IO will be very small, if the data take the big, IO data will be high. Also available through Avgqu-sz * (r/s or w/s) = RSEC/S or wsec/s. That is to say, the speed of reading and writing is determined by this.

SVCTM generally less than await (because the waiting time for a colleague's waiting is repeated), the size of SVCTM is generally related to disk performance, cpu/memory load will have an impact on it, too many requests will indirectly lead to SVCTM increase. The size of an await typically depends on the service time (SVCTM) and the length of the I/O queue and the emit mode of the I/O request. If the SVCTM is closer to await, stating that I/O has almost no waiting time, if the await is much larger than SVCTM, the I/O queue is too long, the response time should be slower, and if the response time is more than the user can tolerate, then consider replacing the faster disk and tuning the kernel ele Vator algorithm, optimize the application, or upgrade the CPU.

The queue Length (AVGQU-SZ) can also be used as an indicator for measuring the system I/O load, but because Avgqu-sz is averaged over a unit time, it does not reflect instantaneous I/O flooding.

Image of Metaphor:

R/S+W/S The total number of similar and payment persons.

Average Queue Length (AVGQU-SZ) is similar to the number of average queueing people in a unit time

Average service time (SVCTM) is similar to the cashier's payment time

Average wait time (await) is similar to the average wait time per person

Average I/O data (AVGRQ-SZ) is similar to the average number of things each person buys

I/O operation rate (%util) is similar to the time scale at which a person is queued at the cashier

Device IO operation: Total io/s=r/s+w/s

The average Per Device I/O operation takes only 0.36 milliseconds to complete and now takes 10.57 milliseconds because there are too many requests (26.74 per second), and if the request is made at the same time, the average wait time can be calculated as: Average wait time = single I/O server time * (1+2+3...+ Total number of requests-1)/total number of requests.

There are many I/O requests per second, but the average queue is 4, which means that these requests are more uniform and most of the processing is more timely.

Example 8: Viewing CPU status

Command: IOSTAT-C 1 3 View CPU status, refresh 1 times per second, refresh 3 times altogether.

It seems that this command, including several previous commands to view the state of the system, has been useful and has been used recently.

  

One Linux command per day (PNS)--iostat command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.