Auto backup: 2026-02-21 07:01
This commit is contained in:
@@ -10,8 +10,9 @@ DATA_FILE="$SCRIPT_DIR/monitor-state.json"
|
||||
source "$SCRIPT_DIR/../../.env" 2>/dev/null || true
|
||||
|
||||
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:-}"
|
||||
NTFY_MIN_PRIORITY="${NTFY_MIN_PRIORITY:-4}"
|
||||
|
||||
# Services to monitor
|
||||
# Format: name|url|type|restart_command(optional)
|
||||
@@ -139,19 +140,28 @@ send_telegram() {
|
||||
}" > /dev/null || log "Failed to send Telegram"
|
||||
}
|
||||
|
||||
# Send Gotify alert
|
||||
send_gotify() {
|
||||
# Send ntfy alert
|
||||
send_ntfy() {
|
||||
local title="$1"
|
||||
local message="$2"
|
||||
local priority="${3:-5}"
|
||||
|
||||
curl -s -X POST "${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"$title\",
|
||||
\"message\": \"$message\",
|
||||
\"priority\": $priority
|
||||
}" > /dev/null || log "Failed to send Gotify"
|
||||
local priority="${3:-4}"
|
||||
local sound="${4:-default}"
|
||||
|
||||
[[ -z "$NTFY_URL" ]] && return 0
|
||||
[[ -z "$NTFY_TOPIC" ]] && return 0
|
||||
|
||||
# Enforce minimum priority (default 4)
|
||||
if [[ "$priority" =~ ^[0-9]+$ ]] && [[ "$NTFY_MIN_PRIORITY" =~ ^[0-9]+$ ]]; then
|
||||
if (( priority < NTFY_MIN_PRIORITY )); then
|
||||
priority="$NTFY_MIN_PRIORITY"
|
||||
fi
|
||||
fi
|
||||
|
||||
curl -s -X POST "${NTFY_URL%/}/${NTFY_TOPIC}" \
|
||||
-H "Title: $title" \
|
||||
-H "Priority: $priority" \
|
||||
-H "Sound: $sound" \
|
||||
-d "$message" > /dev/null 2>&1 || log "Failed to send ntfy"
|
||||
}
|
||||
|
||||
# Attempt self-healing
|
||||
@@ -241,7 +251,7 @@ check_services() {
|
||||
# Send alert
|
||||
if ! alert_cooldown_active "$name" "down"; then
|
||||
send_telegram "🚨 *Service Down: $name*\n\nStatus: $status_code\nURL: $url\n\nAuto-heal failed. Manual intervention may be needed."
|
||||
send_gotify "Service Down: $name" "$name is down (status: $status_code)" 8
|
||||
send_ntfy "🚨 Service Down: $name" "$name is down (status: $status_code)\nURL: $url" 4 default
|
||||
log_alert "$name" "down"
|
||||
|
||||
# Update failure stats
|
||||
|
||||
Reference in New Issue
Block a user