douyinWEB/scripts/_diag_neko502_yt2.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

61 lines
2.9 KiB
Python

# -*- coding: utf-8 -*-
import json, sys, paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False)
REMOTE = r"""
echo '=== services ==='
systemctl is-active douyinweb-api nginx 2>&1
echo '=== neko containers ==='
docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' | grep -i neko || true
echo '=== nginx neko locations ==='
grep -r 'neko' /etc/nginx/sites-enabled/ /etc/nginx/conf.d/ 2>/dev/null | head -30
echo '=== relay status ==='
curl -sS -c /tmp/dy.ck -X POST https://dy.nomadro.live/api/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"hackrobot","password":"Xiao4669805@"}' >/dev/null
curl -sS -b /tmp/dy.ck 'https://dy.nomadro.live/api/youtube/relay/status' -o /tmp/r.json
curl -sS -b /tmp/dy.ck 'https://dy.nomadro.live/api/youtube/live-map?force=1' -o /tmp/yt.json
python3 <<'PY'
import json
from pathlib import Path
r = json.loads(Path('/tmp/r.json').read_text())
yt = json.loads(Path('/tmp/yt.json').read_text())
print('exclusive', r.get('settings',{}).get('youtube_relay_exclusive_live'))
print('pushing_count', r.get('pushing_count'))
print('live_count map', yt.get('live_count'))
for k,v in sorted((yt.get('entries') or {}).items()):
if v.get('is_live'):
print(' LIVE', k, 'src', v.get('source'), 'title', (v.get('title') or '')[:40])
print('--- groups ---')
for g in r.get('groups', []):
st = g.get('business_status') or g.get('status')
if g.get('is_pushing') or st in ('streaming','relay_starting','relay_slow','waiting') or 'Evan' in str(g.get('name','')) or '大师兄' in str(g.get('name','')) or 'nomad' in str(g.get('name','')).lower():
print(g.get('name'), 'push', g.get('is_pushing'), 'biz', st, 'neko', g.get('neko_instance_id'), 'pid', g.get('ffmpeg_pid'))
print(' src', g.get('source_room_id'), g.get('source_display'))
print(' err', (g.get('error') or g.get('business_note') or '')[:80])
log = g.get('recent_log') or ''
if isinstance(log, list): log = '\n'.join(log[-8:])
else: log = str(log)[-600:]
for line in str(log).splitlines()[-5:]:
print(' ', line[:120])
PY
echo '=== curl neko 6/7 local ==='
for p in 8086 8087 8080; do curl -sS -o /dev/null -w "port$p:%{http_code} " --max-time 3 http://127.0.0.1:$p/ 2>/dev/null || echo "port$p:fail "; done
echo
for n in douyinweb-neko-6 douyinweb-neko-7; do
echo "--- $n ---"
docker inspect -f '{{.State.Status}} health={{if .State.Health}}{{.State.Health.Status}}{{end}}' $n 2>/dev/null || echo missing
docker port $n 2>/dev/null || true
done
echo '=== ffmpeg for nomad/evan ==='
ps aux | grep -E 'ffmpeg.*rtmp|ffmpeg.*youtube' | grep -v grep | head -5
"""
_, o, e = c.exec_command(REMOTE, timeout=180)
print(o.read().decode())
err = e.read().decode()
if err.strip():
print("ERR:", err)
c.close()