#!/usr/bin/env python3 import sys import paramiko if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace") HOST = "108.174.50.68" USER = "root" PASS = "Xiao4669805" REMOTE_PY = r""" import sqlite3 c = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db') tables = [r[0] for r in c.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall()] print('tables:', ', '.join(tables[:25])) for t in tables: if 'setting' in t.lower(): try: cols = [r[1] for r in c.execute(f'PRAGMA table_info({t})').fetchall()] print(f'table {t} cols={cols}') rows = c.execute( f"SELECT * FROM {t} WHERE " + " OR ".join([f"key LIKE 'yt_long%'" , "key LIKE 'shorts%'", "key LIKE 'youtube_relay%'"]) ).fetchall() for row in rows[:30]: print(' ', row) except Exception as e: print(' err', t, e) if 'yt_long_jobs' in tables: print('yt_long_jobs:') for r in c.execute('SELECT status, count(1) FROM yt_long_jobs GROUP BY status').fetchall(): print(' ', r) for r in c.execute( "SELECT id, status, created_at FROM yt_long_jobs " "WHERE status IN ('recording','pending','queued','processing') " "ORDER BY created_at DESC LIMIT 5" ).fetchall(): print(' active', r) """ cmds = [ 'docker ps --format "table {{.Names}}\t{{.Status}}" | grep -E "neko|NAME"', 'pgrep -a ffmpeg || echo no_ffmpeg', 'uptime', f"/opt/douyinWEB/backend/.venv/bin/python -c {REMOTE_PY!r}", ] c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, USER, PASS, timeout=45, allow_agent=False, look_for_keys=False) for cmd in cmds: print("===", cmd[:90], "===") _, stdout, stderr = c.exec_command(cmd, timeout=30) print(stdout.read().decode("utf-8", "replace")) err = stderr.read().decode("utf-8", "replace").strip() if err: print("ERR:", err[:400]) print() c.close()