#!/usr/bin/env python3 """Search host03 logs for douyin room at ~07:00 today.""" from __future__ import annotations import paramiko HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805" BASE = "/opt/live/d2ypp" REMOTE = f''' import os, re, glob from datetime import datetime patterns = [ f"{BASE}/logs/*.log", f"{BASE}/.pm2/logs/*.log", "/var/log/syslog", "/tmp/*.log", ] needles = ["live.douyin.com", "source_room", "629587976874", "288944177940", "334176667239", "切换", "Douyin", "web data"] for pat in patterns: for path in glob.glob(pat): try: if os.path.getsize(path) == 0: continue with open(path, "r", errors="replace") as f: hits = [] for line in f: if any(n.lower() in line.lower() for n in needles): hits.append(line.rstrip()) if hits: print("FILE", path, "hits", len(hits)) for line in hits[-30:]: print(line[:300]) except Exception as e: pass # journal for youtube/ffmpeg today morning os.system("journalctl -u 'live*' --since '2026-06-24 05:00' --until '2026-06-24 09:30' 2>/dev/null | grep -iE 'douyin|288944|629587|source|room' | tail -40") os.system("journalctl --since '2026-06-24 05:00' --until '2026-06-24 09:30' 2>/dev/null | grep -iE 'douyin|288944|629587|334176|youtube.py' | tail -40") # process runner / state for p in [f"{BASE}/.process_runner/state.json", f"{BASE}/config/runtime-source.json"]: if os.path.exists(p): print("===", p, "===") print(open(p, errors='replace').read()[:4000]) # current youtube child / source tracking files for root, dirs, files in os.walk(f"{BASE}/config"): for fn in files: if any(x in fn.lower() for x in ("source", "current", "active", "runtime")): fp = os.path.join(root, fn) print("===", fp, "===") print(open(fp, errors='replace').read()[:2000]) ''' 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}\nPY", timeout=120, get_pty=True) print((o.read() + e.read()).decode("utf-8", "replace")[:25000]) c.close() return 0 if __name__ == "__main__": raise SystemExit(main())