#!/usr/bin/env python3 """Query 10.88.0.3 YouTube lane 1 config and recent logs.""" from __future__ import annotations import paramiko HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805" BASE = "/home/eric/d2ypp2-src" def q(cmd: str, timeout: int = 90) -> str: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, username=USER, password=PASS, timeout=15) _, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True) out = (o.read() + e.read()).decode("utf-8", "replace") c.close() return out CMDS = [ ("identity", f"hostname; ls -d {BASE} /opt/live/d2ypp 2>/dev/null"), ("pm2", f"PM2_HOME={BASE}/.pm2 pm2 list 2>/dev/null | head -30"), ("ini_files", f"ls -la {BASE}/config/youtube.youtube2__*.ini {BASE}/config/url.youtube2__*.ini 2>/dev/null"), ( "hub_db", f"find {BASE} -maxdepth 3 \\( -name '*.db' -o -name 'hub*.json' \\) 2>/dev/null | head -20", ), ( "youtube_pro_kv", f"""python3 - <<'PY' import sqlite3, json, glob, os base = '{BASE}' paths = glob.glob(base + '/data/*.db') + glob.glob(base + '/.hub/*.db') + glob.glob(base + '/**/*.db', recursive=True) seen = set() for p in paths: if p in seen: continue seen.add(p) try: conn = sqlite3.connect(p) rows = conn.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall() if not rows: continue for key in ('youtube_pro_channels_v1',): try: r = conn.execute('SELECT value FROM kv WHERE key=?', (key,)).fetchone() if r: print('DB', p) print(r[0][:12000]) except Exception: pass conn.close() except Exception as e: pass PY""", ), ( "all_ini", f"for f in {BASE}/config/youtube.youtube2__*.ini; do echo '=== $f ==='; cat \"$f\"; done 2>/dev/null", ), ( "all_url_ini", f"for f in {BASE}/config/url.youtube2__*.ini; do echo '=== $f ==='; cat \"$f\"; done 2>/dev/null", ), ( "logs_lane1", f"ls -la {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | head -20", ), ( "grep_douyin_logs", f"grep -hE 'live.douyin.com|douyin.com/[0-9]|source|拉流|stream_url|web data' {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -80", ), ( "grep_12h", f"find {BASE}/.pm2/logs -name 'youtube2__*-out.log' -mmin -900 2>/dev/null | while read f; do echo '=== $f ==='; grep -E 'live.douyin.com|start|stop|推流|duration|session' \"$f\" | tail -30; done", ), ( "process_monitor", "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube' 2>/dev/null | head -c 8000", ), ] def main() -> int: for label, cmd in CMDS: print(f"\n{'=' * 60}\n=== {label} ===\n{'=' * 60}") try: out = q(cmd) print(out[:12000].encode("ascii", "backslashreplace").decode()) except Exception as exc: print(f"ERR: {exc}") return 0 if __name__ == "__main__": raise SystemExit(main())