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

35 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
import paramiko
HOST = "107.173.30.245"
USER = "root"
PASSWORD = "Xiao4669805"
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)
try:
# Use system python + stdlib sqlite3; avoid quoting issues with nested python -c.
cmd = (
"cd /opt/douyinWEB && "
"python3 -c \"import sqlite3; "
"conn=sqlite3.connect('backend/data/monitor.db'); "
"cur=conn.execute('select count(*) from shorts_channels'); "
"print(cur.fetchone()[0]);\""
)
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()
print("count:", out)
if err:
print("[stderr]", err)
finally:
c.close()
if __name__ == "__main__":
main()