How to monitor CPU, memory and disk usage on a Linux server
Check CPU, memory and disk on Linux with top, free and df, learn which numbers actually matter, pick sensible alert limits, and get alerted before a server runs out.
· 8 min read · By the Spot Downtime team
Most server outages don't start with a crash. They start with a disk quietly filling with logs, memory slowly leaking until the kernel starts killing processes, or CPU pinned by a runaway job until every request times out. All three are visible minutes, hours or days in advance, if you're watching. This guide covers how to read each one on Linux, which numbers are misleading, and how to get alerted automatically.
CPU: what top and uptime tell you
Two commands give you the picture in seconds:
$ uptime
14:02:11 up 41 days, 3:12, 1 user, load average: 7.62, 6.90, 4.11
$ top -bn1 | head -3
top - 14:02:12 up 41 days, 3:12, 1 user, load average: 7.62, 6.90, 4.11
Tasks: 213 total, 9 running, 204 sleeping, 0 stopped, 0 zombie
%Cpu(s): 88.1 us, 5.2 sy, 0.0 ni, 5.9 id, 0.6 wa, 0.0 hi, 0.2 si, 0.0 st| Field | Means | Worry when |
|---|---|---|
| us / sy | Time running your programs / the kernel | Together near 100% for minutes at a time |
| id | Idle | Near 0 for long stretches |
| wa | Waiting on disk (iowait) | Above about 10%: the disk is the bottleneck, not the CPU |
| st | Stolen by the hypervisor (cloud VMs) | Above a few %: you're sharing a busy host |
| load average | Processes running or waiting, over 1, 5 and 15 minutes | Above the number of cores (nproc) and rising |
Load average only makes sense next to the core count. A load of 7.62 is fine on a 16-core machine and a queue on a 4-core one. Check yours with nproc. The three numbers also show direction: 7.62, 6.90, 4.11 means it's been climbing for the last quarter of an hour.
Spikes are normal; sustained highs aren't
A web server that spikes to 100% for a few seconds during a deploy is doing its job. The same server at 95% for ten minutes is out of headroom, and the next traffic bump will make it slow. That's why a CPU alert should look at an average over several minutes, not a single reading:
Memory: read available, not free
$ free -h
total used free shared buff/cache available
Mem: 15Gi 9.8Gi 412Mi 210Mi 5.2Gi 5.1Gi
Swap: 2.0Gi 1.1Gi 905MiThe free column scares people: 412 MB out of 15 GB looks nearly full. It isn't. Linux uses spare memory as a disk cache (buff/cache) and hands it back the moment a program needs it. The number that matters is available: memory programs can get without swapping. Here that's 5.1 GB, so the server is about 68% used and fine.
- Watch the trend. Available memory that drops a little every day, and never recovers, is usually a leak. Restarting the service hides it until next week.
- Swap use isn't automatically bad. A little swap that stays put is idle pages moved aside. Swap that keeps growing while available memory shrinks means the server is out of memory and getting slow.
- Check for the OOM killer. When memory runs out, the kernel kills a process, often the database. Look for it with
dmesg -T | grep -i "killed process"orjournalctl -k | grep -i oom.
Disk: space, and the inodes nobody checks
$ df -h -x tmpfs -x devtmpfs -x squashfs
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p1 50G 19G 29G 40% /
/dev/nvme1n1 200G 162G 38G 81% /var
/dev/nvme2n1 20G 19G 1.4G 93% /var/logThe -x flags hide temporary and snap filesystems, which are always “full” and never matter. Two things catch people out:
- Each mount fills on its own. The root disk can be at 40% while
/var/logis at 93%. Watch every real disk, not just/. - Inodes can run out first. Millions of tiny files (sessions, cache entries, mail queues) can use up a filesystem's inodes while
df -hstill shows space. Check withdf -i; the symptom is “No space left on device” on a disk that isn't full.
When a disk is filling, find what's growing:
# The biggest directories on one filesystem, largest last
sudo du -xh /var --max-depth=2 2>/dev/null | sort -h | tail -15
# Deleted files still held open by a process (space that only comes back on restart)
sudo lsof +L1 2>/dev/null | headThe usual culprits are logs without rotation, old Docker images (docker system df), database write-ahead logs and forgotten backups. Unlike CPU, a full disk breaks things at once, so a disk alert shouldn't wait for an average:
Picking alert limits
Good limits leave enough room to act before users notice, without paging you for normal load. Start here and adjust:
| Resource | Alert when | Why |
|---|---|---|
| CPU | Average over 90% for 5 to 10 minutes | Short spikes are normal; sustained highs mean no headroom |
| Memory | Average over 90% for 5 minutes | Uses available memory, so cache doesn't count against you |
| Disk | Any disk over 85 to 90% | Leaves time to clean up; small disks fill faster, so alert earlier |
| Reports stop | No data for 3 minutes | The server crashed, froze, or lost its network |
Alert on symptoms too
Watching it all automatically
Running top, free and df is fine for a look. To catch problems at 3 a.m., something has to run them for you and tell you. You can script it (a cron job that checks df and pings a heartbeat only while the disk is healthy), but that gives you a yes or no with no history.
Spot Downtime's server agent does it all once a minute:
- Click Add monitor, choose Server, and set the limits from the table above.
- Copy the install command from the server's page and run it on the server:
curl -fsSL https://spotdowntime.com/install-agent.sh | sudo sh -s -- --token YOUR-TOKENThe agent reads the same kernel counters as these commands: CPU from /proc/stat (counting iowait as idle, like top's id plus wa), memory from MemAvailable, and every real disk the way df does. It sends them out over HTTPS, with no ports to open. Within a minute you get charts for each, every disk listed with its limit marked, and alerts on the channels you already use.
One server is included on the Free plan. Read more in the launch post or on the server monitoring page.
Get new guides by email
Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.
Keep reading
- How-to · Monitoring · APIsHow to configure gRPC health checkingLearn how to implement and configure gRPC health checking for reliable service discovery and load balancing: server status, Kubernetes probes, client-side health checks, Envoy, cloud load balancers and Consul.November 7, 2026 · 7 min read
- How-to · MonitoringWordPress uptime monitoring in 10 minutesSet up uptime monitoring for a WordPress or WooCommerce site in 10 minutes: keyword checks for white screens, a page your cache can't hide, WP-Cron, SSL and domain expiry.November 2, 2026 · 5 min read