74 lines
3.5 KiB
JSON
74 lines
3.5 KiB
JSON
{
|
||
"module": "health",
|
||
"version": "1.0",
|
||
"purpose": "MoFin 系统健康监控管线。三层监控(Tier1 快速检查 + Tier2 日检),聚合到 Dashboard F Tab 展示。",
|
||
|
||
"human_help": {
|
||
"title": "F 健康 — 系统健康",
|
||
"description": [
|
||
"实时监控 MoFin 所有关键服务(Flask API、数据库、cron 任务)的运行状态。",
|
||
"两层监控:",
|
||
" Tier1 — 每 5 分钟快速端口/进程检查",
|
||
" Tier2 — 每日 8:00 开盘前全面体检(进程+端口+DB+磁盘+cron)",
|
||
"检查结果聚合到 Dashboard F Tab,异常自动告警。"
|
||
],
|
||
"usage": [
|
||
"1. 打开 Dashboard → F 健康 Tab 查看概览",
|
||
"2. 绿色 = 正常,黄色 = 部分异常,红色 = 严重异常",
|
||
"3. 异常服务列表直接显示影响描述",
|
||
"4. 定时任务区域检查所有 cron 是否正常运行"
|
||
],
|
||
"troubleshooting": [
|
||
"F Tab 显示无数据 → 检查 crontab 中健康检查是否部署",
|
||
"服务显示 down 但实际在运行 → 检查端口或 health 端点是否正确",
|
||
"TODO 堆积 → 检查 self_todo_executor 是否在 crontab 中"
|
||
]
|
||
},
|
||
|
||
"ai_spec": {
|
||
"apis": [
|
||
{"method": "GET", "path": "/api/services", "returns": "{services[{name, type, port, health{ok}, status}]}"},
|
||
{"method": "GET", "path": "/api/expected", "returns": "{expected[{name, port, expected, critical}], actual{name:status}}"},
|
||
{"method": "GET", "path": "/api/monitor", "returns": "{tier1{summary{ok,total}}, tier2{summary{ok,total}}, tasks[{name,status}]}"}
|
||
],
|
||
"dependencies": [
|
||
"agents_health_check.py — Tier1(每 5 分钟,socket 端口 + HTTP /health)",
|
||
"agents_daily_health.py — Tier2(每日 8:00,端口+进程+DB+磁盘+cron)",
|
||
"mofin.db — SQLite 数据库(检查可读写)"
|
||
],
|
||
"architecture": {
|
||
"monitored_services": [
|
||
{"name": "mofin_api", "port": 8899, "type": "http", "check": "GET /api/portfolio"},
|
||
{"name": "mofin_dashboard", "port": 5804, "type": "http", "check": "GET /api/health"},
|
||
{"name": "zhiwei_gateway", "port": 8643, "type": "http", "check": "GET /v1/health"},
|
||
{"name": "ejabberd", "port": 5222, "type": "tcp", "check": "socket connect"},
|
||
{"name": "mofin_db", "port": 0, "type": "file", "check": "sqlite3 connect + SELECT"}
|
||
]
|
||
},
|
||
"constraints": [
|
||
"Tier1 全正常时静默(不输出日志)",
|
||
"Tier1 异常写入 gateway/temp/health_todos.jsonl",
|
||
"Tier1 报告写入 gateway/temp/last_health_check.json",
|
||
"Tier2 报告写入 gateway/temp/last_daily_health.json",
|
||
"Dashboard /api/monitor 聚合读取以上 JSON 文件"
|
||
],
|
||
"must_not": [
|
||
"不要在健康检查中修改业务数据",
|
||
"不要硬编码 Windows 路径或命令",
|
||
"不要检查已停用的服务(wechat_agent 等)"
|
||
],
|
||
"tests": [
|
||
{"id": "H01", "name": "/api/services 返回服务列表", "endpoint": "GET /api/services"},
|
||
{"id": "H02", "name": "/api/expected 返回期望矩阵", "endpoint": "GET /api/expected"},
|
||
{"id": "H03", "name": "/api/monitor 返回监控数据", "endpoint": "GET /api/monitor"}
|
||
],
|
||
"related_files": [
|
||
"agents_health_check.py — Tier1 健康检查",
|
||
"agents_daily_health.py — Tier2 日检",
|
||
"dashboard.py — /api/services, /api/expected, /api/monitor",
|
||
"templates/dashboard.html — F Tab 渲染",
|
||
"specs/health.json — 本 spec 文件"
|
||
]
|
||
}
|
||
}
|