#!/bin/bash # 看两个隧道服务现在的真实配置(作为口径基准) set -u for s in lanremote-tunnel lanremote-tunnel-h2; do echo "── $s ──" if [ -f "/etc/systemd/system/$s.service" ]; then grep -oE '\-\-protocol [a-z0-9]+|--ha-connections [0-9]+|--metrics [0-9.:]+' \ "/etc/systemd/system/$s.service" | tr '\n' ' ' echo echo " enabled=$(systemctl is-enabled "$s" 2>/dev/null) active=$(systemctl is-active "$s" 2>/dev/null)" else echo " (服务不存在)" fi done echo echo "── 合计连接数 ──" for p in 20241 20242; do n=$(curl -s --max-time 4 "http://127.0.0.1:$p/metrics" 2>/dev/null \ | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}') printf " 端口 %s -> %s 条\n" "$p" "${n:-(读不到)}" done echo echo "── 公网自检 ──" curl -s --max-time 15 -o /dev/null -w ' HTTP %{http_code} %{time_total}s\n' \ https://relay.xxmxxs.top/v1/health