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

40 lines
1.2 KiB
Python

import json
import paramiko
HOST = "107.173.30.245"
USER = "root"
PASSWORD = "Xiao4669805"
DB_PATH = "/opt/douyinWEB/backend/data/monitor.db"
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, USER, PASSWORD, timeout=30, allow_agent=False, look_for_keys=False)
# Use a small inline python on the server to avoid PowerShell quoting issues.
cmd = (
"python3 -c \"import sqlite3, json; "
f"conn=sqlite3.connect('{DB_PATH}'); "
"conn.row_factory=sqlite3.Row; "
"n=conn.execute('select count(*) from blacklist').fetchone()[0]; "
"cols=[r[1] for r in conn.execute('PRAGMA table_info(blacklist)').fetchall()]; "
"rows=conn.execute('select * from blacklist order by created_at desc limit 5').fetchall(); "
"print(json.dumps({'count':n,'cols':cols,'rows':[dict(r) for r in rows]},ensure_ascii=False))\""
)
_stdin, stdout, stderr = c.exec_command(cmd, timeout=60)
out = stdout.read().decode("utf-8", "replace").strip()
err = stderr.read().decode("utf-8", "replace").strip()
if err:
print("ERR:", err)
if out:
print(out)
c.close()
if __name__ == "__main__":
main()