#!/usr/bin/env python3 import paramiko import sys HOSTS = [ ("10.88.0.4", "4669805", "/home/eric/d2ypp2-src"), ("10.88.0.5", "4669805", "/opt/live/d2ypp"), ] def run(host: str, pw: str, cmd: str) -> str: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(host, username="eric", password=pw, timeout=15) _, o, e = c.exec_command(cmd, timeout=90) out = (o.read() + e.read()).decode("utf-8", "replace") c.close() return out def main() -> None: for host, pw, base in HOSTS: print(f"\n{'='*60}\n{host} {base}\n{'='*60}") cmds = { "md5": f"md5sum {base}/douyin_youtube_ffplay.py", "re_flags": f"grep -nE 'readrate|wallclock| -re |\\-re,' {base}/douyin_youtube_ffplay.py | head -15", "lanes": f"ls -1 {base}/config/youtube.youtube2__*.ini 2>/dev/null", "keys": f"grep -H '^key' {base}/config/youtube.youtube2__*.ini 2>/dev/null", "ffmpeg": "ps auxww | grep 'ffmpeg.*rtmps' | grep -v grep", "speed": f"grep 'speed=' {base}/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -4", "lane1_tail": f"tail -15 {base}/.pm2/logs/$(ls -1 {base}/.pm2/logs/youtube2__*-out.log 2>/dev/null | head -1) 2>/dev/null", "monitor": "curl -sS -m 10 'http://127.0.0.1:8001/process_monitor?family=youtube&light=1' 2>/dev/null | python3 -c \"import json,sys; d=json.load(sys.stdin); [print(e.get('pm2'), e.get('business_status'), 'speed='+str(e.get('ffmpeg_speed'))) for e in d.get('entries',[])]\" 2>/dev/null", } for name, cmd in cmds.items(): sys.stdout.buffer.write(f"\n--- {name} ---\n".encode()) sys.stdout.buffer.write(run(host, pw, cmd).encode("utf-8", "replace")) if __name__ == "__main__": main()