This captures the current live stack updates across the API, Linux service scripts, tests, diagnostics, and exported console assets so the Ubuntu deployment can pull a consistent test3 build. Co-authored-by: Cursor <cursoragent@cursor.com>
110 lines
3.8 KiB
Python
110 lines
3.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Detailed lane1 event samples around 12h ago on 10.88.0.3."""
|
|
from __future__ import annotations
|
|
|
|
import paramiko
|
|
|
|
HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805"
|
|
|
|
REMOTE_PY = r'''
|
|
import sqlite3, json, time
|
|
from datetime import datetime
|
|
|
|
p = "/opt/live/d2ypp/config/hub_state.sqlite"
|
|
conn = sqlite3.connect(p)
|
|
conn.row_factory = sqlite3.Row
|
|
now = time.time()
|
|
target = now - 12*3600
|
|
print("target_12h", datetime.fromtimestamp(target).isoformat())
|
|
|
|
# lane1 events on Jun 24
|
|
rows = conn.execute(
|
|
"""SELECT * FROM youtube_live_events
|
|
WHERE process='youtube' AND started_at > ?
|
|
ORDER BY started_at DESC""",
|
|
(now - 24*3600,),
|
|
).fetchall()
|
|
print("\n=== lane1 events last 24h ===")
|
|
for r in rows:
|
|
d = dict(r)
|
|
for k in ("started_at","ended_at","last_seen_at"):
|
|
if d.get(k):
|
|
d[k] = datetime.fromtimestamp(float(d[k])).isoformat()
|
|
d["dur_min"] = round(float(dict(r).get("duration_seconds") or 0)/60, 1)
|
|
print(json.dumps({k:d[k] for k in ["id","source_room_id","source_url","status","started_at","ended_at","dur_min"]}, ensure_ascii=False))
|
|
|
|
# samples for event 67
|
|
print("\n=== samples event 67 (distinct sources) ===")
|
|
samples = conn.execute(
|
|
"""SELECT ts, page_url, page_title, payload_json
|
|
FROM youtube_live_samples WHERE event_id=67 ORDER BY ts"""
|
|
).fetchall()
|
|
seen = set()
|
|
for s in samples:
|
|
d = dict(s)
|
|
ts = datetime.fromtimestamp(float(d["ts"])).isoformat()
|
|
url = d.get("page_url") or ""
|
|
title = d.get("page_title") or ""
|
|
payload = d.get("payload_json") or ""
|
|
key = url[:80] + title[:40]
|
|
if key in seen:
|
|
continue
|
|
seen.add(key)
|
|
if "douyin" in url.lower() or "douyin" in payload.lower() or "room" in payload.lower():
|
|
print(ts, url[:120], title[:60], payload[:200])
|
|
|
|
print("sample_count", len(samples), "distinct", len(seen))
|
|
|
|
# all events with duration 7200-7800 (2h-2h10m)
|
|
print("\n=== duration 7200-7800s all time ===")
|
|
rows2 = conn.execute(
|
|
"""SELECT id, process, source_room_id, source_url, duration_seconds, started_at, ended_at
|
|
FROM youtube_live_events
|
|
WHERE duration_seconds BETWEEN 7200 AND 7800
|
|
ORDER BY started_at DESC LIMIT 20"""
|
|
).fetchall()
|
|
for r in rows2:
|
|
d = dict(r)
|
|
d["started_at"] = datetime.fromtimestamp(float(d["started_at"])).isoformat()
|
|
if d.get("ended_at"):
|
|
d["ended_at"] = datetime.fromtimestamp(float(d["ended_at"])).isoformat()
|
|
d["dur_hm"] = f"{int(d['duration_seconds']//3600)}h{int((d['duration_seconds']%3600)//60)}m"
|
|
print(json.dumps(d, ensure_ascii=False))
|
|
|
|
# events for lane1 where ended_at near 12h ago +/- 2h
|
|
print("\n=== lane1 ended near 12h ago ===")
|
|
rows3 = conn.execute(
|
|
"""SELECT id, source_room_id, source_url, duration_seconds, started_at, ended_at
|
|
FROM youtube_live_events
|
|
WHERE process='youtube' AND ended_at BETWEEN ? AND ?
|
|
ORDER BY ended_at DESC""",
|
|
(target - 2*3600, target + 2*3600),
|
|
).fetchall()
|
|
for r in rows3:
|
|
d = dict(r)
|
|
d["started_at"] = datetime.fromtimestamp(float(d["started_at"])).isoformat()
|
|
d["ended_at"] = datetime.fromtimestamp(float(d["ended_at"])).isoformat()
|
|
d["dur_min"] = round(float(d["duration_seconds"])/60, 1)
|
|
print(json.dumps(d, ensure_ascii=False))
|
|
|
|
# snapshot_json from event 67
|
|
r67 = conn.execute("SELECT snapshot_json FROM youtube_live_events WHERE id=67").fetchone()
|
|
if r67 and r67[0]:
|
|
print("\n=== event 67 snapshot ===")
|
|
print(r67[0][:3000])
|
|
|
|
conn.close()
|
|
'''
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASS, timeout=15)
|
|
_, o, e = c.exec_command(f"python3 - <<'PY'\n{REMOTE_PY}\nPY", timeout=90, get_pty=True)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|