# -*- coding: utf-8 -*- """Health/login/watch snapshot for dy + dylive; Recv-Q trend.""" from __future__ import annotations import json import sys import time import http.cookiejar import urllib.request import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def http_get(url, opener=None, timeout=15): op = opener or urllib.request.build_opener() try: with op.open(url, timeout=timeout) as r: return r.status, r.read().decode("utf-8", "replace")[:200] except Exception as ex: return getattr(ex, "code", None), str(ex)[:160] def http_post(url, body, opener=None, timeout=20): op = opener or urllib.request.build_opener() req = urllib.request.Request( url, data=json.dumps(body).encode(), headers={"Content-Type": "application/json"}, method="POST", ) try: with op.open(req, timeout=timeout) as r: return r.status, r.read().decode("utf-8", "replace")[:160], r.headers.get("Set-Cookie") except Exception as ex: return getattr(ex, "code", None), str(ex)[:160], None print("=== public dy ===") print("health", http_get("https://dy.nomadro.com/api/health")) print("ping", http_get("https://dy.nomadro.com/api/ping")) cj = http.cookiejar.CookieJar() op = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) st, body, sc = http_post( "https://dy.nomadro.com/api/auth/login", {"username": "hackrobot", "password": "Xiao4669805@"}, opener=op, ) print("login", st, body, (sc or "")[:100]) print("status", http_get("https://dy.nomadro.com/api/auth/status", opener=op)) print("rooms", http_get("https://dy.nomadro.com/api/rooms?limit=1", opener=op)) print("=== public dylive ===") print("health", http_get("https://dylive.nomadro.com/api/health")) print("ping", http_get("https://dylive.nomadro.com/api/ping")) # physical c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False) pw = "4669805" def sh(cmd, t=60): _, o, e = c.exec_command(f"echo '{pw}' | sudo -S -p '' bash -lc {repr(cmd)}", timeout=t) return (o.read() + e.read()).decode("utf-8", "replace") print("=== phys api ===") print(sh( "systemctl is-active douyinweb-api douyinweb-api-watch douyinweb-next 2>/dev/null; " "ss -ltn sport = :8014; " "ss -tn sport = :8014 | wc -l; " "curl -sS -m 3 http://127.0.0.1:8014/api/health | head -c 160; echo; " "journalctl -u douyinweb-api-watch -n 8 --no-pager; " "journalctl -u douyinweb-api --since '3 min ago' --no-pager | grep -cE 'ingest|ERROR|Traceback' || true" )) # sample Recv-Q for 30s print("=== recvq sample ===") for i in range(6): print(i, sh("ss -ltn sport = :8014 | awk 'NR==2{print $2}'").strip(), flush=True) time.sleep(5) c.close() # VPS c2 = paramiko.SSHClient() c2.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c2.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False) def sh2(cmd, t=60): _, o, e = c2.exec_command(cmd, timeout=t) return (o.read() + e.read()).decode("utf-8", "replace") print("=== vps api ===") print(sh2( "systemctl is-active douyinweb-api douyinweb-api-watch 2>/dev/null; " "ss -ltn sport = :8014; " "curl -sS -m 3 http://127.0.0.1:8014/api/health | head -c 160; echo; " "grep -n 'pure in-process\\|_cn_edge_cache\\|_ping_wg_cache\\|/api/ping' " "/opt/douyinWEB/backend/app/main.py /opt/douyinWEB/backend/app/youtube_neko.py " "/opt/douyinWEB/backend/app/network_hub.py /opt/douyinWEB/backend/app/session_auth.py 2>/dev/null | head -20" )) c2.close()