douyinWEB/scripts/_diag_neko_latency2.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

73 lines
2.2 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Extended Neko diagnostics."""
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"
def ssh(host, port, user, pw):
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, cmd, timeout=120):
_, o, e = c.exec_command(cmd, timeout=timeout)
return (o.read() + e.read()).decode("utf-8", "replace")
def main():
v = ssh(VPS, 22, "root", VPS_PASS)
print("=== full caddy dy.nomadro.com neko blocks ===")
print(run(v, "sed -n '25,70p' /etc/caddy/sites/dy.nomadro.com.caddy", 30))
print("=== external neko latency ===")
print(
run(
v,
'curl -sS -o /dev/null -w "ext neko1: dns=%{time_namelookup}s connect=%{time_connect}s tls=%{time_appconnect}s ttfb=%{time_starttransfer}s total=%{time_total}s code=%{http_code}\n" --connect-timeout 15 https://dy.nomadro.com/neko/1/ 2>&1',
30,
)
)
print("=== wg mtu / stats ===")
print(run(v, "wg show wg-dy 2>/dev/null; ip link show wg-dy 2>/dev/null | head -3", 20))
v.close()
p = ssh(VPS, 4014, "eric", "4669805")
print("=== docker neko (sudo) ===")
print(
run(
p,
"echo '4669805' | sudo -S docker ps -a --filter name=douyinweb-neko --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' 2>&1",
30,
)
)
print("=== neko1 env inside container ===")
print(
run(
p,
"echo '4669805' | sudo -S docker inspect douyinweb-neko-1 --format '{{range .Config.Env}}{{println .}}{{end}}' 2>&1 | grep -E 'NEKO_|FPS|BITRATE|SCREEN|NAT|PROXY'",
30,
)
)
print("=== neko1 logs tail ===")
print(run(p, "echo '4669805' | sudo -S docker logs --tail 25 douyinweb-neko-1 2>&1", 30))
print("=== home public ip ===")
print(run(p, "curl -sS -m 5 https://api.ipify.org 2>&1; echo", 15))
p.close()
if __name__ == "__main__":
main()