Files
diary-news/scripts/check_enrich_logs.py
2026-06-11 17:24:46 +08:00

28 lines
1.1 KiB
Python

"""看 enrich 实际行为"""
import os, paramiko
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("207.57.129.228", port=19717, username="root",
password=os.environ["REMOTE_PASS"],
timeout=30, allow_agent=False, look_for_keys=False)
def run(label, cmd, timeout=20):
print(f"\n=== {label} ===")
si, so, se = c.exec_command(cmd, timeout=timeout)
out = so.read().decode(errors="replace")
print(out.rstrip())
# 1) enrich 关键字完整日志
run("1) enrich 关键字全部", "bash -lc 'cd /srv/news && docker compose logs worker 2>&1 | grep -iE \"enrich|llm_settings|llm.enabled\" | head -60'")
# 2) 最近 30 分钟 enrich 关键字
run("2) enrich 最近 30min", "bash -lc 'cd /srv/news && docker compose logs --since 30m worker 2>&1 | grep -iE \"enrich\" | head -40'")
# 3) worker 当前 asyncio tasks
run("3) 当前 asyncio tasks", "bash -lc 'cd /srv/news && docker compose exec -T worker python -c \"\nimport asyncio\nasync def m():\n for t in asyncio.all_tasks():\n if not t.done(): print(t.get_name(), t.done())\nasyncio.run(m())\n\"'")
c.close()