58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Check live API relay status + ffmpeg for wisenomad (via running API, not fresh import)."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r'''
|
|
set -e
|
|
echo "=== ffmpeg real ==="
|
|
ps -eo pid,etime,cmd | grep -E '[f]fmpeg' | head -20 || echo NONE
|
|
echo "=== api status snippet ==="
|
|
curl -sS -m 15 http://127.0.0.1:8014/api/youtube/relay/status | python3 -c '
|
|
import sys,json
|
|
d=json.load(sys.stdin)
|
|
print("ok", d.get("ok"), "exclusive", d.get("exclusive_winner_group_id"), "running", d.get("running"))
|
|
for g in d.get("groups") or []:
|
|
if "8" in str(g.get("neko_instance_id")) or "wisenomad" in str(g.get("name") or "").lower() or g.get("group_id")=="23fb62dd-fd66-402b-983a-a4d8d09397af":
|
|
print("---", g.get("name"), g.get("group_id"))
|
|
for k in ("status","is_pushing","error","ffmpeg_pid","push_seconds","neko_instance_id","phase","pause_reason"):
|
|
print(f" {k}={g.get(k)}")
|
|
rl=g.get("recent_log") or []
|
|
if isinstance(rl,str): rl=rl.splitlines()
|
|
print(" log_tail:")
|
|
for x in rl[-20:]:
|
|
print(" |", x)
|
|
'
|
|
|
|
echo "=== studio snap via api if any ==="
|
|
curl -sS -m 10 "http://127.0.0.1:8014/api/youtube/neko/8/studio" 2>/dev/null | head -c 800 || true
|
|
echo
|
|
curl -sS -m 10 "http://127.0.0.1:8014/api/youtube/assign/groups/23fb62dd-fd66-402b-983a-a4d8d09397af" 2>/dev/null | python3 -c '
|
|
import sys,json
|
|
try:
|
|
d=json.load(sys.stdin)
|
|
except Exception as e:
|
|
print("parse",e); sys.exit(0)
|
|
g=d.get("group") or d
|
|
print("group name", g.get("name"), "neko", g.get("neko_instance_id"), "neko_enabled", g.get("neko_enabled"))
|
|
' || true
|
|
|
|
echo "=== journal last 5 min ffmpeg/relay kill ==="
|
|
journalctl -u douyinweb-api --since "5 min ago" --no-pager 2>/dev/null | grep -iE "invalid|NODATA|on_air|kill|stop|ffmpeg|waiting|blocked|wisenomad|1586410|green" | tail -40 || true
|
|
'''
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False)
|
|
_, o, e = c.exec_command(REMOTE, timeout=60)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|