Auto backup: 2026-02-21 07:01

This commit is contained in:
Krilly
2026-02-21 07:01:51 +00:00
parent 8757148122
commit 17b5b82d99
2012 changed files with 352552 additions and 331 deletions

View File

@@ -5,13 +5,13 @@
## What's Different?
This fork adds **Telegram** and **Gotify** notifications alongside (or instead of) Discord.
This fork adds **Telegram** and **ntfy** notifications alongside (or instead of) Discord.
| Feature | Original | This Fork |
|---------|----------|-----------|
| Discord alerts | ✅ | ✅ (optional) |
| Telegram alerts | ❌ | ✅ |
| Gotify alerts | ❌ | ✅ |
| ntfy alerts | ❌ | ✅ |
| Multi-channel | ❌ | ✅ (simultaneous) |
## Quick Install
@@ -25,8 +25,8 @@ chmod +x setup.sh watchdog.sh
The installer will ask for:
- Telegram Bot Token
- Gotify Token
- Gotify URL (defaults to your setup)
- ntfy Token
- ntfy URL (defaults to your setup)
## Configuration
@@ -37,9 +37,10 @@ Edit `~/.openclaw/watchdog.env`:
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT=1793951355
# Required for Gotify
GOTIFY_URL=http://runtipi.kangaroo-eel.ts.net:8129
GOTIFY_TOKEN=your_gotify_token_here
# Required for ntfy
NTFY_URL=https://ntfy.sh
NTFY_TOPIC=anthony-krilly-9f3k2
NTFY_MIN_PRIORITY=4
# Optional: Legacy Discord
DISCORD_CHANNEL_ID=
@@ -58,7 +59,7 @@ Same great watchdog behavior from the original:
4. **Stage 3:** SOS alert after 3+ failures
5. **Recovery:** Notification when gateway comes back
But now alerts go to **Telegram** and **Gotify** too!
But now alerts go to **Telegram** and **ntfy** too!
## Managing the Service
@@ -74,7 +75,7 @@ tail -f ~/.openclaw/watchdog.log # View logs
```bash
export TELEGRAM_BOT_TOKEN="your_token"
export TELEGRAM_CHAT="1793951355"
export GOTIFY_TOKEN="your_token"
export NTFY_TOPIC="your_topic"
# Source the functions and test
source ~/.openclaw/watchdog.sh

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# openclaw-watchdog installer (Krilly's fork — Telegram + Gotify edition)
# openclaw-watchdog installer (Krilly's fork — Telegram + ntfy edition)
# https://github.com/jlgrimes/openclaw-watchdog
set -euo pipefail
@@ -7,7 +7,7 @@ INSTALL_DIR="$HOME/.openclaw"
SERVICE_NAME="openclaw-watchdog"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "🦞 OpenClaw Watchdog — Installer (Krilly's Telegram/Gotify Edition)"
echo "🦞 OpenClaw Watchdog — Installer (Krilly's Telegram/ntfy Edition)"
echo "───────────────────────────────────────────────────────────────────"
# Ensure install dir exists
@@ -22,14 +22,17 @@ echo "✅ Installed watchdog.sh → $INSTALL_DIR/watchdog.sh"
TELEGRAM_BOT_TOKEN=""
read -rp "Telegram Bot Token (leave blank to skip): " TELEGRAM_BOT_TOKEN
# Prompt for Gotify token
GOTIFY_TOKEN=""
read -rp "Gotify Token (leave blank to skip): " GOTIFY_TOKEN
# Prompt for ntfy topic
NTFY_URL="https://ntfy.sh"
read -rp "ntfy Server URL [$NTFY_URL]: " custom_ntfy
[[ -n "$custom_ntfy" ]] && NTFY_URL="$custom_ntfy"
# Prompt for custom Gotify URL
GOTIFY_URL="http://runtipi.kangaroo-eel.ts.net:8129"
read -rp "Gotify URL [$GOTIFY_URL]: " custom_gotify
[[ -n "$custom_gotify" ]] && GOTIFY_URL="$custom_gotify"
NTFY_TOPIC=""
read -rp "ntfy Topic (leave blank to skip): " NTFY_TOPIC
NTFY_MIN_PRIORITY="4"
read -rp "ntfy Min Priority [$NTFY_MIN_PRIORITY]: " custom_prio
[[ -n "$custom_prio" ]] && NTFY_MIN_PRIORITY="$custom_prio"
# Create env file
ENV_FILE="$INSTALL_DIR/watchdog.env"
@@ -46,8 +49,9 @@ OPENCLAW_CONFIG_PATH=$HOME/.openclaw/config.yaml
# Notification Settings
TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
TELEGRAM_CHAT=1793951355
GOTIFY_URL=${GOTIFY_URL}
GOTIFY_TOKEN=${GOTIFY_TOKEN}
NTFY_URL=${NTFY_URL}
NTFY_TOPIC=${NTFY_TOPIC}
NTFY_MIN_PRIORITY=${NTFY_MIN_PRIORITY}
# Legacy Discord (optional)
# DISCORD_CHANNEL_ID=
@@ -91,4 +95,4 @@ echo " Config: $ENV_FILE"
echo ""
echo "You'll get alerts via:"
[[ -n "$TELEGRAM_BOT_TOKEN" ]] && echo " ✅ Telegram"
[[ -n "$GOTIFY_TOKEN" ]] && echo "Gotify ($GOTIFY_URL)"
[[ -n "$NTFY_TOPIC" ]] && echo "ntfy ($NTFY_URL/$NTFY_TOPIC)"

View File

@@ -13,11 +13,11 @@ FAIL_THRESHOLD="${FAIL_THRESHOLD:-3}" # consecutive failures before es
WATCHDOG_LOG="${WATCHDOG_LOG:-$HOME/.openclaw/watchdog.log}"
GOOD_CONFIG_PATH="${GOOD_CONFIG_PATH:-$HOME/.openclaw/config.yaml.good}"
# Notification settings (Telegram + Gotify)
# Notification settings (Telegram + ntfy)
TELEGRAM_BOT_TOKEN="${TELEGRAM_BOT_TOKEN:-}"
TELEGRAM_CHAT="${TELEGRAM_CHAT:-1793951355}"
GOTIFY_URL="${GOTIFY_URL:-http://runtipi.kangaroo-eel.ts.net:8129}"
GOTIFY_TOKEN="${GOTIFY_TOKEN:-AGKnHafW3FGzBlt}"
NTFY_URL="${NTFY_URL:-}"
NTFY_TOPIC="${NTFY_TOPIC:-}"
# Legacy Discord settings (optional, for backwards compat)
DISCORD_CHANNEL_ID="${DISCORD_CHANNEL_ID:-}"
@@ -62,18 +62,31 @@ telegram_send() {
>/dev/null 2>&1 || log "WARN: Failed to send Telegram message"
}
# ─── Gotify messaging ────────────────────────────────────────────────────────
gotify_send() {
# ─── ntfy messaging ────────────────────────────────────────────────────────
ntfy_send() {
local title="$1"
local msg="$2"
local priority="${3:-5}"
[[ -z "$GOTIFY_TOKEN" ]] && return 0
local priority="${3:-4}" # 1-5 or low|default|high|urgent
local sound="${4:-default}"
[[ -z "$NTFY_URL" ]] && return 0
[[ -z "$NTFY_TOPIC" ]] && return 0
# Enforce minimum priority (default 4)
local minp="${NTFY_MIN_PRIORITY:-4}"
if [[ "$priority" =~ ^[0-9]+$ ]] && [[ "$minp" =~ ^[0-9]+$ ]]; then
if (( priority < minp )); then
priority="$minp"
fi
fi
curl -sf -X POST \
"${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"title\": \"$title\", \"message\": \"$msg\", \"priority\": $priority}" \
>/dev/null 2>&1 || log "WARN: Failed to send Gotify message"
"${NTFY_URL%/}/${NTFY_TOPIC}" \
-H "Title: $title" \
-H "Priority: $priority" \
-H "Sound: $sound" \
-d "$msg" \
>/dev/null 2>&1 || log "WARN: Failed to send ntfy message"
}
# ─── Send to all configured channels ─────────────────────────────────────────
@@ -84,7 +97,7 @@ send_notification() {
discord_send "$msg"
telegram_send "$msg"
gotify_send "$title" "$msg" "$priority"
ntfy_send "$title" "$msg" "4" "default"
}
# ─── Health check ─────────────────────────────────────────────────────────────
@@ -155,7 +168,7 @@ send_recovery() {
# ─── Main loop ────────────────────────────────────────────────────────────────
main() {
log "Watchdog started (interval=${CHECK_INTERVAL}s, threshold=${FAIL_THRESHOLD}, health=${HEALTH_URL})"
log "Notifications: Telegram=${TELEGRAM_CHAT:+enabled}, Gotify=${GOTIFY_TOKEN:+enabled}, Discord=${DISCORD_CHANNEL_ID:+enabled}"
log "Notifications: Telegram=${TELEGRAM_CHAT:+enabled}, ntfy=${NTFY_TOPIC:+enabled}, Discord=${DISCORD_CHANNEL_ID:+enabled}"
while true; do
if check_health; then