brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mpstat -P ALL shows what each CPU core is doing, not just the average

Linux
~/tips/tip-performance-mpstat-p-all

mpstat -P ALL 2 5

Print one line per CPU core every few seconds to spot a single busy core, I/O wait or steal time.

The load average hides things. A single busy core can slow a service while the overall number looks calm, and mpstat is the quick way to see that on a Linux box.

The command reports statistics per processor:

mpstat -P ALL 2 5

The man page describes that exact example as five reports for all processors at two second intervals. You get one row per core, counted from 0, plus a row for the global average. The default report is a CPU utilisation table with the columns %usr, %nice, %sys, %iowait, %irq, %soft, %steal, %guest, %gnice and %idle.

You can name cores too. -P takes a comma-separated list or a range, like mpstat -P 0,2,4-7 1, and the page says offline processors aren’t displayed.

I’d look at a few columns first. %iowait is the share of idle time during which a disk request was outstanding, so a high value points to storage as the bottleneck. %steal is time the virtual CPU waits while the hypervisor serves another virtual processor, which matters on a VM or a cheap VPS. %soft is time spent on software interrupts.

One caveat: %iowait only counts time the core would otherwise be idle, so a low value doesn’t prove the disk is fine. It is also a snapshot per interval, not a history.

Further reading: mpstat(1) manual page

Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link