41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Diagnose physical API hang: Recv-Q, threads, recent journal, ingest rate."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False)
|
|
pw = "4669805"
|
|
|
|
|
|
def sh(cmd, t=90):
|
|
_, o, e = c.exec_command(f"echo '{pw}' | sudo -S -p '' bash -lc {repr(cmd)}", timeout=t)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
print("=== stop watch first ===")
|
|
print(sh("systemctl stop douyinweb-api-watch; systemctl is-active douyinweb-api-watch || true"))
|
|
|
|
print("=== queue / children ===")
|
|
print(sh("ss -ltnp | grep 8014; ps --ppid $(systemctl show douyinweb-api -p MainPID --value) -o pid,etime,stat,cmd | head -40; pstree -p $(systemctl show douyinweb-api -p MainPID --value) | head -c 4000"))
|
|
|
|
print("=== thread dump-ish ===")
|
|
print(sh("pid=$(systemctl show douyinweb-api -p MainPID --value); ls /proc/$pid/task | wc -l; cat /proc/$pid/status | egrep 'State|Threads|VmRSS'"))
|
|
|
|
print("=== journal last 2 min access ===")
|
|
print(sh("journalctl -u douyinweb-api --since '3 min ago' --no-pager | tail -60"))
|
|
|
|
print("=== ingest count last min from journal ===")
|
|
print(sh("journalctl -u douyinweb-api --since '5 min ago' --no-pager | grep -c ingest || true; journalctl -u douyinweb-api --since '5 min ago' --no-pager | grep -E 'ingest|ERROR|Traceback|shellcrash|timeout' | tail -40"))
|
|
|
|
print("=== deployed debounce marker ===")
|
|
print(sh("grep -n 'telemetry.*debounce\\|studio_telemetry\\|write_debounce\\|_TELEMETRY' /opt/douyinWEB/backend/app/youtube_neko.py | head -20; grep -n 'default.*health\\|wait_for' /opt/douyinWEB/backend/app/main.py | head -20"))
|
|
|
|
c.close()
|