Introducing the “Sovereign Snippets” Series: Most of our time is spent in complex configurations, but the real power of a Linux system often hides in the short, punchy commands we use every day to maintain control over our hardware. I’m starting this series to document the specific “one-liners” I use to audit, secure, and manage my systems. No fluff – just functional tools for those who prefer the CLI over a GUI.
Technically Alive, Socially Unavailable
Every sysadmin knows the frustration of diagnosing a server that refuses to die cleanly. You run uptime and see an elevated load average. You check free -h and see there is still memory available. Monitoring says the host is green. Meanwhile, SSH takes thirty seconds just to echo a single keystroke back to your terminal.
The problem is that load average is a blunt instrument. It tells you how many tasks are currently runnable or stuck in uninterruptible sleep (D state). What it doesn’t tell you is how much actual, productive wall-clock time the machine is losing to CPU, memory, or I/O contention.
Linux Pressure Stall Information (PSI) measures that lost time directly. Instead of guessing whether a load average of 6.40 is healthy parallelism or a storage meltdown, PSI tells you exactly what percentage of the time your tasks are sitting around waiting for resources instead of doing work. It is the single best tool for diagnosing intermittent memory spikes, storage stalls, and servers that remain technically alive while becoming socially unavailable.
Step 1: Verify PSI and Take a Snapshot
First, confirm that your kernel exposes the PSI interface:
ls /proc/pressureIf you see cpu, io, and memory, you are in business. Grab an immediate, system-wide snapshot of all three subsystems:
grep -H . \
/proc/pressure/cpu \
/proc/pressure/memory \
/proc/pressure/io(Using grep -H . is a clean CLI trick to print every line prefixed with its filename, saving you from writing a loop around cat).
Typical output looks like this:
/proc/pressure/memory:some avg10=2.35 avg60=0.71 avg300=0.19 total=918223
/proc/pressure/memory:full avg10=0.84 avg60=0.20 avg300=0.05 total=281104Step 2: Reading the Numbers
PSI splits stall metrics into two lines – some and full – and understanding the difference is the entire point of the tool:
some: The percentage of time in which at least one task was stalled waiting for that resource. Some work may still be getting done on other cores, but friction has started.full: The percentage of time in which every non-idle task was simultaneously stalled. Nobody is getting any useful work done; the machine is effectively frozen on that resource.
Here is how to interpret the fields without fooling yourself:
- The Windows (
avg10,avg60,avg300): These are moving averages representing the percentage of wall-clock time lost over the last 10, 60, and 300 seconds. - Memory Contention: A rising
memory somemeans tasks are increasingly waiting on memory allocation or page faults. Sustainedmemory fullis far more dangerous – it usually accompanies aggressive reclaim thrashing and is the prelude to an OOM killer visit (the exact crime scene we autopsied in Snippet #13). - I/O Stalls: A high
io fullmeans all productive, non-idle work on the system was blocked waiting on storage at the exact same time. - The
cpu fullException: On a system-wide level,cpu fullis defined as meaningless (if the CPU is busy running tasks, something is doing work) and is reported as zero for compatibility. Always usecpu someto evaluate CPU contention. - The
totalCounter: This is the cumulative stall time in microseconds since boot. Never compare rawtotalvalues between two different machines; instead, measure the delta across a fixed time interval.
Step 3: Live Monitoring and Bounded Incident Sampling
When a server is actively misbehaving, watch the short-term pressure roll in every second:
watch -n 1 \
'grep -H . /proc/pressure/cpu /proc/pressure/memory /proc/pressure/io'If you are trying to catch intermittent stalls – or need hard evidence to attach to a post-mortem – capture a bounded one-minute sample with high-precision timestamps and save it to disk:
timeout 60s bash -c '
while true; do
date -Ins
grep -H . \
/proc/pressure/cpu \
/proc/pressure/memory \
/proc/pressure/io
sleep 5
done
' | tee /var/tmp/psi-sample.logJust like our tcpdump and nftables snippets, wrapping the loop in timeout 60s guarantees that your diagnostic capture stops automatically instead of silently filling /var/tmp while you get pulled into an incident call.
Step 4: Blaming the Right Daemon (Per-Service PSI)
System-wide /proc/pressure tells you the house is on fire. On a cgroup v2 system, the kernel also exposes per-cgroup pressure files, allowing you to distinguish between “the machine is under pressure” and “this particular daemon is eating the furniture.”
Query systemd for a service’s control group path and inspect its dedicated PSI counters:
control_group=$(
systemctl show \
--property=ControlGroup \
--value nginx.service
)
grep -H . \
"/sys/fs/cgroup${control_group}"/cpu.pressure \
"/sys/fs/cgroup${control_group}"/memory.pressure \
"/sys/fs/cgroup${control_group}"/io.pressureReplace nginx.service with whatever suspect unit you are investigating. If the service’s own memory.pressure or io.pressure is spiking while the rest of the machine is quiet, you have isolated your culprit.
The Caveats (Safety and Portability)
PSI is clean, read-only, and lightweight, but it comes with a few operational realities you need to keep in mind:
- Kernel Support: PSI entered the mainline Linux kernel in 4.20 (released December 23, 2018) and requires a kernel compiled with
CONFIG_PSI. Administrators can also explicitly disable it via thepsi=0boot parameter. Per-service inspection additionally requires cgroup v2. - The Container Illusion:
/proc/pressurereports system-wide pressure. If you read/proc/pressurefrom inside a container, you may be looking at host-level pressure rather than pressure caused by your container. Always read the container’s specific cgroup pressure files when workload attribution matters. - Effect, Not Cause: PSI measures the symptom of resource contention, not the specific PID causing it. Once PSI confirms whether you are fighting CPU, memory, or I/O stalls, correlate the timestamps with
systemd-cgtop,pidstat,iotop, or your service metrics to find the offending process. - Context Matters: There is no universal “bad” PSI percentage. A nightly batch-processing node and a latency-sensitive web host tolerate very different levels of stalled time. A brief spike in
someis often completely harmless; sustainedfullpressure is what explains frozen shells, latency explosions, and impending OOM kills. - Userland Portability: The bounded logging loop above uses
date -Insandtimeout, which assume GNU coreutils. If you are troubleshooting on a stripped-down BusyBox container or a BSD-derived environment, you will need to adjust those flags.
(For the complete kernel accounting rules and trigger mechanics, refer to the upstream Linux kernel PSI documentation).
Over to you: Have you wired PSI metrics into your monitoring stack yet, or are you still letting 15-minute load averages trigger false alarms at 3 AM?