#!/usr/bin/env python3 import paramiko import sys c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("10.88.0.5", username="eric", password="4669805", timeout=15) log1 = "/opt/live/d2ypp/.pm2/logs/youtube2__ch_mp9mm36r_2wn0r-out.log" log2 = "/opt/live/d2ypp/.pm2/logs/youtube2__ch_mp9n7yu2_83vci-out.log" cmds = [ ("lane1_speed", f"grep 'speed=' {log1} | tail -20"), ("lane1_drop_count", f"grep -c 'invalid dropping' {log1} || true"), ("lane1_profile", f"grep -E 'YouTube Live profile|启动 YouTube|libx264|vaapi|stream copy' {log1} | tail -10"), ("lane2_drop_count", f"grep -c 'invalid dropping' {log2} || true"), ("lane2_speed", f"grep 'speed=' {log2} | tail -5"), ] for name, cmd in cmds: sys.stdout.buffer.write(f"\n=== {name} ===\n".encode()) _, stdout, stderr = c.exec_command(cmd, timeout=60) sys.stdout.buffer.write((stdout.read() + stderr.read()).decode("utf-8", "replace").encode("utf-8", "replace")) sys.stdout.buffer.write(b"\n") c.close()