OnCallReadyStart learning

mpstat: Report processors related statistics

mpstat [ -A ] [ -n ] [ -T ] [ -u ] [ -I { keyword[,...] | ALL } ] [ -N { node_list | ALL } ] [ -o JSON ] [ -P { cpu_list | ALL } ] [ interval [ count ] ]

What it does

mpstat writes the time spent by the CPUs in each mode (%usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle), for all CPUs together or per CPU with -P. With an interval it prints one report per interval and an Average line at the end (or at Ctrl+C).

Options you will use

-P { cpu_list | ALL }
per-processor statistics: ALL = every CPU plus the "all" line. The way to see one CPU at 100% while the rest idle.
-u
CPU utilization (the default report).
-I { SUM | CPU | SCPU | ALL }
interrupt statistics.
-n
summary CPU statistics by NUMA node.
-T
topology elements (socket and core) in the CPU report.
-A
same as -n -u -I ALL -N ALL -P ALL.
-o JSON
JSON output.
-V
print version number then exit.
interval [count]
report every INTERVAL seconds, COUNT times (no count = until Ctrl+C). The first report covers the time since boot (iostat: unless -y).

Examples

$ mpstat -P ALL 1

every CPU, every second

$ mpstat 2 5

all CPUs together, five 2-second reports

Gotchas

On the blog

Try mpstat in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.