#!/bin/bash # 验证改进后的 watchdog set -u echo " 一、语法检查" if bash -n /root/lanremote-relay/watchdog.sh 2>&1; then echo " ✓ watchdog.sh 语法 OK" else echo " ✗ 语法有问题" fi echo echo " 二、手动跑一次(看它怎么判断)" bash /root/lanremote-relay/watchdog.sh 2>&1 | tail -4 | sed 's/^/ /' echo echo " 三、公网连打 15 次" ok=0 for i in $(seq 1 15); do c=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 \ -H 'User-Agent: LanRemote/1.4.0' https://relay.xxmxxs.top/v1/health) [ "$c" = "200" ] && ok=$((ok + 1)) printf " %2d: %s\n" "$i" "$c" sleep 1 done echo " 可用 $ok/15" echo echo " 四、当前连接数" echo " $(curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}') 条" echo echo " 五、watchdog 定时器" systemctl list-timers lanremote-watchdog.timer --no-pager 2>/dev/null | head -3 | sed 's/^/ /' echo echo " 六、watchdog 日志最后 6 行" tail -6 /root/lanremote-relay/watchdog.log 2>/dev/null | sed 's/^/ /'