iostat
Overview
The iostat
command reports CPU statistics and input/output statistics for devices and partitions. It’s useful for monitoring system input/output device loading.
Syntax
iostat [options] [interval [count]]
Common Options
Option | Description |
---|---|
-c |
Display CPU utilization |
-d |
Display device utilization |
-h |
Human readable sizes |
-k |
Display in kilobytes |
-m |
Display in megabytes |
-N |
Display registered device mapper names |
-p [device] |
Display statistics for block devices |
-t |
Print time information |
-x |
Display extended statistics |
-y |
Omit first report |
-z |
Omit devices with no activity |
Key Use Cases
- System performance monitoring
- Disk I/O analysis
- Bottleneck identification
- Capacity planning
- Performance tuning
Examples with Explanations
Example 1: Basic Usage
iostat
Show CPU and device statistics
Example 2: Extended Stats
iostat -x 2 5
Show extended stats every 2 seconds, 5 times
Example 3: Device Specific
iostat -p sda 1
Monitor specific device every second
Understanding Output
CPU statistics: - %user: User level processing - %nice: User level with nice priority - %system: System level processing - %iowait: Waiting for I/O - %steal: Time stolen by virtualization - %idle: Idle time
Device statistics: - tps: Transfers per second - kB_read/s: Kilobytes read per second - kB_wrtn/s: Kilobytes written per second - kB_read: Total kilobytes read - kB_wrtn: Total kilobytes written
Common Usage Patterns
Continuous monitoring:
iostat 2
Specific device analysis:
iostat -xd /dev/sda
Human readable format:
iostat -h -p ALL
Performance Analysis
- I/O bottleneck detection
- Disk utilization patterns
- CPU usage correlation
- Read/write ratios
- Queue length analysis
Additional Resources
Best Practices
- Regular monitoring
- Baseline establishment
- Alert thresholds
- Trend analysis
- Documentation
Troubleshooting
- High wait times
- Queue length issues
- Bandwidth bottlenecks
- Device saturation
- CPU bottlenecks