feat: mofin_health LLM失败告警推送(规范5.5)

This commit is contained in:
xxm
2026-08-10 18:32:27 +08:00
parent 1b997a6d6f
commit 7478f092f5
+14
View File
@@ -1048,6 +1048,20 @@ def build_report():
# 若LLM故障,功能树根节点标 fail
if not llm_health["ok"]:
feature_tree["status"] = "fail"
# 失败告警(2026-08-10新增):LLM故障推XMPP,不只标红
try:
import sys as _sys
if '/home/hmo/.hermes/profiles/position-analyst/scripts' not in _sys.path:
_sys.path.insert(0, '/home/hmo/.hermes/profiles/position-analyst/scripts')
from alert_helper import notify, WARNING
_first = llm_health["errors_recent"][0] if llm_health["errors_recent"] else {}
notify("LLM端点故障",
f"最近{llm_health['scan_window_min']}分钟{llm_health['error_count']}次调用失败"
f"{_first.get('log','?')} {_first.get('time','?')}: {_first.get('msg','')[:80]})。"
f"gateway进程可能正常但LLM服务不可用,请检查opencode.ai端点。",
WARNING)
except Exception as _ae:
print(f"[LLM_MON] 告警发送失败: {_ae}", file=sys.stderr)
feature_tree.setdefault("warn_detail", {})["llm"] = (
f"LLM端点最近{llm_health['scan_window_min']}分钟{llm_health['error_count']}次错误"
f"{llm_health['errors_recent'][0]['log'] if llm_health['errors_recent'] else '?'}")