57 lines
2.5 KiB
Python
57 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Compare live streaming hosts on the same LAN."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
import paramiko
|
|
|
|
HOSTS = [
|
|
("10.88.0.4", "eric", "4669805"),
|
|
("10.88.0.5", "eric", "4669805"),
|
|
]
|
|
|
|
|
|
def run(host: str, user: str, password: str, cmd: str, timeout: int = 45) -> str:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(host, username=user, password=password, timeout=15)
|
|
try:
|
|
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
finally:
|
|
c.close()
|
|
|
|
|
|
def safe(text: str, limit: int = 6000) -> str:
|
|
return text.encode("ascii", "backslashreplace").decode()[:limit]
|
|
|
|
|
|
def main() -> None:
|
|
cmds = [
|
|
"hostname; uptime; free -h | head -2; nproc; uname -m",
|
|
"curl -sS -m 8 http://127.0.0.1:8001/health 2>/dev/null || echo health_fail",
|
|
"curl -sS -m 12 'http://127.0.0.1:8001/process_monitor?family=youtube&light=1' 2>/dev/null | head -c 5000",
|
|
"pgrep -af 'ffmpeg.*rtmps' || echo NO_FFMPEG",
|
|
"ps aux | grep 'd2ypp2.*/youtube.py' | grep -v grep || echo NO_YOUTUBE",
|
|
"grep -E 'stream copy|transcode|speed=|Douyin web data fetch|YouTube Live profile' $(ls -t /home/eric/d2ypp2-src/.pm2/logs/youtube2__ch_*-out.log 2>/dev/null | head -2) 2>/dev/null | tail -8 || true",
|
|
"test -f /home/eric/d2ypp2-src/douyin_youtube_ffplay.py && grep -c '_resolve_stream_copy_plan' /home/eric/d2ypp2-src/douyin_youtube_ffplay.py || echo NO_COPY_FIX",
|
|
"grep -H 'video_mode\\|fast_audio' /home/eric/d2ypp2-src/config/youtube.youtube2__ch_*.ini 2>/dev/null | head -6",
|
|
"curl -sS -m 5 -x socks5://127.0.0.1:7890 https://www.gstatic.com/generate_204 -w 'proxy7890=%{http_code}\\n' -o /dev/null 2>/dev/null; curl -sS -m 5 -x http://127.0.0.1:7894 https://www.gstatic.com/generate_204 -w 'proxy7894=%{http_code}\\n' -o /dev/null 2>/dev/null",
|
|
"systemctl is-active shellcrash live-console 2>/dev/null; ss -tlnp 2>/dev/null | grep -E ':7890|:7894|:8001' || true",
|
|
"ls -d /home/eric/d2ypp2* 2>/dev/null | head -5",
|
|
]
|
|
for host, user, password in HOSTS:
|
|
print(f"\n{'#' * 70}\n# HOST {host}\n{'#' * 70}")
|
|
for cmd in cmds:
|
|
print(f"\n--- {cmd[:72]} ---")
|
|
try:
|
|
out = run(host, user, password, cmd)
|
|
print(safe(out))
|
|
except Exception as exc:
|
|
print(f"ERROR: {exc}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|