RUD/README.md

5.5 KiB

R u ded? (rud)

R u ded? (rud) is a performant, lightweight, self-contained uptime monitor and health checker written in Go by tyuXX for GsDistance.org (git.gsdistance.org/tyuXX/RUD).

It compiles to a single zero-dependency binary, runs concurrent checks across multiple protocols, evaluates declarative alert rules, and serves a single HTTP endpoint whose minimal status page and JSON health output are configured entirely through a single human-readable rud.json file.


Features

  • Single rud.json Configuration: Intuitive, human-readable JSON file loaded at startup. Automatically generates a sensible default rud.json if missing.
  • Strict Config-Driven Minimalist UI: Renders only the UI elements, bars, and metrics declared in rud.json (plus a subtle 'Powered by R u ded?' attribution footer), with all CSS and live-refresh JS inlined into a single fast response.
  • Single HTTP Endpoint (HTML + JSON):
    • Browser requests receive the clean, minimal status page with automatic background updates.
    • Requests with Accept: application/json or ?format=json receive structured JSON status and metrics.
    • Configurable HTTP status codes per state (defaults HTML to 200 so Cloudflare Tunnel never intercepts your status page with a 5xx error screen).
  • Multi-Method Health Checks:
    • http / https: Status codes, custom request headers, body regex matching, latency, TLS options.
    • tcp: Port connectivity and handshake latency.
    • ping: Direct ICMP echo reachability and RTT latency.
    • dns: Record resolution (A, AAAA, CNAME, MX, TXT, NS), custom resolvers, and regex validation.
    • cmd: Custom shell commands or scripts with exit code and output regex verification.
  • Declarative Event & Alert Engine: Combine monitor boolean triggers (all or any of monitor IDs in a state), sustained durations (e.g., "for": "5h"), and metric thresholds (uptime_pct, latency_ms, consecutive_failures) using "and" / "or" logic to trigger outbound webhooks or execute commands.
  • Interactive CLI Config Builder (rud config): Built-in zero-dependency CLI to create new configurations from starter templates or a quick-start wizard, edit existing rud.json files (including nested AND/OR event condition trees, Discord/Slack/ntfy/Gotify webhook presets, and theme presets), test monitors live, validate/lint (rud validate), and save atomically with optional .bak backups.
  • In-Memory Ring Buffer + Optional Persistence: Maximum speed in-memory circular buffer by default, with optional atomic disk persistence across restarts.
  • Docker & Cloudflare Tunnel Ready: Includes a multi-stage Dockerfile, a direct docker-compose.yml, and a zero-exposed-port docker-compose.cloudflared.yml.

Quick Start

1. Run as a Standalone Binary

# Build the self-contained binary
go build -trimpath -ldflags="-s -w" -o rud .

# (Optional) Build or edit rud.json interactively
./rud config -config rud.json

# (Optional) Generate a default rud.json non-interactively
./rud -init -config rud.json

# Validate & lint rud.json, or run one-shot live checks
./rud validate -config rud.json
./rud test -config rud.json

# Run R u ded? (auto-generates rud.json if not present)
./rud -config rud.json

CLI Subcommands

  • ./rud config [-config path] [-new] [-plain] [-no-color]: Interactive configuration builder (arrow-key navigation on TTYs with automatic numbered fallback; -new forces the starter template / quick-start wizard).
  • ./rud validate [-config path] [-strict]: Validates schema, regexes, URLs, and alert templates, and reports lint warnings (unknown JSON fields, dangling monitor IDs). -strict treats lint warnings as errors.
  • ./rud test [-config path] [-json] [-no-retry] [monitor-ids...]: Executes live monitor checks once and prints results (exits non-zero if any tested monitor is down).

Query the single endpoint:

# Minimal HTML Status Page
curl http://localhost:8080/

# Structured JSON Output (via query parameter or Accept header)
curl "http://localhost:8080/?format=json"
curl -H "Accept: application/json" http://localhost:8080/

2. Run with Docker Compose (Direct Port Exposure)

Uses docker-compose.yml to expose port 8080 directly on the host:

docker compose up -d --build

Edit ./rud.json and restart the container to apply changes:

docker compose restart rud

3. Run with Docker Compose + Cloudflare Tunnel (Zero Exposed Host Ports)

Uses docker-compose.cloudflared.yml to run rud and cloudflared on an isolated internal Docker bridge network (rud_tunnel_net) with no ports bound to the host:

  1. Copy .env.example to .env and set your Cloudflare Tunnel token:
    cp .env.example .env
    # Set TUNNEL_TOKEN=... in .env
    
  2. In your Cloudflare Zero Trust dashboard, configure your tunnel's Public Hostname service URL to point to:
    http://rud:8080
    
  3. Start the stack:
    docker compose -f docker-compose.cloudflared.yml up -d --build
    

Configuration Documentation

See CONFIGURATION.md for the complete reference covering every section, check method, declarative event condition, and UI element in rud.json.


License

MIT License — Created by tyuXX for GsDistance.org (https://git.gsdistance.org/tyuXX/RUD).