douyinWEB/scripts/_check_rooms2.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

38 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
import sys, paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
def run(cmd):
_, o, e = c.exec_command(cmd, timeout=60)
return (o.read()+e.read()).decode("utf-8","replace").strip()
print(run(r"""cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
from app import db
import time, json
db.init_db()
from app.db import _connect, _lock
now = time.time()
ids = ['399119394806','910480264065','646335057129','947055309843','553281754960']
with _lock:
conn = _connect()
try:
for rid in ids:
r = conn.execute('SELECT id,room_id,last_status,last_anchor,last_checked_at,next_check_at,enabled,tags,note,created_at FROM rooms WHERE room_id=?', (rid,)).fetchone()
if not r:
print('MISSING', rid)
continue
d = dict(r)
nxt = float(d.get('next_check_at') or 0)
d['overdue'] = bool(d['enabled'] and nxt > 0 and nxt <= now - 60)
print(json.dumps(d, ensure_ascii=False))
cfg = {r['key']: r['value'] for r in conn.execute('SELECT key,value FROM settings').fetchall()}
for k in ['quiet_hours_enabled','quiet_hours_start','quiet_hours_end','max_concurrency']:
print(k, cfg.get(k))
finally:
conn.close()
PY"""))
print("--- monitor ---")
print(run("curl -s http://127.0.0.1:8000/api/monitor/status"))
c.close()