$server-monitoring

Server Monitoring Bash Scripts

8 scripts · cron-ready · no agents · coreutils only

Your monitoring setup should answer three questions in under 30 seconds: is the service running, is the disk about to fill, and is the network reachable? Most teams buy a SaaS platform to answer these. Most of the time, six bash scripts do the same job at zero cost.

The scripts on this page use nothing beyond coreutils, systemctl, curl, and openssl — tools present on every Linux distribution and every cloud provider's base image. No agents to install. No API keys to rotate. No dashboard to log into at 2am. Just shell scripts on a cron that pipe clean output to a log and send an alert when something breaks.

The monitoring gap is always the same: things fail silently. A disk fills incrementally — 70%, 80%, 90% — until writes start failing and services begin crashing in confusing ways. A website goes down on a holiday weekend. A service segfaults and doesn't restart because there's no watchdog. An SSL certificate expires at 2am and HTTPS silently breaks. By the time a human notices, the window for a graceful fix is usually closed.

The scripts here are the watchdogs. Each one checks one thing, emits a clean status line, and fails loudly when the threshold is crossed. They are designed to be composed: run all of them from a single monitoring wrapper script, or schedule each independently depending on what you care about most.

Start with disk-space-warning — it is the most likely script to save you from a production outage in the next 90 days. Then add check-if-website-is-up if you run any public-facing service. If you manage a server with auto-renewing Let's Encrypt certificates, check-ssl-certificate-expiry closes the monitoring gap that renewal hooks miss: the hook runs, certbot silently fails, and the certificate expires anyway without anyone knowing until the browser warning appears.

All of these scripts assume the problem has already happened to you or someone you know. They are not tutorials. They are the scripts you add to /opt/scripts, chmod +x, and add to crontab the day you set up a new server.

Monitor your DigitalOcean droplets with these scripts — no third-party agents, no monthly fees.

Get $200 free credit — DigitalOcean

Get $200 Free →

Affiliate link · we earn a commission

Scripts in This Collection (8)

Disk Space Warning Script

Fires a warning when any mounted filesystem crosses a threshold. The simplest script on this page and the most likely to prevent a production outage.

Full guide →

Check If Website Is Up

Sends an HTTP request and checks the response code. Runs from cron and alerts when your site stops responding.

Full guide →

Monitor CPU and RAM Usage

Logs CPU load average and memory usage with timestamps. Catches resource exhaustion before services start crashing.

Full guide →

Restart Service If Stopped

Checks whether a systemd service is active and restarts it if not. The lightweight watchdog for services that don't auto-recover.

Full guide →

Quick System Info Report

Prints a one-screen health snapshot: uptime, load, memory, disk, and top processes. Run it the moment you SSH into an unfamiliar box.

Full guide →

Check SSL Certificate Expiry

Reads the live TLS certificate from a domain and reports days until expiry. Add to cron with a 30-day threshold for Let's Encrypt renewals.

Full guide →

Kill a Process

Safely terminates a named process with pgrep preview and pkill. Essential when a service hangs and needs a clean kill before you restart it.

Full guide →

Send Email Alerts from Bash

Sends a notification email from any monitoring script using sendmail or msmtp. The standard alert channel for cron-based monitoring.

Full guide →