All posts

Blog

How to Monitor Server Resources on a Linux VPS (CPU, RAM, Disk)

Illustrated cover for the Servers & VPS guide "How to Monitor Server Resources on a Linux VPS (CPU, RAM, Disk)"

"The site is slow" is one of the least helpful sentences in hosting, and one of the most common. Behind it is usually one of four things: the CPU is maxed out, memory has run short, the disk is full or overwhelmed, or the network is saturated. Knowing how to monitor server resources on a Linux VPS lets you find which one in a couple of minutes instead of guessing.

This guide covers the built-in commands for a quick health check, how to read them, and how to set up continuous monitoring with alerts so you hear about problems before your visitors do.

The two-minute health check

When something feels wrong, SSH in and run these in order.

1. uptime: load average

uptime

You will see something like load average: 0.42, 0.55, 0.61. These are averages over 1, 5, and 15 minutes of how many processes are running or waiting. On Linux, the load average includes processes waiting on disk I/O, not just CPU.

To interpret it, compare with your CPU count:

nproc

On a 4-core VPS, a load around 4 means the system is fully busy. Consistently higher than your core count means work is queuing up. Comparing the three numbers tells you whether things are getting better (1-minute lower than 15-minute) or worse.

2. free: memory

free -h

Focus on the available column, not "free." Linux deliberately uses spare RAM as disk cache, so "free" often looks alarmingly small on a perfectly healthy server. "Available" estimates how much memory applications can actually use. Watch the Swap line too: heavy swap use on a VPS usually means you need more RAM or less memory-hungry software.

3. df: disk space

df -h

A filesystem at 100% causes strange failures: databases crash, logs stop writing, uploads fail. Also check inodes, which can run out on servers with millions of tiny files even when space remains:

df -i

To find what is using space:

sudo du -xh / --max-depth=1 | sort -h

Drill down into the biggest directory and repeat. The usual suspects are logs in /var/log, old backups, Docker images, and caches. The interactive tool ncdu makes this much easier if you install it.

4. top or htop: what is using it

top

Press P to sort by CPU and M to sort by memory. htop (install with sudo apt install htop) is friendlier, with color bars per core and easy sorting and filtering.

In the CPU summary line, watch these values:

  • us / sy: time spent on user programs and the kernel.
  • wa (iowait): CPU waiting on disk. High values point to a storage bottleneck.
  • st (steal): time the hypervisor gave your virtual CPU to someone else. On a VPS, consistently high steal suggests contention on the host node, which is worth raising with your provider.

Digging deeper

Disk I/O

A full disk is obvious; a slow one is not. iostat from the sysstat package shows per-device activity:

sudo apt install sysstat -y
iostat -xz 2

High %util and growing await times mean the disk is struggling. iotop shows which processes are doing the reading and writing.

Memory pressure and the OOM killer

If processes vanish without explanation, the kernel's out-of-memory killer may be ending them:

sudo dmesg -T | grep -i "out of memory"
journalctl -k | grep -i oom

If you see entries, find the memory hog and tune it (database buffer sizes, PHP-FPM or app worker counts) or add RAM.

Network

ss -tunap | head -50     # current connections
sudo apt install iftop -y && sudo iftop   # live bandwidth by connection

A sudden flood of connections from a few IPs could be abusive traffic. vnstat keeps long-term bandwidth totals, which helps if your plan has a transfer allowance.

Logs

Resources tell you what is strained; logs often tell you why. Check your web server error log, application logs, and journalctl -p err -b for errors since the last boot.

Continuous monitoring: watch it before it breaks

Checking manually works for emergencies, but you also want history (what did memory look like last Tuesday at 3 p.m.?) and alerts.

sysstat history

Once sysstat is installed and its collection is enabled (on Debian and Ubuntu, set ENABLED="true" in /etc/default/sysstat), sar records CPU, memory, disk, and network stats at regular intervals, so you can look back:

sar -u    # CPU today
sar -r    # memory today

Lightweight dashboards

  • Netdata installs quickly and gives a detailed real-time dashboard with many built-in alerts. Keep its dashboard behind a firewall, an SSH tunnel, or authentication rather than open to the world.
  • Prometheus with node_exporter and Grafana is the more involved, highly flexible option, popular when you manage several servers.
  • Monit is a small tool that can watch services and resources and restart a process or send an alert when a threshold is crossed.

External uptime checks

Internal monitoring cannot tell you the server is unreachable if the server itself is down. Add an external uptime monitor that checks your site over HTTPS every minute or few minutes and alerts you by email or chat. Many services offer a free tier for a handful of checks.

Alerts worth setting

Start with a short list, so alerts stay meaningful:

  • Disk usage above 80 to 85%.
  • Available memory low for more than a few minutes, or swap usage climbing.
  • Load average well above core count for a sustained period.
  • Website or API failing external checks.
  • Certificate expiring within 14 days.
  • Key services (web server, database) stopped.

Turning data into decisions

Monitoring pays off when it guides action:

  • CPU constantly high from your app: profile and optimize, add caching, or move to more cores.
  • Memory tight: tune worker counts and database buffers, or upgrade RAM.
  • iowait high: reduce disk-heavy work, add caching, or move to faster storage.
  • Disk filling: set up log rotation, prune old backups and Docker images, or add space.

If you run sites on shared hosting rather than your own VPS, the same ideas apply through your control panel's resource usage page; our guide to hosting resource limits explains what those numbers mean.

Wrap-up

To monitor server resources on a Linux VPS, start with uptime, free -h, df -h, and htop for a fast diagnosis, use iostat, dmesg, and your logs to dig deeper, and set up continuous monitoring with a few well-chosen alerts. A few minutes of setup now means the next time someone says the site is slow, you will already know why.