93 lines
3.9 KiB
Python
93 lines
3.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Continue: was Studio really stuck, or ops_cdp_ensure fake waiting?"""
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r'''
|
|
import sqlite3, datetime, json
|
|
from collections import Counter
|
|
BJ=datetime.timezone(datetime.timedelta(hours=8))
|
|
con=sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
|
|
con.row_factory=sqlite3.Row
|
|
gid='45f9bd79-2039-4985-8176-5e41b014281b'
|
|
# samples during flap window 04:48-05:30 BJ 09-10
|
|
print('=== detect_source during flap ===')
|
|
rows=[]
|
|
for s in con.execute('SELECT * FROM yt_studio_samples WHERE group_id=? ORDER BY ts DESC LIMIT 500',(gid,)):
|
|
d=dict(s)
|
|
try:
|
|
bj=datetime.datetime.fromtimestamp(float(d['ts']),BJ)
|
|
except Exception:
|
|
continue
|
|
if bj.month==9 and bj.day==10 and ((bj.hour==4 and bj.minute>=40) or (bj.hour==5 and bj.minute<=40)):
|
|
rows.append(d)
|
|
print('n', len(rows))
|
|
print('sources', dict(Counter(str(r.get('detect_source') or '') for r in rows)))
|
|
print('on_air', dict(Counter(int(r.get('on_air') or 0) for r in rows)))
|
|
print('live_status', dict(Counter(str(r.get('live_status') or '') for r in rows)))
|
|
print('--- sample lines ---')
|
|
for d in sorted(rows, key=lambda x: float(x['ts']))[:15]:
|
|
bj=datetime.datetime.fromtimestamp(float(d['ts']),BJ).strftime('%H:%M:%S')
|
|
print(bj, 'src', d.get('detect_source'), 'on_air', d.get('on_air'), 'st', d.get('live_status'), 'ref', d.get('neko_ref'), 'meta', str(d.get('meta_json') or '')[:80])
|
|
print('--- last 10 in window ---')
|
|
for d in sorted(rows, key=lambda x: float(x['ts']))[-10:]:
|
|
bj=datetime.datetime.fromtimestamp(float(d['ts']),BJ).strftime('%H:%M:%S')
|
|
print(bj, 'src', d.get('detect_source'), 'on_air', d.get('on_air'), 'st', d.get('live_status'), 'ref', d.get('neko_ref'))
|
|
|
|
# Sept 9 morning success window samples
|
|
print('=== 09-09 04:50-06:00 samples ===')
|
|
rows2=[]
|
|
for s in con.execute('SELECT * FROM yt_studio_samples WHERE group_id=? ORDER BY ts DESC LIMIT 2000',(gid,)):
|
|
d=dict(s)
|
|
try:
|
|
bj=datetime.datetime.fromtimestamp(float(d['ts']),BJ)
|
|
except Exception:
|
|
continue
|
|
if bj.month==9 and bj.day==9 and bj.hour in (4,5,6,7,8,9):
|
|
rows2.append(d)
|
|
print('n', len(rows2))
|
|
print('sources', dict(Counter(str(r.get('detect_source') or '') for r in rows2)))
|
|
print('on_air', dict(Counter(int(r.get('on_air') or 0) for r in rows2)))
|
|
print('live_status', dict(Counter(str(r.get('live_status') or '') for r in rows2)))
|
|
|
|
# any meta mentioning daily/limit/stream
|
|
print('=== meta with limit/daily ===')
|
|
n=0
|
|
for s in con.execute('SELECT ts,detect_source,on_air,live_status,meta_json FROM yt_studio_samples WHERE group_id=? ORDER BY ts DESC LIMIT 3000',(gid,)):
|
|
meta=str(s['meta_json'] or '').lower()
|
|
if 'limit' in meta or 'daily' in meta or 'quota' in meta:
|
|
bj=datetime.datetime.fromtimestamp(float(s['ts']),BJ).strftime('%m-%d %H:%M:%S')
|
|
print(bj, s['detect_source'], s['on_air'], s['live_status'], meta[:200])
|
|
n+=1
|
|
if n>=20: break
|
|
print('limit_hits', n)
|
|
|
|
# FFmpeg: did sessions actually get frames? check metadata
|
|
print('=== session meta keys during flap ===')
|
|
for r in con.execute('SELECT started_at,ended_at,duration_seconds,metadata_json FROM yt_relay_sessions WHERE group_id=? ORDER BY started_at DESC LIMIT 5',(gid,)):
|
|
try:
|
|
bj=datetime.datetime.fromtimestamp(float(r['started_at']),BJ).strftime('%H:%M:%S')
|
|
except Exception:
|
|
bj='?'
|
|
meta=r['metadata_json'] or '{}'
|
|
try:
|
|
m=json.loads(meta)
|
|
except Exception:
|
|
m={}
|
|
print(bj, 'dur', round(float(r['duration_seconds'] or 0),1), 'keys', list(m.keys())[:12], 'err', str(m.get('error') or m.get('last_error') or '')[:100])
|
|
con.close()
|
|
'''
|
|
|
|
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)
|
|
_, o, e = c.exec_command("python3 - <<'PY'\n" + REMOTE + "\nPY", timeout=90)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err:
|
|
print("STDERR", err[:1500])
|
|
c.close()
|