douyinWEB/scripts/_pve_check_rooms.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

42 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
import sys, paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
p = paramiko.SSHClient()
p.set_missing_host_key_policy(paramiko.AutoAddPolicy())
p.connect("107.173.30.245", 4014, "eric", "4669805", timeout=25, allow_agent=False, look_for_keys=False)
script = r'''
import sqlite3, os
os.chdir("/opt/douyinWEB/backend/data")
c=sqlite3.connect("monitor.db")
print("tables", [r[0] for r in c.execute("select name from sqlite_master where type='table'")])
for t in ["rooms","events"]:
try:
print(t, c.execute(f"select count(*) from {t}").fetchone()[0])
except Exception as ex:
print(t, ex)
try:
for r in c.execute("select id, url, name from rooms limit 8"):
print(r)
except Exception as ex:
print("rows", ex)
'''
sftp = p.open_sftp()
with sftp.file("/tmp/_rooms.py", "w") as f:
f.write(script)
sftp.close()
_, o, e = p.exec_command("echo '4669805' | sudo -S -p '' python3 /tmp/_rooms.py", timeout=20)
print(o.read().decode("utf-8","replace"))
err = e.read().decode("utf-8","replace")
if err.strip():
print("ERR", err[-400:])
# remove leftover import json / stash dbs so they cannot be used later
_, o, e = p.exec_command(
"echo '4669805' | sudo -S -p '' bash -c "
"'rm -f /opt/douyinWEB/backend/data/import_rooms.json "
"/opt/douyinWEB/backend/data/_monitor_stash0.db "
"/opt/douyinWEB/backend/data/_monitor_stash1.db; ls /opt/douyinWEB/backend/data'",
timeout=15,
)
print("data dir", o.read().decode("utf-8","replace"))
p.close()