Update
This commit is contained in:
parent
d37503c863
commit
1509789cde
19 changed files with 1534 additions and 112 deletions
96
README.md
96
README.md
|
|
@ -1,99 +1,47 @@
|
|||
# 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](https://git.gsdistance.org/tyuXX/RUD)).
|
||||
Lightweight uptime monitor and health checker written in Go by [tyuXX] ([git.gsdistance.org/tyuXX/RUD](https://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:///home/devuser/workspace/RUD/rud.json) file.
|
||||
Mainly created for use in GsDistance.org.
|
||||
|
||||
---
|
||||
|
||||
## 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.
|
||||
- **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`.
|
||||
Compiles to a single static binary, checks `http`/`https`, `tcp`, `ping`, `dns`, and `cmd` targets, sends declarative alerts (webhooks/commands), and serves a minimal status page plus JSON health output — all configured through one `rud.json` file. Full check history is kept in daily JSONL logs (zstd-compressed) and a SQLite stats database, viewable per-monitor at `/monitor`.
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Run as a Standalone Binary
|
||||
### Standalone binary
|
||||
|
||||
```bash
|
||||
# Build the self-contained binary
|
||||
go build -trimpath -ldflags="-s -w" -o rud .
|
||||
|
||||
# (Optional) Generate a default rud.json explicitly
|
||||
./rud -init -config rud.json
|
||||
|
||||
# Run R u ded? (auto-generates rud.json if not present)
|
||||
./rud -config rud.json
|
||||
./rud -config rud.json # auto-generates rud.json if missing
|
||||
```
|
||||
|
||||
Query the single endpoint:
|
||||
Then open `http://localhost:8080/` (HTML) or `http://localhost:8080/?format=json` (JSON).
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```bash
|
||||
# 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/
|
||||
docker compose up -d --build # exposes port 8080, persists ./data
|
||||
```
|
||||
|
||||
### Docker Compose + Cloudflare Tunnel (no exposed ports)
|
||||
|
||||
```bash
|
||||
cp .env.example .env # set TUNNEL_TOKEN=...
|
||||
docker compose -f docker-compose.cloudflared.yml up -d --build
|
||||
```
|
||||
|
||||
Point your tunnel's public hostname at `http://rud:8080`.
|
||||
|
||||
---
|
||||
|
||||
### 2. Run with Docker Compose (Direct Port Exposure)
|
||||
## Configuration
|
||||
|
||||
Uses [`docker-compose.yml`](./docker-compose.yml) to expose port `8080` directly on the host:
|
||||
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
Edit `./rud.json` and restart the container to apply changes:
|
||||
```bash
|
||||
docker compose restart rud
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. Run with Docker Compose + Cloudflare Tunnel (Zero Exposed Host Ports)
|
||||
|
||||
Uses [`docker-compose.cloudflared.yml`](./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:
|
||||
```bash
|
||||
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:
|
||||
```text
|
||||
http://rud:8080
|
||||
```
|
||||
3. Start the stack:
|
||||
```bash
|
||||
docker compose -f docker-compose.cloudflared.yml up -d --build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuration Documentation
|
||||
|
||||
See [**`CONFIGURATION.md`**](./CONFIGURATION.md) for the complete reference covering every section, check method, declarative event condition, and UI element in `rud.json`.
|
||||
See [**`CONFIGURATION.md`**](./CONFIGURATION.md) for the full `rud.json` reference — monitors, check methods, alert events, page elements, and storage/history options.
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
MIT License — Created by **tyuXX** for **GsDistance.org** ([https://git.gsdistance.org/tyuXX/RUD](https://git.gsdistance.org/tyuXX/RUD)).
|
||||
MIT — Created by **tyuXX** for **GsDistance.org**.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue