If you run one or two small servers for a landing page, an API behind an app, or a backend for a side project, you probably don't need dashboards, time-series databases, or an on-call rotation. What you do need is to find out about problems before your users do, and to avoid alerts so noisy that you start ignoring them.

This post covers a minimal monitoring setup in three layers. Each layer catches a different kind of failure, and together they cover most of what goes wrong on a small box.

Start with the questions, not the tools

Before installing anything, write down what you actually want to know. For most small servers the list is short:

  1. Is the site or API reachable from the outside? This is the one your users care about.
  2. Is the machine about to fall over? Full disks, memory exhaustion, and expiring TLS certificates are the usual causes.
  3. Did the scheduled jobs actually run? Backups, renewals, and cleanup scripts fail silently more often than anything else.

Each question maps to one layer below. If a check doesn't answer one of these questions, ask yourself whether you need it.

Layer 1: an external uptime check

The most important rule is that the uptime check must not run on the server it watches. If the machine loses power, its network drops, or the kernel panics, a check running on it can't tell you anything. Run it from somewhere else: a second small VPS, a machine at home, or a hosted uptime service. Self-hostable tools like Uptime Kuma work well on a separate box if you'd rather not depend on a third party.

Give the check something meaningful to hit

Checking that the homepage returns 200 tells you the web server is up. It doesn't tell you whether the app behind it can reach its database. A small health endpoint helps:

  • Return 200 only if the app can do a trivial query (for example SELECT 1) against its database.
  • Keep it cheap. No heavy queries, no external API calls, because it will be hit every minute.
  • Don't leak details. A plain ok body is enough; put diagnostics in your logs.
  • Exclude it from caching so a CDN doesn't serve a stale success.

A script that tolerates one blip

Networks hiccup. Alerting on a single failed request produces false alarms, and false alarms train you to ignore alerts. The script below alerts only after two consecutive failures and sends a recovery message when things come back. Run it from cron on the other machine every minute or two.

#!/bin/sh
set -u
URL='https://example.com/healthz'
ALERT_URL='https://alerts.example.net/my-server'
STATE=/var/tmp/site-check.fail

notify() { curl -fsS --max-time 10 -d "$1" "$ALERT_URL" > /dev/null; }

status=$(curl -s -o /dev/null -w '%{http_code}' --max-time 10 "$URL")

if [ "$status" = 200 ]; then
  if [ -f "$STATE" ]; then
    [ "$(cat "$STATE")" -ge 2 ] && notify "Recovered: $URL"
    rm -f "$STATE"
  fi
else
  count=$(cat "$STATE" 2>/dev/null || echo 0)
  count=$((count + 1))
  echo "$count" > "$STATE"
  [ "$count" -eq 2 ] && notify "Down (status $status): $URL"
fi

A status of 000 means curl got no HTTP response at all: DNS failure, a refused connection, or a timeout. That's worth knowing when you start debugging.

Layer 2: resource checks on the box

Some failures build up slowly and are easy to see coming if you look. These checks do run on the server itself, since they need local information. Put them in one script and run it every few minutes.

Disk space

A full disk is one of the most common ways a small server dies: logs grow, Docker images pile up, a database bloats. When the disk fills, writes fail in confusing ways all over the system.

usage=$(df -P / | awk 'NR==2 {gsub("%",""); print $5}')
if [ "$usage" -gt 85 ]; then
  notify "Disk at ${usage}% on $(hostname)"
fi

Pick the threshold by looking at how fast your disk actually grows. Run df -h once a day for a week and note the change. If you gain a few percent a week, 85% gives you plenty of warning. If one bad night of logging can fill the disk, lower the threshold and fix log rotation.

Memory and swap

On Linux, "free" memory is misleading because the kernel uses spare RAM for cache. Look at the available column from free -m, or check whether the OOM killer has fired:

if journalctl -k --since '-10 min' | grep -qi 'out of memory'; then
  notify "OOM killer fired on $(hostname)"
fi

An OOM event is a clear signal. A memory percentage threshold usually just generates noise.

TLS certificate expiry

Automated renewal is great until it quietly stops working because of a changed DNS record, a firewall rule, or an expired API token. Check the certificate the server is actually serving, not the file on disk:

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -checkend 1209600 \
  || notify "TLS cert for example.com expires within 14 days"

-checkend takes seconds; 1209600 is fourteen days. That's enough time to fix a broken renewal without a scramble. This check can also run from your external machine, which tests what visitors actually see.

Layer 3: heartbeats for scheduled jobs

Cron jobs are the classic silent failure. A backup script that exits early, a timer that was never re-enabled after a migration, a job that hangs forever: none of these produce an error you'll see.

The fix is to flip the logic. Instead of alerting when something fails, alert when a success signal stops arriving. This is often called a dead man's switch. Each job pings a URL when it finishes successfully, and a separate service alerts you if the ping doesn't show up within the expected window. Healthchecks.io is one well-known option and can also be self-hosted.

0 3 * * * /usr/local/bin/backup.sh && curl -fsS --retry 3 --max-time 10 https://hc.example.net/ping/backup-job > /dev/null

The && matters: the ping fires only if the backup exits with status zero. That means your backup script has to exit non-zero on failure. Add set -e, and check the exit codes of the commands that matter, such as pg_dump or your upload step.

One more step people skip: check that the backup can actually be restored. A heartbeat only proves the script finished. Once a month, restore a backup into a scratch database and run a sanity query. You can even automate that and give the restore test its own heartbeat.

Where alerts go

An alert only helps if you see it. A few guidelines:

  • Use a channel you already check. A push notification app, a chat webhook, or email to an address you actually read. In the scripts above, the notify function is the only thing you'd change.
  • Keep the alert path off the monitored server where you can. If the server is down, it can't send you email.
  • Test the path on purpose. Point the uptime check at a URL that returns 404 and make sure the alert arrives. Do it again after any change to your notification setup.
  • Put the hostname and the failing value in the message. "Disk at 91% on api-1" is something you can act on. "Check failed" is not.

Keeping it quiet

The quickest way to ruin a monitoring setup is noise. If an alert fires and you decide it doesn't matter, change the check that same day. Raise the threshold, require more consecutive failures, or delete it. Every alert you get should mean you need to do something.

Also watch the opposite problem: total silence. If nothing has fired in months, that could mean everything is fine, or that your alert path broke. A weekly "still alive" message from the monitoring machine, or a periodic manual test, settles the question.

A short checklist

  • External uptime check against a health endpoint, running from a different machine.
  • Alert after two consecutive failures, with a recovery message.
  • Disk usage threshold based on your measured growth rate.
  • OOM killer detection instead of memory percentage alerts.
  • TLS expiry check against the live endpoint, with at least a two-week warning.
  • Heartbeat pings for every scheduled job that matters, sent only on success.
  • A periodic restore test for backups.
  • An alert path you have tested end to end.

Wrapping up

Good monitoring for a small server isn't about collecting every metric. It answers three questions reliably: can people reach it, is it about to break, and did the background work happen. A couple of shell scripts, a second machine or hosted checker, and a heartbeat service cover all three, and you can set them up in an afternoon. Start with the external uptime check, add the others one at a time, and remove any alert that doesn't lead you to do something.