douyinWEB/scripts/_diag_yt_relay_cpu.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

35 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
def run(cmd: str, timeout: int = 60) -> str:
_, o, e = c.exec_command(cmd, timeout=timeout)
return (o.read() + e.read()).decode("utf-8", "replace").strip()
print("=== cpu ===")
print(run("nproc; lscpu | grep -E 'Model name|CPU\\(s\\)|Thread|MHz' | head -10"))
print("=== load ===")
print(run("uptime; free -h | head -2"))
print("=== ffmpeg procs ===")
print(run("ps -eo pid,pcpu,pmem,etime,cmd --sort=-pcpu | grep -E '[f]fmpeg|[u]vicorn' | head -25"))
print("=== relay settings bitrate ===")
print(
run(
"cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'\n"
"from app import db\n"
"m=db.get_settings_map()\n"
"print('bitrate', m.get('youtube_relay_bitrate'))\n"
"print('rtmps', m.get('youtube_relay_use_rtmps'))\n"
"print('enabled', m.get('youtube_relay_enabled'))\n"
"PY"
)
)
c.close()