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

58 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
def ssh(h, p, u, pw):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(h, p, u, pw, timeout=45, allow_agent=False, look_for_keys=False)
return c
def run(c, cmd, t=90):
_, o, e = c.exec_command(cmd, timeout=t)
return (o.read() + e.read()).decode("utf-8", "replace")
g = ssh("107.173.30.245", 4014, "eric", "4669805")
print(
run(
g,
r"""
echo '4669805' | sudo -S -p '' bash -lc '
echo === neko snippet files ===
ls -la /etc/nginx/conf.d/*neko* 2>/dev/null || echo none
ls -la /opt/douyinWEB/backend/data/neko/caddy-neko.snippet 2>/dev/null || true
wc -l /etc/nginx/conf.d/douyinweb-neko-locations.inc 2>/dev/null || true
head -40 /etc/nginx/conf.d/douyinweb-neko-locations.inc 2>/dev/null || true
echo === nginx listen ===
ss -lntp | grep nginx | head
echo === conf.d ===
ls /etc/nginx/conf.d/ 2>/dev/null
grep -R "neko\|include.*neko\|listen" /etc/nginx/conf.d/ 2>/dev/null | head -50
echo === MAX groups ===
python3 - <<PY
import sqlite3
c=sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
print("max_neko", c.execute("select max(neko_instance_id) from yt_assign_groups").fetchone())
print("count", c.execute("select count(*) from yt_assign_groups").fetchone())
for r in c.execute("select name,neko_instance_id,neko_enabled from yt_assign_groups order by neko_instance_id"):
print(r)
PY
'
""",
)
)
g.close()
v = ssh("107.173.30.245", 22, "root", "Xiao4669805")
print("=== caddy ===")
print(run(v, "cat /etc/caddy/sites/dy.nomadro.com.caddy"))
v.close()