Files
ykxmz/_build/device_health.sh
T
xmz7891 b705216e4a ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞
- 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀?
鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException
- 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴?
鏈嶅姟鍣ㄧ
- 鏀寔 chunked 璇锋眰浣擄紙淇瘡 16 绉掍竴娆$殑杩炴帴閿欎贡涓庡ぇ闈㈢Н 502锛?- 缃戠粶璋冧紭鑴氭湰 net-tune.sh锛堝紑鏈鸿嚜鍔ㄥ簲鐢級
- 绠$悊椤碉細鎵归噺鍒犻櫎銆佺綉缁滀綋妫€銆佷笅杞藉尯
- 闅ч亾鏀?HTTP/2 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
2026-10-06 19:01:05 +08:00

106 lines
3.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 中转服务器的内存 / 健壮性检查(这台机器只有 460MB)
#
# 查三件事:
# 1. 服务有没有自己崩过 / 重启过
# 2. 会话、队列涨起来之后内存会不会失控
# 3. 时间长了有没有泄漏(看两次采样的差值)
set -u
BASE=http://127.0.0.1:8080
echo "===== 1. 服务状态 ====="
for svc in lanremote-relay lanremote-tunnel; do
state=$(systemctl is-active "$svc" 2>/dev/null)
restarts=$(systemctl show "$svc" -p NRestarts 2>/dev/null | cut -d= -f2)
since=$(systemctl show "$svc" -p ActiveEnterTimestamp 2>/dev/null | cut -d= -f2)
printf " %-18s %-9s 重启 %s 次 自 %s\n" "$svc" "$state" "$restarts" "$since"
done
echo
echo "===== 2. 系统内存 ====="
free -m | awk 'NR==1{print " " $0} NR==2{printf " 总 %s MB 已用 %s MB 可用 %s MB\n", $2, $3, $7}'
echo
echo "===== 3. 各进程内存(前 8)====="
ps -eo rss,comm --sort=-rss 2>/dev/null | head -9 | tail -8 | \
while read -r rss comm; do
printf " %6s KB %s\n" "$rss" "$comm"
done
echo
echo "===== 4. 中转服务自报的内存 ====="
curl -s --max-time 8 "$BASE/v1/health" > /tmp/relay_health.json 2>/dev/null
if [ -s /tmp/relay_health.json ]; then
python3 - <<'PY'
import json
try:
d = json.load(open('/tmp/relay_health.json'))
except Exception as exc:
print(f" 解析失败: {exc}")
raise SystemExit
print(f" 版本 {d.get('version')}")
print(f" 已运行 {d.get('uptimeSeconds')} 秒")
print(f" 累计请求 {d.get('totalRequests')}")
print(f" 设备 {len(d.get('devices', []))} 台")
print(f" 会话 {d.get('sessions')}")
print(f" Rss {d.get('memoryKB', 0)} KB ({d.get('memoryKB', 0)//1024} MB)")
PY
else
echo " 健康检查没响应"
fi
echo
echo "===== 5. 内存稳定性:连续采样 10 次,每次隔 3 秒 ====="
echo " (如果一直涨,说明有泄漏)"
FIRST=""
LAST=""
for i in $(seq 1 10); do
# 打一批请求,模拟真实使用
for j in 1 2 3 4 5; do
curl -s -o /dev/null --max-time 5 "$BASE/v1/health" &
done
wait
RSS=$(curl -s --max-time 5 "$BASE/v1/health" \
| grep -oE '"memoryKB": *[0-9]+' | grep -oE '[0-9]+')
[ -z "$RSS" ] && RSS=0
if [ -z "$FIRST" ]; then FIRST=$RSS; fi
LAST=$RSS
printf " 第 %2d 次: %6s KB\n" "$i" "$RSS"
sleep 3
done
echo
echo " 第一次 $FIRST KB -> 最后一次 $LAST KB"
if [ "$FIRST" -gt 0 ]; then
DIFF=$((LAST - FIRST))
echo " 变化 ${DIFF} KB"
if [ "$DIFF" -gt 8000 ]; then
echo " ⚠ 涨了超过 8MB,可能有泄漏"
else
echo " ✓ 基本稳定"
fi
fi
echo
echo "===== 6. 队列上限保护(客户端不取数据时会丢最旧的,不涨内存)====="
echo " 队列上限设的是 2MB/设备(RELAY_QUEUE_BYTES)"
echo " 当前各设备队列:"
curl -s --max-time 8 "$BASE/v1/health" > /tmp/relay_health2.json 2>/dev/null
python3 - <<'PY'
import json
try:
d = json.load(open('/tmp/relay_health2.json'))
except Exception:
raise SystemExit
devices = d.get('devices', [])
if not devices:
print(" (还没有设备上线,队列都是空的)")
for item in devices:
print(f" {item.get('name')}: 待发手表 {item.get('queuedToClient')} 字节"
f" / 待发电脑 {item.get('queuedToAgent')} 字节")
PY
echo
echo "===== 7. 磁盘 ====="
df -h / | awk 'NR==2{printf " 总 %s 已用 %s 可用 %s (%s)\n", $2, $3, $4, $5}'