Skip to main content

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).

Quick Summary

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:

install-sysstat-apt.sh
sudo apt update
sudo apt install -y sysstat

Verify:

verify-mpstat-installed.sh
which mpstat
mpstat -V

Core Syntax

mpstat-syntax.sh
mpstat [options] [interval [count]]
  • interval is the sampling interval in seconds.
  • count is the number of samples.

Key Options

OptionWhat it doesExampleWordPress / VPS use case
-P ALLReport per-CPU statsmpstat -P ALL 1 5Detect single-core saturation
-P <list>Select CPU(s)mpstat -P 0 1 5Focus on a specific core
-uCPU utilization reportmpstat -u 1 5Standard utilization view
-I ALLInterrupt statsmpstat -I ALL 1 5Diagnose interrupt-heavy workloads
-o JSONJSON outputmpstat -o JSON 1 1Automation and parsing

Examples (Commands + Expected Output)

Output varies

Field names and CPU counts depend on your kernel and sysstat version.

Overall CPU usage (single snapshot)

mpstat-default.sh
mpstat

Expected output:

example-output-mpstat-default.txt
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-per-cpu-sampling.sh
mpstat -P ALL 1 3

Expected output:

example-output-mpstat-per-cpu.txt
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-single-cpu.sh
mpstat -P 0 1 3

Expected output:

example-output-mpstat-cpu0.txt
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-iowait-check.sh
mpstat -P ALL 1 3

Expected output:

example-output-mpstat-iowait.txt
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-steal-time.sh
mpstat -P ALL 1 3

Expected output:

example-output-mpstat-steal.txt
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-json-output.sh
mpstat -o JSON 1 1

Expected output:

example-output-mpstat-json.txt
{"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

SymptomWhat to look forCommandInterpretation
High load averageOne core pinnedmpstat -P ALL 1 5PHP can saturate one core even when others are idle
Slow requestsHigh iowaitmpstat 1 5Disk bottleneck (confirm with iostat -xz)
Unstable performanceHigh stealmpstat 1 5Shared host contention

Troubleshooting

ProblemLikely causeFix
mpstat: command not foundsysstat not installedInstall sysstat
Output shows only allNot using per-CPU modeAdd -P ALL
Hard to interpret resultsSampling too shortIncrease count and watch trends

Best Practices

  • Sample multiple times (interval count) to avoid conclusions from a single moment.
  • If %iowait is high, confirm with iostat and check disk saturation.
  • If %steal is high, consider a plan upgrade or moving workloads.
Cheat Sheet
mpstat-cheat-sheet.sh
mpstat
mpstat 1 5
mpstat -P ALL 1 5
mpstat -P 0 1 5
mpstat -I ALL 1 5
mpstat -o JSON 1 1

What's Next