Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
91 lines
3.3 KiB
Python
91 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Diagnose Neko latency on dy.nomadro.com physical deploy."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
if hasattr(sys.stdout, "reconfigure"):
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
VPS = "107.173.30.245"
|
|
VPS_PASS = "Xiao4669805"
|
|
PVE_PORT = 4014
|
|
PVE_USER = "eric"
|
|
PVE_PASS = "4669805"
|
|
|
|
|
|
def ssh(host: str, port: int, user: str, pw: str) -> paramiko.SSHClient:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(host, port, user, pw, timeout=45, allow_agent=False, look_for_keys=False)
|
|
return c
|
|
|
|
|
|
def run(c: paramiko.SSHClient, cmd: str, timeout: float = 120) -> str:
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
VPS_SCRIPT = r"""#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
echo '=== WG ping ==='
|
|
ping -c 3 -W 2 10.8.0.2 2>&1 || true
|
|
echo '=== latency direct to neko ports (WG) ==='
|
|
for p in 9200 9201 9202; do
|
|
curl -sS -o /dev/null -w "port ${p}: time=%{time_total}s code=%{http_code}\n" --connect-timeout 5 "http://10.8.0.2:${p}/" 2>&1 || echo "port ${p}: FAIL"
|
|
done
|
|
echo '=== latency via Caddy localhost ==='
|
|
for id in 1 2 3; do
|
|
curl -sS -o /dev/null -w "neko/${id}: time=%{time_total}s code=%{http_code}\n" --connect-timeout 10 -k "https://127.0.0.1/neko/${id}/" -H 'Host: dy.nomadro.com' 2>&1 || true
|
|
done
|
|
echo '=== caddy neko routes ==='
|
|
grep -n 'neko' /etc/caddy/sites/dy.nomadro.com.caddy 2>/dev/null | head -30 || grep -rn 'neko' /etc/caddy/sites/ 2>/dev/null | head -20
|
|
echo '=== iptables webrtc forward ==='
|
|
iptables -t nat -L PREROUTING -n 2>/dev/null | grep -E '5230|5200|5210|5220' | head -15 || echo 'no nat rules'
|
|
echo '=== ufw neko ports ==='
|
|
ufw status 2>/dev/null | grep -E '5230|5200|9200' | head -15 || true
|
|
"""
|
|
|
|
PVE_SCRIPT = r"""#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
echo '=== neko env ==='
|
|
grep NEKO /etc/douyinweb.env 2>/dev/null || true
|
|
systemctl show douyinweb-api -p Environment 2>/dev/null | tr ' ' '\n' | grep NEKO || true
|
|
echo '=== compose settings ==='
|
|
grep -E 'DESKTOP_SCREEN|MAX_FPS|VIDEO_BITRATE|NAT1TO1|BROWSER_PROXY|HTTP_BIND|0\.0\.0\.0:920' /opt/douyinWEB/backend/data/neko/docker-compose.yml 2>/dev/null | head -30
|
|
echo '=== docker neko status ==='
|
|
docker ps -a --filter name=douyinweb-neko --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' 2>/dev/null
|
|
echo '=== local curl neko ==='
|
|
for p in 9200 9201 9202; do
|
|
curl -sS -o /dev/null -w "local ${p}: time=%{time_total}s code=%{http_code}\n" --connect-timeout 5 "http://127.0.0.1:${p}/" 2>&1 || true
|
|
done
|
|
echo '=== cpu/mem ==='
|
|
uptime
|
|
free -h | head -3
|
|
docker stats --no-stream 2>/dev/null | head -8 || true
|
|
echo '=== shellcrash proxy ==='
|
|
curl -sS -o /dev/null -w 'proxy7890=%{time_total}s code=%{http_code}\n' --connect-timeout 5 http://127.0.0.1:7890/ 2>&1 || true
|
|
echo '=== nat1to1 file ==='
|
|
cat /opt/douyinWEB/backend/data/neko/nat1to1.txt 2>/dev/null || echo missing
|
|
"""
|
|
|
|
|
|
def main() -> int:
|
|
print("===== VPS (107.173.30.245) =====")
|
|
v = ssh(VPS, 22, "root", VPS_PASS)
|
|
print(run(v, VPS_SCRIPT, 90))
|
|
v.close()
|
|
|
|
print("===== PHYSICAL (10.8.0.2 via FRP) =====")
|
|
p = ssh(VPS, PVE_PORT, PVE_USER, PVE_PASS)
|
|
print(run(p, PVE_SCRIPT, 120))
|
|
p.close()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|