From a8c604f215ec7a4560f124c141f2f669efa793c8 Mon Sep 17 00:00:00 2001 From: mango Date: Sun, 22 Feb 2026 19:45:49 +0800 Subject: [PATCH] feat: README + one-click install scripts for server and agent --- README.md | 115 ++++++++++++++++++++++++++++++++++------------- install-agent.sh | 80 +++++++++++++++++++++++++++++++++ install.sh | 49 ++++++++++++++++++++ 3 files changed, 214 insertions(+), 30 deletions(-) create mode 100755 install-agent.sh create mode 100755 install.sh diff --git a/README.md b/README.md index 3a7d746..c3c03ca 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,100 @@ -# OpenClaw Monitor +# 🐾 OC Monitor β€” OpenClaw Mission Control -Multi-node monitoring dashboard for OpenClaw instances. +Real-time monitoring dashboard for [OpenClaw](https://github.com/openclaw/openclaw) multi-node deployments. -## Architecture +![Dashboard](https://img.shields.io/badge/status-active-brightgreen) ![License](https://img.shields.io/badge/license-MIT-blue) -- **Server**: Node.js + SQLite + WebSocket (central dashboard) -- **Agent**: Bash script on each OpenClaw machine, reports heartbeat + metrics +## ✨ Features -## Quick Start +- **Real-time metrics** β€” CPU / Memory / Disk / Swap with live jitter animation (10s refresh) +- **Provider health checks** β€” Auto-detect all configured AI providers, latency monitoring +- **Default model detection** β€” Auto-identifies most-used provider per node (green dot indicator) +- **Request logging** β€” Track API calls across all nodes with filtering by node / provider / result +- **Multi-node support** β€” Lightweight bash+python agent, works on macOS & Linux +- **Dark / Light theme** β€” Toggle with localStorage persistence +- **WebSocket push** β€” Instant updates, no polling +- **Admin panel** β€” Node management, token display, one-click agent install command generator +- **Docker deployment** β€” Single container, SQLite storage + +## πŸš€ Quick Start + +### 1. Deploy Server (Docker) -### Server (Docker) ```bash -docker run -d --name oc-monitor -p 3800:3800 -v oc-monitor-data:/app/data ghcr.io/mango082888-bit/oc-monitor -# Get auth token -docker logs oc-monitor 2>&1 | grep "Auth token" +curl -fsSL https://raw.githubusercontent.com/mango082888-bit/oc-monitor/main/install.sh | bash ``` -### Agent +This will: +- Pull the repo and build the Docker image +- Generate a random auth token +- Start the container on port **3800** +- Print the dashboard URL and token + +### 2. Install Agent on Each Node + +After server is running, install the agent on each OpenClaw node: + ```bash -curl -sL https://raw.githubusercontent.com/mango082888-bit/oc-monitor/main/agent/agent.sh -o agent.sh -chmod +x agent.sh -./agent.sh -s http://YOUR_SERVER:3800 -t YOUR_TOKEN -n "My Node" -r master +curl -fsSL https://raw.githubusercontent.com/mango082888-bit/oc-monitor/main/install-agent.sh | bash -s -- \ + -s http://YOUR_SERVER_IP:3800 \ + -t YOUR_AUTH_TOKEN \ + -n "Node Name" ``` -## Features +The agent auto-detects: +- OpenClaw config, providers, and models +- System metrics (CPU, memory, disk, swap) +- Gateway & daemon status +- Session count and token usage +- Default/most-used provider -- Real-time node status (CPU/mem/disk/swap) -- Provider health matrix across all nodes -- API request logging with TTFT/latency tracking -- Auto-detect OpenClaw config changes -- WebSocket live updates -- Dark theme UI +### 3. Open Dashboard -## API +Visit `http://YOUR_SERVER_IP:3800` in your browser. -| Endpoint | Method | Auth | Description | -|---|---|---|---| -| `/api/dashboard` | GET | No | Full dashboard data | -| `/api/heartbeat` | POST | Yes | Agent heartbeat report | -| `/api/request` | POST | Yes | Log API request | -| `/api/node/rename` | POST | Yes | Rename a node | -| `/api/node/:id` | DELETE | Yes | Remove a node | +## πŸ“ Architecture -Auth: `Authorization: Bearer ` +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Node Agent β”‚ β”‚ Node Agent β”‚ β”‚ Node Agent β”‚ +β”‚ (bash+py) β”‚ β”‚ (bash+py) β”‚ β”‚ (bash+py) β”‚ +β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ HTTP POST β”‚ β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β–Ό + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ OC Monitor β”‚ + β”‚ Server β”‚ + β”‚ (Node.js+SQLiteβ”‚ + β”‚ +WebSocket) β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ WS push + β–Ό + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ Browser β”‚ + β”‚ Dashboard β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +## πŸ”§ Configuration + +| Env Variable | Default | Description | +|---|---|---| +| `PORT` | `3800` | Server listen port | +| `AUTH_TOKEN` | (required) | Bearer token for API auth | + +## πŸ“‹ API Endpoints + +| Method | Path | Description | +|---|---|---| +| GET | `/api/dashboard` | Full dashboard data | +| POST | `/api/heartbeat` | Agent heartbeat report | +| POST | `/api/request` | API request log (single or batch) | +| POST | `/api/rename` | Rename a node | +| DELETE | `/api/node/:id` | Remove a node | + +All POST/DELETE endpoints require `Authorization: Bearer ` header. + +## License + +MIT diff --git a/install-agent.sh b/install-agent.sh new file mode 100755 index 0000000..5ce7e28 --- /dev/null +++ b/install-agent.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# OC Monitor - One-click agent install +set -e + +SERVER="" TOKEN="" NAME="" ROLE="worker" +while getopts "s:t:n:r:" opt; do + case $opt in s)SERVER="$OPTARG";;t)TOKEN="$OPTARG";;n)NAME="$OPTARG";;r)ROLE="$OPTARG";;esac +done + +if [ -z "$SERVER" ] || [ -z "$TOKEN" ]; then + echo "Usage: $0 -s SERVER_URL -t AUTH_TOKEN [-n NAME] [-r ROLE]" + echo " -s Server URL (e.g. http://1.2.3.4:3800)" + echo " -t Auth token" + echo " -n Node name (default: hostname)" + echo " -r Role: master|worker (default: worker)" + exit 1 +fi + +[ -z "$NAME" ] && NAME=$(hostname) +AGENT="/usr/local/bin/oc-monitor-agent.sh" + +echo "🐾 OC Monitor Agent Installer" +echo "==============================" + +# Check deps +for cmd in python3 curl; do + command -v $cmd &>/dev/null || { echo "❌ $cmd not found"; exit 1; } +done + +# Download agent +echo "πŸ“¦ Downloading agent..." +curl -fsSL https://raw.githubusercontent.com/mango082888-bit/oc-monitor/main/agent/agent.sh -o "$AGENT" +chmod +x "$AGENT" + +# Detect init system +if [ "$(uname)" = "Darwin" ]; then + PLIST="$HOME/Library/LaunchAgents/com.oc-monitor.agent.plist" + echo "🍎 Setting up launchd service..." + cat > "$PLIST" < + + +Labelcom.oc-monitor.agent +ProgramArguments +/bin/bash$AGENT +-s$SERVER +-t$TOKEN +-n$NAME +-r$ROLE + +RunAtLoad +KeepAlive +StandardOutPath/tmp/oc-monitor-agent.log +StandardErrorPath/tmp/oc-monitor-agent.log + +EOF + launchctl unload "$PLIST" 2>/dev/null || true + launchctl load "$PLIST" + echo "βœ… Agent running (launchd)" +else + echo "🐧 Setting up systemd service..." + cat > /etc/systemd/system/oc-monitor-agent.service </dev/null; then + echo "❌ Docker not found. Install docker first." + exit 1 +fi + +# Clone or update +if [ -d "$DIR" ]; then + echo "πŸ“¦ Updating existing installation..." + cd "$DIR" && git pull +else + echo "πŸ“¦ Cloning repository..." + git clone https://github.com/mango082888-bit/oc-monitor.git "$DIR" + cd "$DIR" +fi + +# Build and run +echo "πŸ”¨ Building Docker image..." +docker build -t oc-monitor . + +docker rm -f oc-monitor 2>/dev/null || true +echo "πŸš€ Starting container..." +docker run -d --name oc-monitor --restart always \ + -p "$PORT:3800" \ + -v oc-monitor-data:/app/data \ + -e "AUTH_TOKEN=$TOKEN" \ + oc-monitor + +IP=$(hostname -I 2>/dev/null | awk '{print $1}' || curl -s ifconfig.me) + +echo "" +echo "βœ… OC Monitor is running!" +echo "========================" +echo "🌐 Dashboard: http://$IP:$PORT" +echo "πŸ”‘ Auth Token: $TOKEN" +echo "" +echo "πŸ“‘ Install agent on each node:" +echo " curl -fsSL https://raw.githubusercontent.com/mango082888-bit/oc-monitor/main/install-agent.sh | bash -s -- -s http://$IP:$PORT -t $TOKEN -n \"NodeName\""