sh2/d2ypp2/tools/_check_host04_lanes.py
2026-06-14 10:41:48 -05:00

41 lines
1.3 KiB
Python

#!/usr/bin/env python3
import json
import paramiko
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("10.88.0.4", username="eric", password="4669805", timeout=20)
B = "/home/eric/d2ypp2-src"
def run(cmd: str, timeout: int = 90) -> str:
_, o, e = c.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=timeout, get_pty=True)
return (o.read() + e.read()).decode("utf-8", "replace")
raw = run("curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'")
entries = json.loads(raw).get("entries", [])
print("=== all youtube lanes ===")
for row in entries:
pm2 = row.get("pm2", "")
if not pm2.startswith("youtube"):
continue
print(
pm2,
row.get("business_status"),
f"pushing={row.get('is_pushing')}",
f"speed={row.get('ffmpeg_speed')}",
repr((row.get("source_display") or "")[:50]),
)
print("\n=== ffmpeg ===")
print(run("pgrep -af ffmpeg | grep -v pgrep | head -6"))
print("\n=== live profile lines ===")
print(run(f"grep -h 'YouTube Live profile' {B}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -6"))
print("\n=== recent errors ===")
print(run(f"grep -hE '外层异常|NameError|DuplicateOption' {B}/.pm2/logs/youtube2__*-err.log 2>/dev/null | tail -5 || echo none"))
c.close()