52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
SCRIPT = r"""#!/bin/bash
|
|
python3 - <<'PY'
|
|
import sqlite3, time
|
|
con=sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
|
|
con.row_factory=sqlite3.Row
|
|
now=time.time()
|
|
print('now', now)
|
|
rows=con.execute('SELECT * FROM yt_studio_samples ORDER BY ts DESC LIMIT 12').fetchall()
|
|
for r in rows:
|
|
d=dict(r)
|
|
age=now-float(d.get('ts') or 0)
|
|
print(f"age={age:.0f}s kind={d.get('neko_kind')} ref={d.get('neko_ref')} on_air={d.get('on_air')} page={d.get('live_page_open')} status={d.get('live_status')} health={d.get('health')} group={str(d.get('group_id') or '')[:8]} url={(d.get('studio_url') or '')[:70]}")
|
|
|
|
print('=== relay state group7 detail ===')
|
|
r=con.execute("SELECT * FROM yt_relay_states WHERE group_id='3fb8cbf7-2180-45bc-99f0-836169f0bf97'").fetchone()
|
|
if r:
|
|
d=dict(r)
|
|
for k in sorted(d.keys()):
|
|
v=d[k]
|
|
if isinstance(v,str) and len(v)>200: v=v[:200]+'...'
|
|
print(f" {k}={v}")
|
|
PY
|
|
"""
|
|
|
|
|
|
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/_studio_samples_ro.sh", "w") as f:
|
|
f.write(SCRIPT)
|
|
sftp.close()
|
|
_i, o, e = c.exec_command("bash /tmp/_studio_samples_ro.sh", timeout=30)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|