A VPS has no built-in mechanism to tell you when it is running low on disk space, memory, or CPU headroom; unlike managed hosting, nobody is watching it on your behalf. The first sign of trouble is often the server itself failing, a full disk blocking MySQL from writing, a WordPress site returning database connection errors because memory ran out. Setting up monitoring before that happens turns a surprise outage into a scheduled maintenance task.
This guide installs a live resource monitor for checking on the server manually, then sets up a scheduled disk space check that sends a push notification before the disk fills up. It assumes you have a running Ubuntu VPS with a non-root sudo user, for example from the [Ubuntu 24.04 initial setup guide](/guides/how-to-set-up-ubuntu-24-04-vps).
htop gives a live, readable view of CPU, memory, and running processes, and is the first thing worth checking whenever a server feels slow. Install it:
sudo apt update
sudo apt install htop -y
Launch it any time with:
htop
The top bars show per-core CPU usage and memory usage at a glance, and the process list below can be sorted by pressing F6 and choosing CPU% or MEM% to find whatever is consuming resources. Press F10 or q to exit. This covers checking on the server when you are already logged in; the next steps set up checks that run even when you are not.
Check overall disk usage per mounted filesystem with df:
df -h
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 75G 34G 38G 48% /
The Use% column on the root filesystem is the number to watch; once that consistently climbs past 80%, it is worth investigating what is consuming space before it becomes urgent. To find which directories are the largest contributors, run du against a specific path:
sudo du -h --max-depth=1 /var | sort -rh | head -10
This is a common way to discover that logs, database backups, or an old WordPress uploads folder from a since-deleted site have quietly consumed most of the free space. With a way to check disk usage manually established, the next step automates the checking so you do not have to remember to run it.
A script that checks disk usage and sends a notification when it crosses a threshold means you find out about a filling disk from a push notification rather than from a site going down. This uses ntfy.sh, a free push notification service that needs no account or API key, just a topic name you choose that acts as a private channel. Create the script:
sudo nano /usr/local/bin/disk-check.sh
Add the following, replacing arcadia-vps-alerts-8f2k with a topic name of your own choosing; treat it like a password; anyone who knows the exact topic name can read notifications sent to it, so pick something unguessable rather than something predictable:
#!/bin/bash
THRESHOLD=80
TOPIC="arcadia-vps-alerts-8f2k"
USAGE=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%')
if [ "$USAGE" -ge "$THRESHOLD" ]; then
curl -s -d "Disk usage on $(hostname) is at ${USAGE}%" ntfy.sh/$TOPIC > /dev/null
fi
Make it executable:
sudo chmod +x /usr/local/bin/disk-check.sh
Test it manually to confirm the notification arrives before relying on it. Subscribe to your topic at ntfy.sh/your-topic-name in a browser or the ntfy mobile app first, then temporarily lower THRESHOLD to a value below your current usage and run the script directly:
sudo /usr/local/bin/disk-check.sh
A notification should arrive within a few seconds. Once confirmed, set THRESHOLD back to 80 or whatever level gives you enough runway to act before the disk actually fills.
With the script tested, schedule it to run automatically so you are notified without needing to check manually. Open the root crontab:
sudo crontab -e
Add a line to run the check every hour:
0 * * * * /usr/local/bin/disk-check.sh
The disk space check now runs automatically every hour, and will only ever send a notification when usage actually crosses the threshold, so it stays silent unless there is something to act on.
You have htop for checking live resource usage whenever you are logged in, and an automated hourly check that pushes a notification before a filling disk becomes an outage. From here, the same cron and curl pattern used in the alert script can be extended to check memory usage or the exit status of your [backup cron job](/guides/backup-wordpress-vps-cron-job), so a failed backup gets noticed the same day rather than the next time you happen to need it.
Move a live WordPress site from shared hosting to a VPS: database export with my...
How to set up SSH key authentication on Ubuntu and disable password logins to se...
Install WordPress on a Linux VPS with Nginx, PHP-FPM, and MariaDB. Complete step...