bfddfdfdfewe
This commit is contained in:
27
scripts/diag_status_dist.py
Normal file
27
scripts/diag_status_dist.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""弄清 pending_classify=648 的真实含义 - 用单引号"""
|
||||
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)
|
||||
|
||||
cmds = [
|
||||
("1) llm_settings", "SELECT id, enabled, chat_model, image_model, interval_sec, updated_at FROM llm_settings;"),
|
||||
("2) translation_status", "SELECT translation_status, count(*) FROM articles GROUP BY translation_status ORDER BY count(*) DESC;"),
|
||||
("3) classify_status", "SELECT classify_status, count(*) FROM articles GROUP BY classify_status ORDER BY count(*) DESC;"),
|
||||
("4) format_status", "SELECT format_status, count(*) FROM articles GROUP BY format_status ORDER BY count(*) DESC;"),
|
||||
("5) commentary_status", "SELECT commentary_status, count(*) FROM articles GROUP BY commentary_status ORDER BY count(*) DESC;"),
|
||||
("6) image_ai_status", "SELECT image_ai_status, count(*) FROM articles GROUP BY image_ai_status ORDER BY count(*) DESC;"),
|
||||
("7) 已 enrich 比例(translation=ok AND 4 status 全 ok)", "SELECT count(*) AS fully_enriched FROM articles WHERE translation_status='ok' AND classify_status='ok' AND format_status='ok' AND image_ai_status='ok' AND commentary_status='ok';"),
|
||||
("8) 翻译 ok 但 classify 是 n/a", "SELECT count(*) FROM articles WHERE translation_status='ok' AND classify_status='n/a';"),
|
||||
]
|
||||
for label, sql in cmds:
|
||||
# 用 set -a; . .env; set +a 加载 env 变量
|
||||
cmd = f"bash -lc 'cd /srv/news && set -a && . ./.env && set +a && docker compose exec -T postgres psql -U \"$POSTGRES_USER\" -d \"$POSTGRES_DB\" -c \"{sql}\"'"
|
||||
si, so, se = c.exec_command(cmd, timeout=20)
|
||||
out = so.read().decode(errors="replace")
|
||||
print(f"=== {label} ===")
|
||||
print(out.rstrip())
|
||||
print()
|
||||
c.close()
|
||||
Reference in New Issue
Block a user