# -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") PASS = "Xiao4669805" def probe(host: str, label: str) -> None: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(host, 22, "root", PASS, timeout=40, allow_agent=False, look_for_keys=False) cmd = r""" cd /opt/douyinWEB/backend && PYTHONPATH=/opt/douyinWEB/backend .venv/bin/python - <<'PY' import subprocess from app import youtube_relay_db, yt_assign_db, db from app.youtube_neko import _cdp_studio_page_signals from app.youtube_relay_pipeline import youtube_relay_pipeline as rp, _claim_first_live_normal, _normal_auto_candidates cfg = db.get_settings_map() print('relay', cfg.get('youtube_relay_enabled'), 'exclusive', cfg.get('youtube_relay_exclusive_live'), 'slot', cfg.get('youtube_relay_time_slot_mode')) print('winner', getattr(rp, '_exclusive_winner', None), 'probe_off', sorted(getattr(rp, '_probe_offline_until', {}) or {})[:8]) groups = yt_assign_db.list_groups(include_urls=True) normals = [g for g in groups if (g.get('category') or 'normal') != 'time_slot'] for g in normals: st = youtube_relay_db.get_relay_state(g['id']) or {} print('N', g.get('name'), st.get('status'), 'src', st.get('source_room_id') or '-', 'pid', st.get('ffmpeg_pid') or 0, str(st.get('error') or '')[:50]) claimed = _claim_first_live_normal(_normal_auto_candidates(groups)) print('claim', (claimed[1].get('name') if claimed else None), (claimed[2] if claimed else None)) print('ffmpeg_n', subprocess.getoutput("ps -ef | grep ffmpeg | grep -v grep | wc -l").strip()) # studio for any pushing normal for g in normals: st = youtube_relay_db.get_relay_state(g['id']) or {} if str(st.get('status') or '') not in {'pushing', 'starting'}: continue nid = int(g.get('neko_instance_id') or 0) if not nid: continue try: sig = _cdp_studio_page_signals(nid, force=True) print('studio', g.get('name'), 'neko', nid, sig.get('live_status'), 'on_air', sig.get('on_air'), 'recv', sig.get('encoder_receiving')) except Exception as e: print('studio_err', e) PY """ _, o, e = c.exec_command(cmd, timeout=70) print(f"===== {label} {host} =====") print((o.read() + e.read()).decode("utf-8", "replace")) c.close() if __name__ == "__main__": probe("107.173.30.245", "dylive") try: probe("108.174.50.68", "dy") except Exception as e: print("dy_direct_fail", e) # jump c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", PASS, timeout=40, allow_agent=False, look_for_keys=False) _, o, e = c.exec_command( "sshpass -e ssh -o StrictHostKeyChecking=no root@108.174.50.68 'curl -sS -m 5 http://127.0.0.1:8014/api/health | head -c 200'", timeout=40, environment={"SSHPASS": PASS}, ) # paramiko may not pass env that way; use inline _, o, e = c.exec_command( "SSHPASS='Xiao4669805' sshpass -e ssh -o StrictHostKeyChecking=no root@108.174.50.68 \"curl -sS -m 5 -o /dev/null -w '%{http_code}' http://127.0.0.1:8014/api/health\"", timeout=40, ) print("dy_via_jump_health", (o.read() + e.read()).decode("utf-8", "replace")) c.close()