57 lines
2.9 KiB
Python
57 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Quick remote diagnostics for live streaming host."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
HOST = sys.argv[1] if len(sys.argv) > 1 else "10.88.0.4"
|
|
USER = sys.argv[2] if len(sys.argv) > 2 else "eric"
|
|
PASS = sys.argv[3] if len(sys.argv) > 3 else "4669805"
|
|
|
|
COMMANDS = [
|
|
"hostname; uptime; free -h | head -3",
|
|
"which pm2; PM2_HOME=/etc/.pm2 pm2 list 2>/dev/null; PM2_HOME=$HOME/.pm2 pm2 list 2>/dev/null",
|
|
"ps aux | grep -E 'ffmpeg|youtube|douyin|ffplay' | grep -v grep | head -40",
|
|
"ss -tlnp 2>/dev/null | head -40",
|
|
"systemctl is-active live-console shellcrash 2>/dev/null; docker ps --format '{{.Names}} {{.Status}}' 2>/dev/null | head -20",
|
|
"find /opt /home/eric -maxdepth 4 -name 'd2ypp*' -type d 2>/dev/null | head -10",
|
|
"for p in 8001 8000 9200 9201 7890 7894; do curl -sS -m 3 -o /dev/null -w \"port=$p code=%{http_code}\\n\" http://127.0.0.1:$p/ 2>/dev/null; done",
|
|
"curl -sS -m 8 http://127.0.0.1:8001/api/process-monitor 2>/dev/null | head -c 5000",
|
|
"curl -sS -m 8 http://127.0.0.1:8001/process-monitor 2>/dev/null | head -c 5000",
|
|
"ls -la /etc/.pm2/logs/ 2>/dev/null | tail -20",
|
|
"tail -30 /etc/.pm2/logs/*youtube*out*.log 2>/dev/null | tail -80",
|
|
"tail -30 /etc/.pm2/logs/*youtube*error*.log 2>/dev/null | tail -80",
|
|
"wg show 2>/dev/null | head -30",
|
|
"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",
|
|
"for pid in $(pgrep -f 'ffmpeg.*rtmps://a.rtmps.youtube.com'); do echo PID=$pid; timeout 3 cat /proc/$pid/fd/2 2>/dev/null | tail -3; done",
|
|
"curl -sS -m 10 http://127.0.0.1:8001/api/process-monitor/list 2>/dev/null | head -c 10000",
|
|
"curl -sS -m 10 http://127.0.0.1:8001/hub/youtube/quality 2>/dev/null | head -c 10000",
|
|
"grep -r speed= /home/eric/d2ypp2-src/logs/ /var/log/ 2>/dev/null | tail -15",
|
|
"ls -la /root/.pm2/logs/ 2>/dev/null; ls -la /home/eric/d2ypp2-src/logs/ 2>/dev/null | tail -15",
|
|
"grep fast_audio /home/eric/d2ypp2-src/config/youtube*.ini 2>/dev/null",
|
|
"head -80 /home/eric/d2ypp2-src/douyin_youtube_ffplay.py 2>/dev/null | tail -5; grep -n fast_audio /home/eric/d2ypp2-src/douyin_youtube_ffplay.py 2>/dev/null | head -5",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(HOST, username=USER, password=PASS, timeout=20)
|
|
for cmd in COMMANDS:
|
|
print(f"\n{'='*20} {cmd[:72]} {'='*20}")
|
|
_, stdout, stderr = client.exec_command(cmd, timeout=60)
|
|
out = stdout.read().decode("utf-8", "replace")
|
|
err = stderr.read().decode("utf-8", "replace")
|
|
if out.strip():
|
|
print(out[:12000])
|
|
if err.strip():
|
|
print("STDERR:", err[:2000])
|
|
client.close()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|