mpstat
Overview
The mpstat
command reports processor-related statistics. It displays CPU utilization for each available processor and overall averages.
Syntax
mpstat [options] [interval [count]]
Common Options
Option | Description |
---|---|
-A |
Report all CPU statistics |
-I |
Report interrupts statistics |
-P {cpu|ALL} |
Processor to monitor |
-u |
CPU utilization |
-V |
Version information |
-n |
Report summary in JSON format |
--dec=N |
Number of decimal places |
Key Use Cases
- CPU performance monitoring
- Load balancing analysis
- System troubleshooting
- Performance tuning
- Capacity planning
Examples with Explanations
Example 1: Basic Usage
mpstat
Show CPU statistics
Example 2: All CPUs
mpstat -P ALL 2 5
Show all CPU stats every 2 seconds, 5 times
Example 3: Specific CPU
mpstat -P 0
Show statistics for CPU 0
Understanding Output
Fields explained: - %usr: User level processing - %nice: User level with nice priority - %sys: System level processing - %iowait: Waiting for I/O - %irq: Hardware interrupts - %soft: Software interrupts - %steal: Time stolen by virtualization - %guest: Time spent running virtual CPU - %idle: Idle time
Common Usage Patterns
Continuous monitoring:
mpstat 1
CPU-specific analysis:
mpstat -P 1 2
JSON output:
mpstat -n -P ALL
Performance Analysis
- Per-processor utilization
- Interrupt handling
- I/O wait impact
- Virtualization overhead
- Load distribution
Additional Resources
Best Practices
- Regular monitoring
- Baseline establishment
- Load balancing checks
- Interrupt distribution
- Performance correlation
Troubleshooting
- High CPU usage
- Interrupt storms
- I/O bottlenecks
- Load imbalances
- Virtualization issues