#!/usr/bin/env python3 # -*- coding: utf-8 -*- """VPS: binds + relay/studio gate state (read-only).""" from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") SCRIPT = r"""#!/bin/bash set +e python3 - <<'PY' import sqlite3, json, time con=sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db') con.row_factory=sqlite3.Row print('=== assign groups ===') cols=[r[1] for r in con.execute('PRAGMA table_info(yt_assign_groups)')] print('cols', [c for c in cols if 'neko' in c.lower() or 'ops' in c.lower()]) rows=con.execute('SELECT * FROM yt_assign_groups ORDER BY neko_instance_id').fetchall() now=time.time() for r in rows: d=dict(r) print(f"#{d.get('neko_instance_id')} en={d.get('neko_enabled')} prefer={d.get('neko_open_prefer')} name={d.get('name')}") print(f" ops_url={d.get('ops_neko_open_url')} slot={d.get('ops_neko_slot')} edge={d.get('ops_neko_edge_label')} bound_at={d.get('ops_neko_bound_at')}") print('=== yt_relay_states (recent) ===') try: rs=con.execute('SELECT * FROM yt_relay_states ORDER BY updated_at DESC LIMIT 8').fetchall() for r in rs: d=dict(r) keep={k:d.get(k) for k in d if k in ('group_id','group_name','phase','reason','pushing','studio_live','updated_at','error','active','mode') or True} # print compact print({k:d[k] for k in d.keys() if k in d and (k in ('group_id','name','status','phase','reason','updated_at','message','pushing','live','error') or 'studio' in k or 'neko' in k or 'relay' in k)}) except Exception as e: print('relay_states_err', e) print([r[0] for r in con.execute("SELECT name FROM sqlite_master WHERE name LIKE '%relay%'")]) print('=== yt_studio_samples latest per key ===') try: info=con.execute('PRAGMA table_info(yt_studio_samples)').fetchall() print('studio_cols', [x[1] for x in info]) rows=con.execute('SELECT * FROM yt_studio_samples ORDER BY received_at DESC LIMIT 10').fetchall() for r in rows: d=dict(r) print({k:d.get(k) for k in list(d.keys())[:20]}) except Exception as e: print('studio_err', e) print('=== ops_neko_edge_catalog ===') try: for r in con.execute('SELECT * FROM ops_neko_edge_catalog').fetchall(): print(dict(r)) except Exception as e: print(e) print('=== ops_neko_instances ===') try: for r in con.execute('SELECT * FROM ops_neko_instances').fetchall(): print(dict(r)) except Exception as e: print(e) PY echo '=== relay status API ===' curl -sS -m 8 http://127.0.0.1:8014/api/youtube/relay/status 2>/dev/null | python3 -m json.tool 2>/dev/null | head -120 echo '=== ops neko hub status ===' curl -sS -m 8 http://127.0.0.1:8014/api/ops-neko/hub 2>/dev/null | head -c 1500; echo curl -sS -m 8 http://127.0.0.1:8014/api/ops-neko/catalog 2>/dev/null | head -c 1500; echo """ def main(): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() with sftp.file("/tmp/_vps_bind_relay_ro.sh", "w") as f: f.write(SCRIPT) sftp.close() _i, o, e = c.exec_command("bash /tmp/_vps_bind_relay_ro.sh", timeout=60) print((o.read() + e.read()).decode("utf-8", "replace")[:20000]) c.close() if __name__ == "__main__": main()