sh2/d2ypp2/tools/query_host03_root_log_grep.py
eric 278b48497e Add YouTube relay log tooling and optional hub service controls.
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>
2026-07-30 05:10:09 -05:00

45 lines
2.0 KiB
Python

#!/usr/bin/env python3
import paramiko
HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805"
def main():
c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, username=USER, password=PASS, timeout=15)
remote = r'''
LOG=/root/.pm2/logs/youtube-out.log
echo "=== 07:xx recording lines ==="
grep "正在录制 1 路" "$LOG" | grep "2026-06-24T07:" | tail -30
echo "=== 2:0x duration lines today ==="
grep "正在录制 1 路" "$LOG" | grep "2026-06-24" | grep -E "原画 2:0[0-9]:|原画 2:1[0-9]:" | tail -40
echo "=== around 2:05 exactly ==="
grep "正在录制 1 路" "$LOG" | grep -E "原画 2:05:|原画 2:04:|原画 2:06:" | tail -30
echo "=== first 2:05 today ==="
grep "正在录制 1 路" "$LOG" | grep "2026-06-24" | grep "原画 2:05:" | head -5
echo "=== last before 07:15 with 2h+ ==="
grep "正在录制 1 路" "$LOG" | grep "2026-06-24T07:1" | tail -10
'''
_, o, e = c.exec_command(
f"echo {PASS} | sudo -S python3 - <<'PY'\n"
"import subprocess\n"
"LOG='/root/.pm2/logs/youtube-out.log'\n"
"def rg(pat, tail=30):\n"
" out=subprocess.check_output(f\"grep -F '{pat}' {LOG} | tail -{tail}\", shell=True, text=True, errors='replace')\n"
" print(out)\n"
"print('=== 07:xx recording ===')\n"
"rg('2026-06-24T07:')\n"
"print('=== 2:05 duration ===')\n"
"out=subprocess.check_output(\"grep '正在录制 1 路' /root/.pm2/logs/youtube-out.log | grep '原画 2:05:' | tail -20\", shell=True, text=True, errors='replace')\n"
"print(out)\n"
"print('=== 2:04-2:06 today ===')\n"
"out=subprocess.check_output(\"grep '正在录制 1 路' /root/.pm2/logs/youtube-out.log | grep '2026-06-24' | grep -E '原画 2:0[4-6]:' | tail -30\", shell=True, text=True, errors='replace')\n"
"print(out)\n"
"PY",
timeout=180,
get_pty=True,
)
import sys; sys.stdout.buffer.write((o.read()+e.read())[:40000])
c.close()
if __name__=='__main__': main()