#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Confirm ffmpeg still pushing + studio receiving.""" from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def main(): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=25, allow_agent=False, look_for_keys=False) _, o, e = c.exec_command( r""" cd /opt/douyinWEB/backend python3 - <<'PY' import sqlite3, time, os, json con=sqlite3.connect('data/monitor.db') con.row_factory=sqlite3.Row gid='3fb8cbf7-2180-45bc-99f0-836169f0bf97' r=dict(con.execute('select * from yt_relay_states where group_id=?',(gid,)).fetchone() or {}) pid=int(r.get('ffmpeg_pid') or 0) alive=bool(pid and os.path.exists(f'/proc/{pid}')) print('status', r.get('status'), 'error', (r.get('error') or '')[:120], 'pid', pid, 'alive', alive, 'push_sec', r.get('push_seconds'), 'age', round(time.time()-float(r.get('updated_at') or 0),1)) log=str(r.get('recent_log') or '') # show ffmpeg-ish tail lines if log is json array string try: lines=json.loads(log) if log.startswith('[') else log.splitlines() except Exception: lines=str(log).splitlines() for ln in list(lines)[-12:]: print('L', ln[:200] if isinstance(ln,str) else ln) s=con.execute("select ts,on_air,live_status,health,viewer_count from yt_studio_samples where neko_ref='ops:1' order by ts desc limit 1").fetchone() if s: print('ops1', 'age', round(time.time()-float(s['ts']),1), 'on_air', s['on_air'], 'st', s['live_status'], 'health', s['health'], 'viewers', s['viewer_count']) PY # quick ps ps -p 1870796 -o pid,etime,cmd 2>/dev/null | head -3 || echo 'pid gone' """, timeout=40, ) print((o.read() + e.read()).decode("utf-8", "replace")) c.close() if __name__ == "__main__": main()