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>
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys, paramiko, time
|
|
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 -c "
|
|
from app import db
|
|
import time
|
|
db.init_db()
|
|
from app.db import _connect, _lock
|
|
now = time.time()
|
|
print('server now:', now)
|
|
with _lock:
|
|
conn = _connect()
|
|
try:
|
|
rows = conn.execute('SELECT id,room_id,url,last_status,last_anchor,last_checked_at,next_check_at,enabled,last_error,tags,note FROM rooms ORDER BY next_check_at ASC LIMIT 20').fetchall()
|
|
for r in rows:
|
|
d = dict(r)
|
|
nxt = float(d.get('next_check_at') or 0)
|
|
overdue = d['enabled'] and nxt > 0 and nxt <= now - 60
|
|
d['overdue'] = overdue
|
|
d['lag_sec'] = int(now - nxt) if nxt > 0 and nxt <= now else 0
|
|
print(d)
|
|
print('--- counts ---')
|
|
total = conn.execute('SELECT COUNT(*) c FROM rooms').fetchone()['c']
|
|
unknown = conn.execute(\"SELECT COUNT(*) c FROM rooms WHERE last_status='unknown'\").fetchone()['c']
|
|
overdue = conn.execute('SELECT COUNT(*) c FROM rooms WHERE enabled=1 AND next_check_at>0 AND next_check_at<=?', (now-60,)).fetchone()['c']
|
|
print('total', total, 'unknown', unknown, 'overdue', overdue)
|
|
finally:
|
|
conn.close()
|
|
" """))
|
|
print(run("systemctl is-active douyinweb-api"))
|
|
c.close()
|