How to Monitor Disk, RAM, and CPU Usage on a VPS with htop and Glances

When a VPS feels slow, guessing wastes time. The fix starts with seeing what the server is doing right now. Learning to monitor VPS CPU RAM disk usage with htop and Glances gives you that view in five minutes. Both tools run in the terminal, both show live numbers, and both help you tell a CPU problem apart from a RAM problem or a full disk.

This guide installs both tools on Ubuntu, walks through each screen, and shows how to spot the process that is eating your server. You need SSH access and a user with sudo.

Monitor VPS CPU RAM disk usage: why live beats guessing

A slow site can come from several directions. PHP-FPM workers can pile up, MySQL can eat RAM, a backup can fill the disk, or a cron job can pin one CPU core. Each cause looks the same from the outside: pages load slowly or time out. A live monitor shows which one it is.

Check the numbers before you change settings. Raising PHP workers when RAM is already full makes things worse. Adding swap when the disk is full does nothing.

Install htop and Glances on Ubuntu

Both tools live in the Ubuntu repositories. Update the package list first, then install them in one command. This is the standard way to set up Glances Ubuntu server owners use, and it works on 22.04 and 24.04 alike.

sudo apt update
sudo apt install htop glances -y

That is enough for the basics. The repository version covers CPU, RAM, disk, network, and processes, which is what this guide uses.

Read htop: CPU, RAM, and processes

Start htop with a plain command. It opens a full-screen view that updates every couple of seconds. For htop VPS monitoring, the top bar and the process table are the two parts that matter.

htop

The top bar shows CPU usage per core, memory, and swap. The main table lists processes sorted by CPU use. Each row shows the user, the process name, CPU percent, and memory percent. Press q to quit.

What the CPU bars mean

Each bar is one virtual CPU core. A bar near 100 percent on one core while the others sit idle points at a single-threaded task, such as one PHP script or one backup job. All cores near 100 percent points at a server-wide load spike.

The load average in the top right tells a longer story. Three numbers show the average load over 1, 5, and 15 minutes. On a 2-core VPS, a 1-minute load above 2 means work is queuing.

What the memory bars mean

htop splits memory into used, buffers, and cache. Used memory is what programs hold. Buffers and cache are memory Linux lends to disk work and reclaims when programs need it, so a high cache number on its own is not a problem. Watch the used figure and the swap bar: swap in use means RAM is tight and the server is leaning on disk, which is far slower.

Press F6 to sort by a different column. Sort by PERCENT_MEM when RAM looks tight, and sort by TIME+ to find a process that has been burning CPU for a long time. Press F4 to filter the list by a name such as mysql or php.

Useful htop keys

  • F6: choose the sort column
  • F4: filter processes by name
  • F5: tree view, so you see parent and child processes together
  • u: show processes for one user only, such as www-data
  • k: send a signal to the highlighted process
  • q: quit

Do not kill a process just because it sits at the top of the list. Check what it is first. A MySQL process at 80 percent CPU during a backup is normal.

Read Glances: the whole server on one screen

Glances trades htop’s process detail for a full-system view. Start it with one command.

glances

One screen shows CPU, memory, swap, disk usage per mount, network traffic, and the top processes. Colors do the first round of triage for you: green means fine, orange means watch it, red means act.

The disk section lists each mounted filesystem with used and free space. That is where you catch a log file or a backup filling the root partition before it takes the site down. The network section shows bytes sent and received per interface.

Press d to hide or show disk I/O, n for network details, and s for sensors where the VPS exposes them. Press h inside Glances to see the full key list. Glances also runs as a web server or a client-server pair, so you can check a remote VPS from another machine.

Quick checks with df and free

htop and Glances are live views. The df and free commands give you the same numbers in one shot, which is handy inside scripts or when you paste output into a support ticket. To check disk usage VPS owners usually start with df -h, and the guide to check VPS resource usage with htop, df, and free walks through both commands in more detail.

df -h shows disk use per mount in readable sizes. free -h shows total, used, and available RAM plus swap. Run both before and after a fix, such as clearing old logs, so you can see whether the fix actually moved the numbers.

df -h
free -h

Spot a runaway process

A runaway process keeps consuming CPU or RAM without finishing its work. The pattern: one process holds a high CPU share for minutes while other requests slow down.

Work through it in order. First, note the process name and user in htop. Second, check how long it has run by sorting on TIME+. Third, look at what it is doing. For a web process, check the access log for the matching request. For a database process, check the slow query log.

Sometimes the fix is a restart. Sometimes the fix is a config change, such as fewer PHP-FPM children or a smaller MySQL buffer pool. Restarting the same broken job every day is not a fix. A VPS disk and network speed test also helps here: if disk writes are slow, a process that looks CPU-bound may really be waiting on disk.

Disk vs RAM vs CPU: which bottleneck is it?

The three resources fail in different ways, and each one calls for a different fix.

CPU bottleneck

Signs: all cores busy, load average above the core count, pages slow even though RAM and disk have room. Common causes are uncached PHP pages, image processing, or a backup compressing large files. Fixes include caching or moving the heavy job to off-peak hours.

RAM bottleneck

Signs: used RAM near total, swap in use, or the out-of-memory killer ending processes. Common causes are too many PHP-FPM children, a large MySQL buffer, or several Docker containers on a small plan. Fixes include tuning worker counts or moving to a plan with more RAM. Swap helps a tight server survive a spike, and the guide to adding swap on a VPS walks through when it makes sense and how to set it up.

Disk bottleneck

Signs: disk use above 85 percent, slow writes, errors about no space left, or a site that fails when it tries to write a session or a cache file. Common causes are old logs, unrotated backups, or Docker images piling up. Fix it by deleting what you no longer need, rotating logs, and moving backups off the server.

When to move from live tools to a monitoring stack

htop and Glances show the present moment. They cannot tell you what happened at 3 a.m. while you slept, and they cannot send you an alert. That is where a monitoring stack earns its place.

Move on when you catch yourself checking the same server every day, when an outage is discovered by a visitor instead of by you, or when you need history to prove a pattern, such as RAM climbing a little further every week. Uptime Kuma covers uptime checks and alerts from a Docker container, and the setup guide for installing Uptime Kuma with Docker is a good first step. For full metrics history, Netdata or Prometheus with Grafana record CPU, RAM, and disk over weeks, so you can size your next upgrade from real data instead of a guess. Paid hosted services exist too; compare features and check official pricing before you commit to one.

FAQ

Do I need to install anything to check VPS resources?

No. df, free, and top ship with Ubuntu. htop and Glances are nicer to read, and both install from the standard repositories with one apt install command.

Is Glances better than htop?

Neither is better in general. htop is sharper for process work: sorting, filtering, and acting on one process. Glances is sharper for a full-system check: CPU, RAM, disk, and network on one screen. Most VPS owners end up using both.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.