mpstat — Per-CPU Usage Statistics
mpstat reports CPU utilization for all CPUs or a selected CPU over time. Use it when uptime shows high load and you need to know whether a single core is saturated (common with PHP workloads) or whether the whole system is CPU-bound. It can also help you spot high iowait (disk bottlenecks) and steal time (noisy neighbors on shared hosts).
Run mpstat -P ALL 1 5 to sample per-CPU usage every second. Look for high %usr/%sys (CPU pressure), high %iowait (disk wait), or high %steal (hypervisor contention).
Prerequisites
mpstat is provided by the sysstat package.
Install it:
- Ubuntu / Debian
- CentOS / RHEL
sudo apt update
sudo apt install -y sysstat
sudo dnf install -y sysstat
Verify:
which mpstat
mpstat -V
Core Syntax
mpstat [options] [interval [count]]
intervalis the sampling interval in seconds.countis the number of samples.
Key Options
| Option | What it does | Example | WordPress / VPS use case |
|---|---|---|---|
-P ALL | Report per-CPU stats | mpstat -P ALL 1 5 | Detect single-core saturation |
-P <list> | Select CPU(s) | mpstat -P 0 1 5 | Focus on a specific core |
-u | CPU utilization report | mpstat -u 1 5 | Standard utilization view |
-I ALL | Interrupt stats | mpstat -I ALL 1 5 | Diagnose interrupt-heavy workloads |
-o JSON | JSON output | mpstat -o JSON 1 1 | Automation and parsing |
Examples (Commands + Expected Output)
Field names and CPU counts depend on your kernel and sysstat version.
Overall CPU usage (single snapshot)
mpstat
Expected output:
Linux 6.x.x (server) 03/01/2026 _x86_64_ (2 CPU)
10:20:00 AM CPU %usr %sys %iowait %steal %idle
10:20:00 AM all 10.00 3.00 1.00 0.00 86.00
Use case: Quick snapshot to see if the system is broadly idle or busy.
Per-CPU sampling
mpstat -P ALL 1 3
Expected output:
10:20:01 AM CPU %usr %sys %iowait %steal %idle
10:20:01 AM 0 70.00 10.00 1.00 0.00 19.00
10:20:01 AM 1 10.00 2.00 0.00 0.00 88.00
Use case: Identify a single hot core caused by PHP or a single-threaded process.
Monitor a specific CPU
mpstat -P 0 1 3
Expected output:
10:20:01 AM CPU %usr %sys %iowait %steal %idle
10:20:01 AM 0 70.00 10.00 1.00 0.00 19.00
Use case: Track whether a single core remains pinned during an incident.
Check for I/O wait
mpstat -P ALL 1 3
Expected output:
CPU %usr %sys %iowait %steal %idle
all 20.00 5.00 15.00 0.00 60.00
Use case: High %iowait often indicates disk is the bottleneck (confirm with iostat).
Check for CPU steal time (shared hosts)
mpstat -P ALL 1 3
Expected output:
CPU %usr %sys %iowait %steal %idle
all 10.00 3.00 1.00 12.00 74.00
Use case: High %steal suggests the hypervisor is not giving you the CPU time you expect.
JSON output for automation
mpstat -o JSON 1 1
Expected output:
{"sysstat":{"hosts":[{"statistics":[{"cpu-load":[{"cpu":"all","usr":10.00,"sys":3.00,"iowait":1.00,"steal":0.00,"idle":86.00}]}]}]}}}
Use case: Feed per-CPU stats into tooling.
WordPress VPS Use Cases
| Symptom | What to look for | Command | Interpretation |
|---|---|---|---|
| High load average | One core pinned | mpstat -P ALL 1 5 | PHP can saturate one core even when others are idle |
| Slow requests | High iowait | mpstat 1 5 | Disk bottleneck (confirm with iostat -xz) |
| Unstable performance | High steal | mpstat 1 5 | Shared host contention |
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
mpstat: command not found | sysstat not installed | Install sysstat |
Output shows only all | Not using per-CPU mode | Add -P ALL |
| Hard to interpret results | Sampling too short | Increase count and watch trends |
Best Practices
- Sample multiple times (
interval count) to avoid conclusions from a single moment. - If
%iowaitis high, confirm withiostatand check disk saturation. - If
%stealis high, consider a plan upgrade or moving workloads.
Cheat Sheet
mpstat
mpstat 1 5
mpstat -P ALL 1 5
mpstat -P 0 1 5
mpstat -I ALL 1 5
mpstat -o JSON 1 1