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>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import time
|
|
import httpx
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
print("=== dy.nomadro.com health ===")
|
|
for i in range(5):
|
|
try:
|
|
r = httpx.get("https://dy.nomadro.com/api/health", timeout=25)
|
|
print(r.status_code, r.text[:500])
|
|
break
|
|
except Exception as ex:
|
|
print("try", i, ex)
|
|
time.sleep(3)
|
|
|
|
print("\n=== physical sqlite ===")
|
|
g = paramiko.SSHClient()
|
|
g.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(6):
|
|
try:
|
|
g.connect("107.173.30.245", 4014, "eric", "4669805", timeout=60, banner_timeout=120, allow_agent=False, look_for_keys=False)
|
|
break
|
|
except Exception as ex:
|
|
print("ssh", i, type(ex).__name__)
|
|
time.sleep(2 + i)
|
|
_, o, e = g.exec_command(
|
|
"""echo 4669805 | sudo -S -p '' python3 - <<'PY'
|
|
import sqlite3
|
|
c=sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
|
|
c.row_factory=sqlite3.Row
|
|
print('rooms', c.execute('select count(*) from rooms').fetchone()[0])
|
|
print('enabled', c.execute('select count(*) from rooms where enabled=1').fetchone()[0])
|
|
print('blacklist', c.execute('select count(*) from blacklist').fetchone()[0])
|
|
print('sample:')
|
|
for r in c.execute('select room_id, url, note, enabled, last_status from rooms order by updated_at desc limit 5'):
|
|
print(dict(r))
|
|
PY""",
|
|
timeout=40,
|
|
)
|
|
print((o.read() + e.read()).decode())
|
|
g.close()
|