#!/usr/bin/env python3 import json import paramiko HOST, USER, PASS, BASE = "10.88.0.4", "eric", "4669805", "/home/eric/d2ypp2-src" c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, username=USER, password=PASS, timeout=20) def run(cmd: str) -> str: _, o, e = c.exec_command(f"export LC_ALL=C.UTF-8; {cmd}", timeout=90, get_pty=True) return (o.read() + e.read()).decode("utf-8", "replace") checks = { "health": run("curl -sf -m 8 http://127.0.0.1:8001/health"), "copy_fn": run(f"grep -c _resolve_stream_copy_plan {BASE}/douyin_youtube_ffplay.py 2>/dev/null || echo 0").strip(), "key_guard": run(f"grep -c _looks_like_youtube_output_rejected {BASE}/douyin_youtube_ffplay.py").strip(), "relay": run(f"grep -c relay_strategy {BASE}/config/hardware-profile.json 2>/dev/null || echo 0").strip(), "ffmpeg": run("pgrep -af 'ffmpeg.*rtmps' | grep -v pgrep | head -3"), "profile": run(f"grep -h 'YouTube Live profile' {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4"), "speed": run(f"grep -h 'speed=' {BASE}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4"), "qg": run( "curl -sS -m 12 http://127.0.0.1:8001/hub/youtube/quality_guard | " "python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('ffmpeg_profile',{}).get('target','?'))\"" ).strip(), } print(json.dumps(checks, ensure_ascii=False, indent=2)) raw = run("curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube'") for row in json.loads(raw).get("entries", []): pm2 = row.get("pm2", "") if pm2.startswith("youtube2"): print(pm2, row.get("business_status"), row.get("is_pushing"), row.get("ffmpeg_speed")) ok = ( checks["copy_fn"] in {"0", ""} and checks["relay"] in {"0", ""} and "libx264" in (checks["ffmpeg"] + checks["profile"]) ) print("REGRESSION:", "PASS" if ok else "PARTIAL") c.close()