#!/usr/bin/env python3 """Check orphan Neko vs enabled flags; API CPU reason on dy.live.""" from __future__ import annotations import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") def connect(host): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) for i in range(8): try: c.connect(host, 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False, banner_timeout=120) return c except Exception as e: print("retry", e, flush=True) time.sleep(2) raise SystemExit("fail") c = connect("108.174.50.68") _i, o, e = c.exec_command( r""" set +e echo '=== neko container vs DB ===' docker ps -a --filter name=neko --format '{{.Names}} {{.Status}}' cd /opt/douyinWEB/backend ./.venv/bin/python - <<'PY' from app.db import _connect, _lock with _lock: conn=_connect() rows=conn.execute('SELECT name, neko_instance_id, neko_enabled FROM yt_assign_groups WHERE neko_instance_id=10 OR neko_enabled=1').fetchall() for r in rows: print(dict(r)) PY echo echo '=== ffmpeg threads / input ===' ps -eo pid,pcpu,pmem,cmd | grep '[f]fmpeg' | head -5 # how many cores ffmpeg uses PID=$(pgrep -n ffmpeg) if [ -n "$PID" ]; then echo ffmpeg_pid=$PID top -b -n 1 -H -p $PID 2>/dev/null | head -20 fi echo echo '=== who polls API (last 3 min unique peers) ===' journalctl -u douyinweb-api --since '3 min ago' --no-pager 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | sort | uniq -c | sort -rn | head echo req_count=$(journalctl -u douyinweb-api --since '3 min ago' --no-pager 2>/dev/null | grep -c 'HTTP/1.1') echo echo '=== single path exclusive? ===' ./.venv/bin/python - <<'PY' from app import db try: s=db.get_settings() if hasattr(db,'get_settings') else {} except Exception as e: s={} print('settings_err', e) # kv from app.db import _connect, _lock with _lock: conn=_connect() for k in ('relay_single_exclusive','single_path','host_profile','egress_mode','neko_exclusive'): try: r=conn.execute("SELECT key, substr(value,1,80) FROM settings WHERE key LIKE ?", ('%'+k+'%',)).fetchall() for x in r: print('set', x) except Exception: pass try: for r in conn.execute("SELECT key, substr(value,1,100) FROM settings WHERE key LIKE '%exclusive%' OR key LIKE '%host%' OR key LIKE '%neko%' LIMIT 30").fetchall(): print(r) except Exception as e: print(e) PY echo echo '=== cpu now ===' uptime mpstat 1 2 2>/dev/null | tail -5 """, timeout=60, ) print((o.read() + e.read()).decode("utf-8", "replace"), flush=True) c.close() print("ALL_DONE", flush=True)