34 lines
2.1 KiB
Python
34 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
import paramiko
|
|
|
|
HOST, USER, PASS = "10.88.0.4", "eric", "4669805"
|
|
|
|
CMDS = [
|
|
("mem_detail", "free -h; swapon --show; cat /proc/meminfo | grep -E 'MemTotal|MemAvailable|Swap'"),
|
|
("cpu", "lscpu | grep -E 'Model name|CPU\\(s\\)|MHz'"),
|
|
("deploy_path", "ls -la /home/eric/d2ypp2-src/ /opt/live/d2ypp/ 2>&1 | head -20"),
|
|
("hw_files", "ls -la /home/eric/d2ypp2-src/config/hardware* 2>&1; cat /home/eric/d2ypp2-src/config/hardware-profile.json 2>/dev/null"),
|
|
("hw_env", "cat /home/eric/d2ypp2-src/config/hardware.env 2>/dev/null"),
|
|
("pm2_full", "PM2_HOME=/home/eric/d2ypp2-src/.pm2 pm2 list 2>/dev/null"),
|
|
("ffmpeg_cmd", "ps auxww | grep -E 'ffmpeg.*rtmps' | grep -v grep"),
|
|
("stream_mode", "grep -hE 'stream copy|transcode|YouTube Live profile|hardware relay|video_mode' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -15"),
|
|
("speed_lines", "grep -h 'speed=' /home/eric/d2ypp2-src/.pm2/logs/youtube2__*-out.log 2>/dev/null | tail -20"),
|
|
("ini_all", "grep -H '' /home/eric/d2ypp2-src/config/youtube*.ini 2>/dev/null | head -40"),
|
|
("quality", "curl -sS -m 15 http://127.0.0.1:8001/youtube/quality_guard 2>/dev/null | head -c 5000"),
|
|
("process_mon", "curl -sS -m 15 'http://127.0.0.1:8001/process_monitor?family=youtube' 2>/dev/null"),
|
|
("compare_ffmpeg", "which -a ffmpeg; /usr/bin/ffmpeg -version 2>&1 | head -1; /usr/local/bin/ffmpeg -version 2>&1 | head -1"),
|
|
("docker_neko", "docker ps --format '{{.Names}} {{.Status}}' 2>/dev/null | head -15"),
|
|
("load_per_cpu", "mpstat -P ALL 1 1 2>/dev/null || top -bn1 | head -8"),
|
|
("oom", "dmesg 2>/dev/null | grep -iE 'oom|killed process' | tail -5; journalctl -k --no-pager 2>/dev/null | grep -i oom | tail -3"),
|
|
]
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASS, timeout=15)
|
|
for label, cmd in CMDS:
|
|
print(f"\n=== {label} ===")
|
|
_, o, e = c.exec_command(cmd, timeout=60, get_pty=True)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace")
|
|
print(out[:6000].encode("ascii", "backslashreplace").decode())
|
|
c.close()
|