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>
50 lines
2.1 KiB
Python
50 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r'''
|
|
import sqlite3
|
|
p="/opt/douyinWEB/backend/data/monitor.db"
|
|
con=sqlite3.connect(p); con.row_factory=sqlite3.Row
|
|
tabs={r[0] for r in con.execute("SELECT name FROM sqlite_master WHERE type='table'")}
|
|
for t in sorted(tabs):
|
|
if "yt_long" in t or "long" in t:
|
|
print("TABLE", t)
|
|
cols=[r[1] for r in con.execute(f"PRAGMA table_info({t})")]
|
|
print(" cols", cols[:40])
|
|
if "error" in cols or "status" in cols:
|
|
want=[c for c in cols if c in ("id","status","error","title","anchor_name","channel_handle","channel_id","room_id","created_at","upload_at")]
|
|
if want:
|
|
for r in con.execute(f"SELECT {','.join(want)} FROM {t} ORDER BY rowid DESC LIMIT 6"):
|
|
d=dict(r); d["error"]=str(d.get("error") or "")[:220]; print(" ", d)
|
|
# search any table for invalidTitle
|
|
for t in sorted(tabs):
|
|
cols={r[1] for r in con.execute(f"PRAGMA table_info({t})")}
|
|
if "error" not in cols: continue
|
|
try:
|
|
n=con.execute(f"SELECT COUNT(*) c FROM {t} WHERE error LIKE '%invalidTitle%' OR error LIKE '%初始化上传%'").fetchone()["c"]
|
|
if n:
|
|
print("HIT", t, n)
|
|
want=[c for c in ("id","status","error","title","anchor_name","name","channel_handle","created_at") if c in cols]
|
|
for r in con.execute(f"SELECT {','.join(want)} FROM {t} WHERE error LIKE '%invalidTitle%' OR error LIKE '%初始化上传%' ORDER BY rowid DESC LIMIT 5"):
|
|
d=dict(r); d["error"]=str(d.get("error") or "")[:300]; print(" ", d)
|
|
except Exception as e:
|
|
print("skip", t, e)
|
|
con.close()
|
|
'''
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_yt_err.py", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
_, o, e = c.exec_command("echo '4669805' | sudo -S -p '' python3 /tmp/_yt_err.py", timeout=60)
|
|
print((o.read() + e.read()).decode())
|
|
c.close()
|