#!/bin/bash # 现状全面勘察(只读):双隧道实例、watchdog、日志、连接数 set -u echo "════════ 1. 隧道服务清单 ════════" for u in lanremote-tunnel lanremote-tunnel-h2; do if systemctl list-unit-files 2>/dev/null | grep -q "^$u.service"; then echo " ── $u ──" echo " 状态: $(systemctl is-active $u 2>/dev/null) / $(systemctl is-enabled $u 2>/dev/null)" systemctl cat $u 2>/dev/null | grep -E '^ExecStart=' | sed 's/^/ /' else echo " ── $u:不存在 ──" fi done echo echo "════════ 2. cloudflared 进程 ════════" ps -eo pid,etime,rss,cmd 2>/dev/null | grep -E 'cloudflared' | grep -v grep | sed 's/^/ /' echo echo "════════ 3. 谁绑上了 20241 metrics 端口 ════════" ss -tlnp 2>/dev/null | grep 20241 | sed 's/^/ /' || echo " (没人绑)" echo " metrics 报的连接数:" curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null \ | grep -E '^cloudflared_tunnel_ha_connections' | sed 's/^/ /' echo echo "════════ 4. 两个实例各自的日志文件 ════════" ls -la /root/lanremote-relay/*.log 2>/dev/null | sed 's/^/ /' echo echo "════════ 5. watchdog 脚本关键逻辑 ════════" grep -nE 'metrics|20241|ha_connections|CONNS|restart_tunnel|systemctl restart' \ /root/lanremote-relay/watchdog.sh 2>/dev/null | head -30 | sed 's/^/ /' echo echo "════════ 6. watchdog 服务状态 ════════" systemctl is-active lanremote-watchdog 2>/dev/null | sed 's/^/ active: /' systemctl is-enabled lanremote-watchdog 2>/dev/null | sed 's/^/ enabled: /' echo " 最近 15 行 watchdog 日志:" tail -15 /root/lanremote-relay/watchdog.log 2>/dev/null | sed 's/^/ /' echo echo "════════ 7. net-tune(MTU/MSS 持久化)════════" echo " wlan0 MTU: $(cat /sys/class/net/wlan0/mtu 2>/dev/null)" iptables -t mangle -S OUTPUT 2>/dev/null | grep TCPMSS | sed 's/^/ /' systemctl cat lanremote-nettune 2>/dev/null | grep ExecStart | sed 's/^/ /' echo echo "════════ 8. 中转版本和健康 ════════" curl -s --max-time 10 http://127.0.0.1:8080/v1/health | head -c 160 | sed 's/^/ /' echo echo " 长轮询设定: $(grep -oE 'RELAY_POLL=[0-9]+' /etc/systemd/system/lanremote-relay.service 2>/dev/null)" echo echo "════════ 9. 系统负载 / 内存 ════════" uptime | sed 's/^/ /' free -m | sed 's/^/ /'