mpstat
Overview
The mpstat command reports processors related statistics. It shows CPU utilization for all CPUs or specific ones.
Syntax
mpstat [options] [interval [count]]Common Options
| Option | Description |
|---|---|
-A |
All CPU info |
-P ALL |
All processors |
-P list |
CPU list |
-u |
CPU utilization |
-I |
Interrupts info |
-n |
Header once |
-T |
Temperature |
-V |
Version info |
-o JSON |
JSON output |
-N |
Node stats |
Output Fields
| Field | Description |
|---|---|
| CPU | Processor number |
| %usr | User time |
| %nice | Nice time |
| %sys | System time |
| %iowait | IO wait time |
| %irq | Hardware interrupt |
| %soft | Software interrupt |
| %steal | Hypervisor time |
| %guest | Virtual CPU time |
| %idle | Idle time |
Key Use Cases
- CPU monitoring
- Performance analysis
- Load balancing
- System tuning
- Troubleshooting
Examples with Explanations
Example 1: Basic Usage
mpstatAll CPU average
Example 2: Per CPU
mpstat -P ALLAll processors stats
Example 3: Interval
mpstat 2 5Every 2s, 5 times
Common Usage Patterns
All CPUs:
mpstat -P ALL 1Specific CPU:
mpstat -P 0With interrupts:
mpstat -I ALL
Performance Metrics
- CPU usage
- System load
- Interrupt rates
- IO wait
- Idle time
Additional Resources
Best Practices
- Regular monitoring
- Check all CPUs
- Track trends
- Document baselines
- Compare cores
Performance Analysis
- CPU utilization
- Load distribution
- Interrupt handling
- System overhead
- Process impact
Troubleshooting
- High CPU usage
- Load imbalance
- Interrupt storms
- System overhead
- Process issues
Common Issues
- CPU saturation
- Uneven loads
- High interrupts
- System time
- Poor scaling