#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Inventory rooms/core tables on dylive VPS vs physical guest.""" import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def ssh(h, p, u, pw): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(h, p, u, pw, timeout=45, banner_timeout=90, allow_agent=False, look_for_keys=False) return c def run(c, cmd, t=60): _, o, e = c.exec_command(cmd, timeout=t) return (o.read() + e.read()).decode("utf-8", "replace") SQL = r''' python3 - <<'PY' import sqlite3 from pathlib import Path p = Path("/opt/douyinWEB/backend/data/monitor.db") print("db", p, "exists", p.is_file(), "size", p.stat().st_size if p.is_file() else 0) if not p.is_file(): raise SystemExit(0) c = sqlite3.connect(str(p)) c.row_factory = sqlite3.Row tables = [r[0] for r in c.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1")] print("tables", tables) for t in tables: try: n = c.execute(f"SELECT COUNT(*) FROM [{t}]").fetchone()[0] except Exception as ex: n = f"err:{ex}" print(f" {t}: {n}") if "rooms" in tables: print("--- rooms sample ---") for r in c.execute("SELECT id, room_id, url, nickname, enabled, last_status FROM rooms ORDER BY id LIMIT 8"): print(dict(r)) print("enabled", c.execute("SELECT COUNT(*) FROM rooms WHERE enabled=1").fetchone()[0]) c.close() PY ''' print("===== DYLIVE VPS (local app) =====") v = ssh("107.173.30.245", 22, "root", "Xiao4669805") print(run(v, SQL, 30)) print("path check", run(v, "ls -la /opt/douyinWEB/backend/data/monitor.db* 2>/dev/null; curl -sS -m 5 https://dylive.nomadro.com/api/health | head -c 300; echo", 20)) v.close() print("===== PHYSICAL =====") g = ssh("107.173.30.245", 4014, "eric", "4669805") print(run(g, f"echo 4669805 | sudo -S -p '' bash -c '{SQL}'", 40)) g.close()