How to Monitor a VPS: Uptime, Resources, and Alerts

Cover graphic: How to Monitor a VPS: Uptime, Resources, and Alerts

Core takeaway

  • Be the first to know: a program checks your server on a schedule and messages you when something looks wrong, ideally before it becomes an outage.
  • In this order: set up outside monitoring first, learn to read the server by hand with built-in commands, then set up your own alerts that reach your phone.
  • Know what counts: a disk that is 90 percent full is a warning; at 100 percent full it is a crashed database.
  • No paid software needed: nothing in the guide requires it.

Disclosure: con1ainer.com participates in affiliate programs. This article contains no affiliate links. See the Affiliate & Commercial Disclosure.

The 15-second version: a disk at 90% is a warning, at 100% it is a crashed database.

Most people find out their server is down in one of three ways: a visitor emails them, a customer complains, or they happen to open their own site and see an error.

All three mean the problem has been running for an unknown amount of time, and someone else found it first.

Monitoring fixes that. It means a program checks your server on a schedule, and sends you a message when something looks wrong, ideally before it becomes an outage. A disk that is 90 percent full is a warning. A disk that is 100 percent full is a crashed database.

This guide explains what to watch, which numbers count as healthy, how to read them yourself with built-in commands, and how to set up alerts that reach your phone. Nothing here needs paid software, and every term is explained as it appears.

The Two Kinds of Monitoring

There are two different questions to answer, and they need two different tools.

QuestionKindWhere the check runsWhat it catches
Can visitors reach my site right now?External (uptime) monitoringOn someone else’s server, on the internetServer crashed, network down, web server stopped, expired certificate, domain problem
Is my server healthy on the inside?Internal (resource) monitoringOn your VPSDisk filling up, memory running out, CPU overloaded, a service that stopped

You need both, and the reason is simple. If your VPS crashes completely, it cannot send you a message saying so. Only a check running somewhere else can notice that the server stopped answering. The reverse is also true: an external check only tells you the site is down, not why. The internal numbers tell you why.

What to Watch and What Counts as a Problem

The table below lists the measurements that matter on almost every VPS. The levels are starting points, not laws. Adjust them after you have seen what is normal on your own server.

WhatWhat it meansWarningAct now
Disk usedPercentage of storage filled80%90%
Inodes usedPercentage of file slots filled. Every file uses one, and a disk can run out of them while still having free space80%90%
Available memoryRAM the system can give to programs right nowBelow 20%Below 10%
Swap in useDisk space used as slow emergency memoryAny sustained useHeavy and growing
Load averageHow many programs are waiting for CPU time, compared with your number of CPU coresAbove 70% of core countAbove core count for 15 minutes or more
CPU stealTime your VPS wanted the CPU but the host gave it to another customerAbove 5% sustainedAbove 10% sustained
Website checkDoes the page load with a 200 status?One failed checkTwo failed checks in a row
SSL certificate expiryDays until the HTTPS certificate expires21 days7 days
Domain expiryDays until the domain registration ends60 days14 days
Key servicesIs Nginx, the database, and PHP running?—Any stopped

Most of these have a plain explanation, but three need more.

Load average is the number of programs either running or waiting to run, averaged over time. A single CPU core can work on one program at a time, so a load of 1.0 on a one-core VPS means the core is fully busy. On a four-core VPS, a load of 4.0 means all four are fully busy. A load far above your core count means programs are queuing, and the server feels slow.

Swap is a section of disk the operating system uses when RAM runs out. Disk is thousands of times slower than memory, so a server that is actively swapping becomes very slow. A little swap used and left alone is normal. Constant swapping means you need more RAM or fewer programs. Read next: How Much RAM Does a Web Server Need?

CPU steal exists because a VPS shares a physical machine with other customers, as explained in What Is a VPS and How Does It Work? Steal is the percentage of time your VPS was ready to work but the hypervisor, the software that divides the physical server, gave the processor to someone else. A little is normal. Sustained high steal means the host is overloaded, and it is something to raise with your provider.

Step 1: Set Up Outside Monitoring First

Start here, because it takes ten minutes and catches the worst problems.

Use an uptime monitoring service that checks your site from servers on the internet. Several well-known services offer free plans, and you can also self-host a tool such as Uptime Kuma. If you self-host one, run it on a different server than the one it watches, or it will go down together with the thing it is supposed to report on. Free plan limits change, so check the current limits before you choose.

Whichever you pick, these are the settings that matter:

SettingWhat to chooseWhy
What to checkhttps://example.com/, plus one inner pageA real page request tests DNS, the network, HTTPS, the web server, PHP, and the database in one go
Check typeHTTP(S) with a keyword match, not ping aloneA ping only proves the machine answers. A site can answer pings and still show an error page
KeywordA phrase that appears on the real page, such as text in your footerA broken site can return a 200 status with an error message. The keyword catches that
Interval1 to 5 minutesShorter intervals find outages sooner
ConfirmationAlert after 2 failed checks in a rowOne failed check is often a dropped connection, not an outage. This is how you avoid false alarms
Alert channelsEmail plus one push channel such as a phone app or TelegramEmail gets buried. A phone notification does not
Certificate expiry checkOnIt warns you before HTTPS breaks

A false positive is an alert about a problem that does not exist. Too many of them teach you to ignore alerts, which is worse than having none. The two-failures rule removes most of them.

When the monitor is set up, test it. Stop Nginx for one minute:

sudo systemctl stop nginx

Wait for the alert to arrive on your phone, then start it again:

sudo systemctl start nginx

An alert you have never received is an alert you do not know works.

Step 2: Learn to Read Your Server by Hand

Before installing anything, learn what the built-in commands show. These work on every Linux VPS and use almost no resources. Connect over SSH and try each.

Load and uptime

uptime
nproc

uptime prints how long the server has been running and three load averages: the last 1, 5, and 15 minutes. nproc prints your number of CPU cores. A typical line looks like this:

 14:02:11 up 36 days,  3:12,  1 user,  load average: 0.42, 0.51, 0.48

On a two-core server, 0.48 is about 24 percent busy. That is healthy. If the 15-minute figure stays above the core count, programs are waiting in line.

Memory

free -h
               total        used        free      shared  buff/cache   available
Mem:           1.9Gi       812Mi       143Mi        24Mi       1.0Gi       1.0Gi
Swap:          2.0Gi          0B       2.0Gi

The column that matters is available. The free column looks alarming and almost always is not. Linux deliberately fills spare RAM with cached copies of recently used files, shown as buff/cache, because that makes the server faster. It hands that memory back instantly when a program needs it. Here the server has 1.0 GB available out of 1.9 GB, which is healthy.

The Swap line shows how much of the emergency disk memory is used. Zero is ideal. If total swap is also 0, no swap is configured, which is common on cloud images.

Disk

df -h
df -i

df -h shows space used per disk in readable units. Look at the line ending in /. df -i shows the inode count, the number of file slots. A WordPress site with a very large cache folder, or a mail server holding millions of tiny messages, can run out of inodes with plenty of space left. When that happens, the server cannot create new files, and databases and uploads fail strangely.

To find what is eating the space:

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

That lists each folder under /var with its size, smallest first. Repeat the command inside the largest folder to drill down.

What is using the CPU and memory

top

top shows a live list of programs, busiest first. Press M to sort by memory, P to sort by CPU, and q to quit. In the CPU line near the top, three numbers matter:

  • us is time spent running programs. High is normal under load.
  • wa is time spent waiting for the disk. Constantly high means storage is the bottleneck.
  • st is steal, explained above.

For a one-off list of the biggest memory users:

ps aux --sort=-%mem | head -n 6

If a particular program keeps appearing at the top, you have found your next investigation. Read next: Why Is My VPS Slow? How to Find the Bottleneck

Services

systemctl is-active nginx mariadb

Each service prints active or something else. Anything that is not active is a problem to look at.

Step 3: Set Up Your Own Alerts

Reading numbers by hand tells you what is wrong today. Alerts tell you when it becomes wrong while you are asleep.

The simplest approach needs no software to install. A short script checks the key numbers on a timer and sends a push notification to your phone when one crosses a line.

This example uses ntfy, a simple notification service. You install its free phone app, subscribe to a topic name, and anything sent to that name appears as a notification. The public ntfy.sh service has no accounts, so anyone who knows your topic name can read your messages. Choose a long random name, and never put passwords or private details into a message. Any other service that accepts a web request, including a Telegram bot, works the same way.

Create the script:

sudo nano /usr/local/bin/vps-check.sh
#!/bin/bash
TOPIC="https://ntfy.sh/replace-with-a-long-random-name"
HOST=$(hostname)

# Disk: alert at 85% full
DISK=$(df --output=pcent / | tail -1 | tr -dc '0-9')
if [ "$DISK" -ge 85 ]; then
  curl -s -d "$HOST: disk is ${DISK}% full" "$TOPIC"
fi

# Memory: alert when 10% or less is available
MEM=$(free | awk '/Mem:/ {printf "%d", $7/$2*100}')
if [ "$MEM" -le 10 ]; then
  curl -s -d "$HOST: only ${MEM}% memory available" "$TOPIC"
fi

# Services: alert if any has stopped
for SERVICE in nginx mariadb; do
  if ! systemctl is-active --quiet "$SERVICE"; then
    curl -s -d "$HOST: $SERVICE is not running" "$TOPIC"
  fi
done

How it works:

  • df --output=pcent / prints the percentage of the main disk used. tail -1 keeps only the last line, and tr -dc '0-9' strips everything except digits, leaving a plain number.
  • free | awk ... reads the memory table, takes the available column (7th) and divides it by the total column (2nd) to get a percentage.
  • systemctl is-active --quiet prints nothing and simply reports success or failure, which the if ! turns into “this service is not running.”
  • curl -s -d sends the message text to your topic. -s keeps it quiet, and -d supplies the data.

Make it executable and test it:

sudo chmod +x /usr/local/bin/vps-check.sh
sudo /usr/local/bin/vps-check.sh

Nothing should happen when everything is healthy. To prove the alert works, temporarily change 85 to 1, run it again, and confirm that a notification arrives. Then set it back.

Now run it on a schedule. Open the cron table, which is the system’s task scheduler:

sudo crontab -e

Add one line at the bottom:

*/15 * * * * /usr/local/bin/vps-check.sh

The */15 means every 15 minutes. While a problem persists you will be reminded every 15 minutes, which is intentional. If you find that too noisy, change it to */30.

The limitation is the one named earlier: this script lives on the server it watches. If the whole VPS dies, it dies too. That is exactly why Step 1 comes first.

Step 4: Use What Your Provider Already Gives You

Most VPS providers show graphs of CPU, network traffic, and disk activity in their dashboard. Some let you set alerts on them. Turn those on if they exist, because they are measured from outside your server, at the hypervisor level, and can show things your own server cannot see, including CPU steal.

If your provider also offers a web console, meaning a terminal window in the dashboard that does not need SSH, note where it is now. When SSH stops responding during an incident, that console is often the only way in.

Step 5: Know Where the Evidence Is

An alert tells you something is wrong. The logs tell you what. These are the first ones to check:

QuestionCommand
Is Nginx reporting errors?sudo tail -n 50 /var/log/nginx/error.log
Who is requesting what from the website?sudo tail -n 50 /var/log/nginx/access.log
What did the system log in the last hour?sudo journalctl --since "1 hour ago"
Did a program run out of memory and get killed?sudo journalctl -k | grep -i "out of memory"
Are there failed SSH logins?sudo journalctl -u ssh --since today | grep -c Failed

The fourth row deserves attention. When Linux runs out of memory completely, it kills a program to save the system, often the database, and records it in the system log as an out-of-memory event. A database that keeps dying at random is very often this.

A few failed SSH logins per day are normal background noise from automated scanners. Thousands per day are a sign to read How to Secure a VPS: Essential Setup Checklist if you have not already.

Step 6: Watch the Slow-Burn Problems

Some failures arrive with no outage first, only a calendar date.

  • SSL certificate. Certbot renews Let’s Encrypt certificates automatically, but a renewal can fail silently. Check with sudo certbot certificates, which lists each certificate and its expiry date. Your uptime monitor’s certificate check is the safety net.
  • Domain registration. If your domain expires, your site disappears and so does your email. Turn on auto-renew at the registrar and keep a card on file that is not about to expire.
  • Backups. A backup job that stopped running last month looks exactly like one that is working, until you need it. Check the date of the newest backup file every week, or have the job send a success message. Read next: VPS Backup Strategy: How to Back Up a VPS and Actually Restore It
  • Updates. Security updates that were never applied create a risk no resource graph will show. Check pending updates with apt list --upgradable.

What to Do When an Alert Fires

A calm routine beats improvising at 3 a.m. Follow the same order each time.

  1. Confirm it from outside. Open the site on your phone using mobile data, not your home Wi-Fi. This rules out a problem in your own network.
  2. Connect over SSH. If SSH times out, use the provider’s web console. If that is also dead, check the provider’s status page, and then use the dashboard to reboot.
  3. Run the quick health check. uptime, free -h, df -h, and systemctl is-active nginx mariadb.
  4. Read the logs for the service that failed.
  5. Fix the cause, not only the symptom. Restarting a database that ran out of memory brings it back for a few hours. Adding memory or limiting a runaway program keeps it back.
  6. Write down what happened, even in two lines: the time, the symptom, the cause, and the fix. The second time it happens, you will be glad of the note.

The most common alerts and their usual first move:

AlertFirst commandUsual cause
Website downsystemctl is-active nginxNginx stopped, or the whole server is down
Website shows an error pagesudo tail -n 50 /var/log/nginx/error.logPHP or the database failed
Database stoppedsudo journalctl -k | grep -i "out of memory"The server ran out of RAM
Disk above 90%sudo du -h --max-depth=1 /var | sort -hLogs, backups, or cache growing without limit
High loadtopA runaway program, or a traffic spike
Certificate expiringsudo certbot renew --dry-runRenewal failing, often because of a changed Nginx configuration

Keep Alerts Useful

The goal of alerts is action, not information. Follow these rules.

  • Alert only on things you would get out of bed for. A CPU spike for ten seconds is information. A site that has been down for two minutes is an alert.
  • Require the condition to last. Use two failed checks in a row for websites, and sustained values for resources.
  • Use at least two channels, so a single notification setting or a failed email delivery does not leave you blind.
  • Test the whole chain once a month. Stop Nginx for a minute and confirm that the alert reaches your phone.
  • Review the thresholds after a month. If you were alerted ten times for nothing, raise the level. If a real problem passed with no alert, lower it.

Frequently Asked Questions

Do I need paid monitoring software?

Not to start. A free external uptime check, your provider’s dashboard, and the script in this guide cover most small websites. Paid tools become useful when you run many servers, need detailed history graphs, or must report uptime to customers.

Is a ping check enough?

No. A ping (an ICMP request, a basic “are you there” signal) only proves that the machine answers the network. Your site can be completely broken, with Nginx stopped or the database dead, while the server still answers pings. Use an HTTP check with a keyword.

How often should the checks run?

One to five minutes for uptime checks. Every five to fifteen minutes is enough for resource checks, because disks and memory change slowly compared with a crash.

Will monitoring slow my server down?

The commands and the script in this guide run for a fraction of a second every 15 minutes, which is negligible. Heavy monitoring suites that collect detailed data every second use more memory and are better kept for larger servers.

Can I run a monitoring tool in Docker?

Yes, and tools such as Uptime Kuma are commonly run that way. Remember the rule from Step 1: run the uptime checker somewhere other than the server it watches. Read Docker on a VPS: A Practical Starting Point if you are new to containers.

You Should Be the First to Know

Good monitoring is not elaborate. One check from outside, a few numbers watched from inside, alerts that reach your phone, and a routine for when they fire.

Set it up before you need it. The day your server has a problem is a bad day to learn how to build the thing that tells you about it.

The first person to know your server is down should be you.