Ayodele AjimatiContact ↗
05 · DevOps & Infrastructure← All projects

Shell Script Website Monitor

Lightweight automated website monitoring system using shell scripting — periodic HTTP checks, uptime logging, and failure alerts without requiring a full observability stack.

GitHub repository ↗5 tools · 4 measured outcomes
Shell Script Website Monitor

Problem

Before reaching for Prometheus and Grafana, you need to understand why monitoring exists. A freelance client needed basic uptime tracking for three web properties with zero infrastructure budget. The requirement: detect downtime within 5 minutes and send an alert.

Approach

  1. 01

    Wrote a Bash script using curl to perform HTTP checks and capture response codes and response times.

  2. 02

    Added logic to classify responses: 2xx (up), 4xx/5xx (application error), timeout (infrastructure failure).

  3. 03

    Implemented structured logging of uptime/downtime events with timestamps to a flat log file.

  4. 04

    Built a simple alert function supporting email notification and webhook (Slack-compatible) triggers.

  5. 05

    Scheduled execution every 5 minutes using cron — no daemon, no dependencies.

  6. 06

    Added a daily summary report script that aggregates uptime percentage from the log file.

Results

Detection window
< 5 minutes
Dependencies
None (bash + curl)
Alert channels
Email + webhook
Uptime log retention
30 days rolling

Code

Core HTTP check with response code classification and alert trigger.

check_site() {
  local url=$1
  local response
  response=$(curl -s -o /dev/null -w "%{http_code} %{time_total}" \
    --max-time 10 "$url")

  local code time
  read -r code time <<< "$response"

  local ts
  ts=$(date '+%Y-%m-%d %H:%M:%S')

  if [[ $code =~ ^2 ]]; then
    echo "$ts UP $url $code ${time}s" >> "$LOG_FILE"
  else
    echo "$ts DOWN $url $code ${time}s" >> "$LOG_FILE"
    send_alert "$url" "$code"
  fi
}

Stack

  • Bash
  • curl
  • cron
  • SMTP
  • Webhook / Slack

Why it matters

  • Zero external dependencies — runs on any Linux/macOS server with bash and curl installed.
  • Flat log format makes it trivially parseable by any downstream tool.
  • Built as a client project on Upwork — zero-infrastructure budget requirement.