#!/bin/bash # 分析 530 的性质:中转收到了吗?还是 Cloudflare 边缘就没送进来? set -u echo "════════ 1. 中转日志在 17:31 前后的记录 ════════" awk '/\[10-07 17:2[89]|\[10-07 17:3[0-4]/' /root/lanremote-relay/relay.log 2>/dev/null \ | tail -40 | sed 's/^/ /' echo echo "════════ 2. 中转日志里有没有"健康检查"级别的记录 ════════" echo " 说明:中转对 /v1/health 不写日志(太频繁)。" echo " 所以"中转没记录"不能证明它没收到 —— 得靠 totalRequests 增量判断。" echo echo "════════ 3. 当前 totalRequests 和运行时长 ════════" curl -s --max-time 10 http://127.0.0.1:8080/v1/health \ | python3 -c " import sys, json d = json.load(sys.stdin) print(' totalRequests:', d.get('totalRequests')) print(' uptimeSeconds:', d.get('uptimeSeconds')) print(' 平均每秒请求数: %.3f' % (d.get('totalRequests', 0) / max(d.get('uptimeSeconds', 1), 1))) print(' devices:', len(d.get('devices', [])), ' sessions:', d.get('sessions')) " echo echo "════════ 4. HTTP 5xx 都是什么时候出现的(从长测数据)════════" awk -F'\t' 'NR>1 && $2!="200" {print " " $1 " 码=" $2 " " $3 "ms"}' /root/long2h_health.tsv 2>/dev/null echo echo "════════ 5. 这些失败时刻,连接数是多少(对齐最近一次采样)════════" awk -F'\t' ' NR==FNR { if (FNR>1 && $2!="200") bad[NR]=$1; next } { lines[++n]=$0 } END { for (k in bad) { t=bad[k] best="" for (i=1;i<=n;i++) { split(lines[i], f, "\t") if (f[1] <= t) best=lines[i] } print " 失败 " t " <- 最近采样: " best } }' /root/long2h_health.tsv /root/long2h_conns.tsv | sort | sed 's/^/ /' echo echo "════════ 6. 两个 tunnel 日志里,17:28~17:35 的事件 ════════" echo " ── QUIC ──" grep -E '2026-10-07T09:(2[89]|3[0-5])' /root/lanremote-relay/tunnel.log 2>/dev/null \ | grep -E 'Registered|Lost|Failed|Unregistered' | tail -12 | sed 's/^/ /' echo " ── HTTP/2 ──" grep -E '2026-10-07T09:(2[89]|3[0-5])' /root/lanremote-relay/tunnel-h2.log 2>/dev/null \ | grep -E 'Registered|Lost|Failed|Unregistered' | tail -12 | sed 's/^/ /' echo echo "════════ 7. watchdog 在这段时间的处置 ════════" grep -E '17:2[89]|17:3[0-5]' /root/lanremote-relay/watchdog.log 2>/dev/null | sed 's/^/ /'