Run seven Linux checks in order when production degrades: load, CPU, memory, disk, network, logs and recent changes, with real commands.
At 2am your payment API starts returning 503s. You SSH into the box, open top, and stare at the process with the highest CPU. Ten minutes later you are guessing.
The pattern is the same whether you run checkout for a Shopify-scale retailer or dispatch for a Grab-scale ride platform. A fixed decision sequence beats improvising under pressure. This post gives you seven checks in order, each one narrowing the problem. Most incidents end at step 2, 3 or 4, so you rarely need all seven.
The fastest way is to run seven checks in a fixed order: snapshot, CPU, memory, disk, network, logs, recent changes. Each check either finds the bottleneck or rules out a whole resource class, so you stop as soon as you find the culprit.
Work top to bottom, write down what you see, and do not skip steps because you already have a theory.
Tip: if users are actively failing, mitigate first and diagnose second. Roll back the last deploy, shed load or fail over, then run the checks below with a calmer system.
Run uptime, free -h, df -h and df -ih first. Together they show load, memory pressure, full disks and exhausted inodes before you spend time on any single resource.
uptimenprocfree -hdf -hdf -ihA load average above your core count means more tasks want to run than CPUs can serve. On a 4-core host, a load of 8.42 means roughly twice as much work as the CPUs can service.
10:01:23 up 14 days, load average: 8.42, 4.11, 2.05Read the three numbers (1, 5 and 15 minutes) as a trend. 8.42, 4.11, 2.05 means load is rising fast. 2.05, 4.11, 8.42 means the spike is already passing.
One Linux-specific trap: the load average counts tasks waiting on disk (state D), not just tasks waiting for a CPU. High load with idle CPUs is a storage problem in disguise, so keep that in mind at step 2.
On free -h, watch the available column, not free. If available memory is a small fraction of total and swap is growing, the kernel is already paging.
Modern kernels also expose pressure stall information (PSI), which tells you whether tasks are actually stalling:
cat /proc/pressure/cpucat /proc/pressure/memorycat /proc/pressure/ioNon-zero some avg10 values on any of these mean real contention right now. A non-zero full line on memory or io means every runnable task was stalled at the same time, which is serious.
Sort processes by CPU and check how time is split between user, system and iowait. One process near 100% of a core suggests a code problem. Many moderate processes suggest traffic growth. High %wa means the disk, not the CPU, is the bottleneck.
ps aux --sort=-%cpu | head -15 ## per-state CPU breakdown, five 1-second samplesvmstat 1 5 ## per-process CPU over timepidstat -u 1 5Interpret what you see with this table:
| Pattern | What it means |
|---|---|
| One process at 90%+ | Loop or regression |
| Many at 10-30% | Traffic spike, scale out |
High %sy |
Kernel work, syscalls |
%wa above 20 |
Disk bound, go to step 4 |
%wa is the most commonly missed signal. If CPUs are waiting on disk, tuning application code will not help. You need to fix storage first.
For a short history instead of one instant, sar -u 1 5 from the sysstat package shows whether a spike is sustained or already fading. Without sar history enabled, you only see the present, which is why step 1 of the guidelines below is to turn it on.
Search the kernel log for OOM-killer events, then compare per-process memory against the limit that applied to it. The killed process is often not the one that leaked: the kernel picks the process with the highest badness score, which is mostly a function of memory use.
free -hdmesg -T | grep -i "out of memory\|killed process" | tailgrep -E "MemAvailable|SwapTotal|SwapFree" /proc/meminfoIf dmesg returns "Operation not permitted", the host sets kernel.dmesg_restrict=1. Use sudo dmesg -T or journalctl -k instead.
A typical OOM entry looks like this:
Out of memory: Killed process 1234 (node) total-vm:2048000kB, anon-rss:1834000kB, oom_score_adj:0In containers, the cause is usually the cgroup limit rather than host RAM. Check both the limit and the kill counter:
## cgroup v2 limit and current usagecat /sys/fs/cgroup/memory.maxcat /sys/fs/cgroup/memory.current ## how many times the cgroup hit its limit and killed somethinggrep oom_kill /sys/fs/cgroup/memory.eventsOn older hosts still on cgroup v1, the equivalent files are memory/memory.limit_in_bytes and memory/memory.usage_in_bytes under /sys/fs/cgroup.
To see which processes are using swap right now:
for f in /proc/[0-9]*/status; do awk '/^Name|^VmSwap/{printf "%s ", $2} END{print ""}' \ "$f" 2>/dev/nulldone | awk '$2>0' | sort -k2 -rn | headCheck blocks with df -h, inodes with df -ih, and device saturation with iostat -xz. A full disk fails silently: processes return write errors that look like application bugs.
## block usagedf -h## inode usagedf -ih## device utilisation, 3 samplesiostat -xz 1 3The inode trap catches experienced engineers. You can have 40GB of free blocks and zero free inodes. Every open() that creates a file then fails with ENOSPC, the same error as a full disk, and only df -ih shows the difference.
To find the directory holding the most files, run the scan at low priority so it does not add to the problem:
ionice -c3 nice find / -xdev -printf '%h\n' 2>/dev/null \ | sort | uniq -c | sort -rn | headA third cause: df says the disk is full but du cannot find the space. A process is holding a deleted file open, usually a rotated log. List them and restart or signal the owner:
lsof +L1 | sort -k7 -rn | headIn iostat, read the latency and queue columns first. Depending on your sysstat version you will see a single await column or separate r_await and w_await columns (read and write latency in milliseconds). The queue depth column is aqu-sz in recent versions and avgqu-sz in older ones. Sustained latency above roughly 20ms on SSD-backed volumes means requests are queueing.
Be careful with %util. It means "the device had at least one request in flight", which made sense for a single spinning disk. NVMe and cloud block devices serve many requests in parallel, so %util can read 100 while the device still has headroom. Trust latency and queue depth over %util on those.
To find which process is doing the I/O:
pidstat -d 1 5Test the dependency directly from the affected host. If a raw TCP connect fails, the cause is DNS, routing, a firewall or the remote service. No amount of application debugging will fix that.
## DNS resolves?dig +short db.internal.example.net ## TCP connect with a 3 second timeouttimeout 3 bash -c \ 'echo > /dev/tcp/db.internal.example.net/5432' \ && echo "port open" || echo "unreachable"Then look at connection states on the host itself:
## listeners with owning processss -tulpn## connection counts by statess -ant | awk 'NR>1 {print $1}' | sort | uniq -c | sort -rnRead the state counts like this:
| State | What it means |
|---|---|
TIME_WAIT high |
Normal after bursts |
CLOSE_WAIT high |
App not closing sockets |
SYN_RECV high |
SYN flood or backlog full |
Two silent network killers are worth a quick look on busy hosts. A full connection-tracking table drops packets with a nf_conntrack: table full line in dmesg. Ephemeral port exhaustion shows up as thousands of TIME_WAIT sockets to one destination plus cannot assign requested address errors in the application.
Find the timestamp of the first error, not the loudest one. The first error marks the moment the system changed state, and the cause usually sits in the two to five minutes before it.
journalctl -u payment-api --since "30 minutes ago" --no-pagerjournalctl -p err -b --no-pager | tail -30 ## first error in a flat filegrep -n -i "error" /var/log/app/payment-api.log | head -3 ## kernel messages with readable timestampsdmesg -T | tail -30Write down that first timestamp. Step 7 uses it.
Check what changed in the two hours before the first error. Most production incidents follow a deploy, config edit, package upgrade or scheduled job, so this check often finds the cause even when the resource checks only show symptoms.
## files changed in the last 2 hoursfind /etc /opt /app -mmin -120 -type f 2>/dev/null ## service restarts and failuresjournalctl --since "2 hours ago" \ | grep -E "Started|Stopped|Failed" | head -20 ## recent package changes (Debian/Ubuntu)grep -E " install | upgrade " /var/log/dpkg.log | tail -10On RHEL-family hosts, use dnf history instead of the dpkg.log check.
If the host runs cron jobs or systemd timers, check them too:
systemctl list-timers --all | head -20journalctl -u cron --since "2 hours ago" | tail -20This is an illustrative composite of a common pattern: a checkout API slows to a crawl during peak traffic because a background process saturates the disk.
Symptom: p99 latency jumps from 180ms to 4,200ms at 01:47 and the payment failure rate rises to 12%.
## step 1: snapshotuptime load average: 12.45, 8.31, 4.22 (4 cores) ## step 2: CPU split shows the cluevmstat 1 3 us=12 sy=6 id=44 wa=38 ## step 4: confirm the diskiostat -xz 1 2 nvme1n1 w_await=84.2 aqu-sz=31.4 %util=98.7 ## which process?pidstat -d 1 3 postgres: autovacuum worker kB_wr/s=412000Load was three times the core count, yet 44% of CPU time was idle. That combination points at tasks stuck on I/O, and wa=38 confirmed it. Write latency of 84ms with 31 requests queued on the data volume showed the device was the bottleneck, not the %util figure alone.
An autovacuum worker on a 48GB table was writing at full speed during peak traffic, so every checkout query queued behind it. The fix took two minutes of mitigation and one change afterwards: cancel the worker, then throttle autovacuum with a higher autovacuum_vacuum_cost_delay and schedule heavy maintenance off peak. Total diagnosis time was about four minutes because the sequence led straight from load to iowait to the device to the process.
Paste this into a runbook and run it top to bottom when an alert fires:
## snapshotuptime; free -h; df -h; df -ih## cpu and iovmstat 1 3; iostat -xz 1 2## top processesps aux --sort=-%cpu | head -10## memory and OOMdmesg -T | grep -i "killed process" | tail -5## networkss -s; ss -tulpn | head -20## errors and changesjournalctl -p err -b --no-pager | tail -30find /etc /opt -mmin -120 -type f 2>/dev/nullThis manual sequence is the right first response because it needs nothing installed beyond sysstat. It is not the only tool.
| Approach | Best for | Limit |
|---|---|---|
| This 7-step sequence | First 5 minutes | Point in time |
| USE method checklist | Structured review | Needs discipline |
| eBPF tools (bcc, bpftrace) | Deep root cause | Needs kernel support |
Metrics platforms such as Datadog or Prometheus with node_exporter answer "what happened an hour ago" far better than any shell command. Use them for history, and use the shell for what is happening now.
Treat this sequence as a standing procedure, not tribal knowledge. The value is that a junior engineer can follow it correctly at 2am without having memorized it.
sysstat (for iostat, pidstat, sar) is on every production host and that sar history collection is enabled, so you can look back at what happened before you logged in./usr/local/bin/triage, so no one has to look it up.%iowait, memory pressure (PSI) and inode usage as well as CPU and disk space, because these are the signals that fail silently.References and Further Reading
- Linux Performance Analysis in 60 Seconds - Netflix Tech Blog, the classic first-minute checklist
- The USE Method - Brendan Gregg on Utilization, Saturation and Errors
- Pressure Stall Information - Kernel documentation for
/proc/pressure- journalctl Manual - Official reference
You have probably run out of inodes, not blocks. Run df -ih: if IUse% is 100%, every file creation fails with ENOSPC even with gigabytes free. Find the directory with millions of small files (session files, mail queues, temp files) and clean it up. If neither blocks nor inodes are full, check for deleted files still held open with lsof +L1.
Look at the distribution, not the load average. One process pinned near 100% of a core usually means a loop, a runaway query or a regression. Many processes each using 10-30% while request rate rises means real traffic growth that needs scaling.
Linux counts tasks in uninterruptible sleep (state D, usually waiting on disk or NFS) in the load average. A load of 12 on 4 cores with 44% idle CPU and high %iowait means processes are stuck on storage, so confirm with iostat -xz 1 and fix the volume or the noisy writer first.
Check dmesg -T for oom-kill lines. In containers and cgroups, the OOM killer fires when the cgroup memory limit is hit, even if the host has free RAM. Compare the limit against the process's anon-rss, read memory.events for the oom_kill counter, then raise the limit or fix the leak.
Test the dependency from the affected host with a raw TCP connect to its host and port. If the connect times out or is refused, the cause is DNS, routing, a firewall, a full conntrack table or the remote service, not your application code. If it succeeds, move on to application logs.
Discussion0