YouTip LogoYouTip

Linux Comm Iostat

[![Image 1: Linux Command Manual](#) Linux Command Manual](#) * * * ## 1. iostat Command Overview iostat (Input/Output Statistics) is a powerful performance monitoring tool in Linux systems, part of the sysstat package. It is mainly used to monitor disk I/O activity and CPU usage. ### 1.1 Basic Functions * Monitor system disk I/O read/write speeds * View CPU utilization * Statistics on device load * Identify I/O performance bottlenecks ### 1.2 Typical Application Scenarios * Server performance tuning * Storage device performance analysis * System bottleneck troubleshooting * Capacity planning * * * ## 2. Installation and Basic Usage ### 2.1 Installation Methods Most Linux distributions do not install iostat by default; you need to install the sysstat package first: ## Example # Ubuntu/Debian sudo apt-get install sysstat # CentOS/RHEL sudo yum install sysstat # Fedora sudo dnf install sysstat ### 2.2 Basic Command Format ## Example iostat #### Simple Examples ## Example # Display statistics for all devices once iostat # Refresh every 2 seconds, display 5 times total iostat 2 5 * * * ## 3. Command Options Explained ### 3.1 Common Options | Option | Description | | --- | --- | | -c | Show CPU usage only | | -d | Show disk usage only | | -h | Display in human-readable format (e.g., KB, MB, GB) | | -k | Display data in KB | | -m | Display data in MB | | -N | Show device mapper names | | -p | Show statistics for specified device or partition | | -t | Show timestamp | | -x | Show extended statistics | | -y | Skip first statistics (usually used with interval) | ### 3.2 Advanced Options | Option | Description | | --- | --- | | -z | Omit output for devices with zero activity | | -j ID | Show persistent names for specified devices | | --dec={0|1|2} | Specify number of decimal places | * * * ## 4. Output Interpretation ### 4.1 CPU Statistics Section avg-cpu: %user %nice %system %iowait %steal %idle 5.32 0.00 1.06 0.25 0.00 93.37 * **%user**: CPU usage at user level (applications) * **%nice**: CPU usage of processes with priority adjustment * **%system**: CPU usage at system level (kernel) * **%iowait**: Percentage of time CPU spent waiting for I/O operations to complete * **%steal**: "Stolen" time in virtualized environments * **%idle**: CPU idle time percentage ### 4.2 Disk Statistics Section (Basic) Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 1.02 12.34 5.67 1234567 567890 * **tps**: Transfers per second * **kB_read/s**: Data read per second (KB) * **kB_wrtn/s**: Data written per second (KB) * **kB_read**: Total data read (KB) * **kB_wrtn**: Total data written (KB) ### 4.3 Extended Statistics (-x option) Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 0.50 1.00 0.50 12.00 4.00 21.33 0.02 10.00 8.00 14.00 6.00 0.90 * **rrqm/s**: Read requests merged per second * **wrqm/s**: Write requests merged per second * **r/s**: Read I/O operations completed per second * **w/s**: Write I/O operations completed per second * **rkB/s**: KB read per second * **wkB/s**: KB written per second * **avgrq-sz**: Average data size per I/O operation (sectors) * **avgqu-sz**: Average I/O queue length * **await**: Average wait time per I/O operation (milliseconds) * **r_await**: Average wait time for read operations (milliseconds) * **w_await**: Average wait time for write operations (milliseconds) * **svctm**: Average service time per I/O operation (milliseconds) * **%util**: Device bandwidth utilization percentage * * * ## 5. Practical Examples and Analysis ### 5.1 Monitor Specific Disk ## Example # Monitor sda disk, refresh every 2 seconds, display 3 times iostat -d-x sda 2 3 ### 5.2 Comprehensive CPU and Disk Monitoring ## Example # Monitor CPU and disk, refresh every 5 seconds, continuous display iostat -c-d-x-t 5 ### 5.3 Display in MB Units ## Example # Display disk statistics in MB iostat -d-m ### 5.4 Monitor All Partitions ## Example # Monitor all partitions, including LVM iostat -p ALL * * * ## 6. Performance Metrics Interpretation and Optimization Suggestions ### 6.1 Key Performance Indicators 1. **%util**: Device utilization * > 80% indicates device is near saturation * Sustained 100% indicates device has become a bottleneck 2. **await**: I/O wait time * Normally should be 50ms indicates possible performance issues 3. **avgqu-sz**: Queue length * > 1 indicates device may be overloaded ### 6.2 Common Problem Diagnosis #### Problem 1: High %util but low throughput * Possible cause: Too much random I/O * Solution: Optimize application I/O patterns, consider using SSD #### Problem 2: High await but low %util * Possible cause: Controller or bus bottleneck * Solution: Check HBA card or storage controller #### Problem 3: Abnormally high rkB/s or wkB/s * Possible cause: Application doing heavy read/write * Solution: Optimize application or add cache * * * ## 7. Using with Other Tools ### 7.1 Combined with vmstat ## Example # Monitor memory and I/O simultaneously vmstat 1 5& iostat -x 1 5 ### 7.2 Combined with sar ## Example # View historical I/O data sar -d ### 7.3 Combined with iotop ## Example # Identify specific high I/O processes iotop * * * ## 8. Summary and Best Practices ### 8.1 Usage Recommendations 1. For production environment monitoring, use -x option to get detailed data 2. For long-term monitoring, combine with sar to collect historical data 3. When analyzing performance issues, pay attention to both CPU and I/O data 4. Comparing statistics from different time periods is more meaningful ### 8.2 Common Command Combinations ## Example # Comprehensive monitoring command iostat -c-d-x-t-m 5 # Monitor disk extended information only iostat -d-x 2 # Monitor specific partition iostat -p sda1 -x 1 10 By mastering the iostat command, system administrators can effectively monitor and analyze Linux system I/O performance, and promptly discover and resolve storage-related performance bottleneck issues. [![Image 2: Linux Command Manual](#) Linux Command Manual](#)
← Linux Comm SarLinux Comm Uptime β†’