79 lines
3.1 KiB
Python
79 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Why asian streetfood stuck at 启动中 — prefer/gate/telemetry."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
SCRIPT = r"""#!/bin/bash
|
|
set +e
|
|
python3 <<'PY'
|
|
import sqlite3, json, time
|
|
con=sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
|
|
con.row_factory=sqlite3.Row
|
|
now=time.time()
|
|
print('=== groups matching streetfood / instance 7 ===')
|
|
for r in con.execute("select id,name,neko_instance_id,neko_enabled,neko_open_prefer,ops_neko_open_url,ops_neko_slot,ops_neko_edge_label,enabled,category from yt_assign_groups order by neko_instance_id"):
|
|
d=dict(r)
|
|
if 'street' in (d.get('name') or '').lower() or d.get('neko_instance_id') in (1,7) or d.get('ops_neko_slot')==1:
|
|
print(d)
|
|
|
|
print('=== relay states for those groups ===')
|
|
for r in con.execute('select * from yt_relay_states'):
|
|
d=dict(r)
|
|
# print recent
|
|
print({k:d.get(k) for k in ('group_id','status','error','ffmpeg_pid','push_seconds','updated_at','started_at','anchor_name')})
|
|
log=d.get('recent_log')
|
|
if log:
|
|
try:
|
|
lines=json.loads(log) if isinstance(log,str) and log.startswith('[') else str(log).split('\n')
|
|
except Exception:
|
|
lines=[str(log)[:200]]
|
|
for line in (lines[-12:] if isinstance(lines,list) else [lines]):
|
|
print(' LOG', str(line)[:160])
|
|
|
|
print('=== settings exclusive / relay ===')
|
|
for k in ('youtube_relay_enabled','youtube_relay_exclusive_live','youtube_relay_time_slot_mode','host_profile','youtube_relay_on_air_deadline_sec'):
|
|
row=con.execute('select value from kv_settings where key=?',(k,)).fetchone()
|
|
print(k, row['value'] if row else None)
|
|
|
|
print('=== latest studio samples ops:1 ===')
|
|
try:
|
|
rows=con.execute("select ts,neko_ref,neko_kind,live_page_open,on_air,live_status,health,group_id,substr(studio_url,1,70) from yt_studio_samples where neko_ref like '%ops%1%' or neko_ref='ops:1' or neko_ref='ops-1' order by ts desc limit 8").fetchall()
|
|
for r in rows:
|
|
d=dict(r); d['age']=round(now-float(d.get('ts') or 0),1); print(d)
|
|
except Exception as e:
|
|
print('sample_err', e)
|
|
print([x[1] for x in con.execute('pragma table_info(yt_studio_samples)')])
|
|
PY
|
|
|
|
echo '=== local neko-7 ==='
|
|
docker ps -a --format '{{.Names}} {{.Status}}' | grep neko-7 || true
|
|
curl -sS -m 2 -o /dev/null -w '9206=%{http_code}\n' http://127.0.0.1:9206/ || true
|
|
|
|
echo '=== api relay status snippet (no auth may fail) ==='
|
|
# try read journal for gate
|
|
journalctl -u douyinweb-api --since '10 min ago' --no-pager 2>/dev/null | grep -iE 'streetfood|neko wait|ops|NODATA|waiting|gate|3fb8|relay' | tail -40
|
|
"""
|
|
|
|
|
|
def main():
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_why_no_push.sh", "w") as f:
|
|
f.write(SCRIPT)
|
|
sftp.close()
|
|
_i, o, e = c.exec_command("bash /tmp/_why_no_push.sh", timeout=60)
|
|
print((o.read() + e.read()).decode("utf-8", "replace")[:15000])
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|