Show strategy stats in control monitor detail modal.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-02 09:49:27 +08:00
parent 0e3b9e53ac
commit 079dc83132
5 changed files with 211 additions and 7 deletions
+20
View File
@@ -278,6 +278,26 @@ async def node_status(
return await _collect_one_status(node)
@router.get("/{node_id}/stats")
async def node_stats(
node_id: int,
_user: Annotated[str, Depends(require_control_user)],
) -> dict:
"""代理策略机整体统计(点击详情时按需拉取,不进 SSE)。"""
db = get_control_db()
node = db.get_node(node_id)
if not node:
raise HTTPException(status_code=404, detail="节点不存在")
if not node.get("token_sealed"):
raise HTTPException(status_code=400, detail="未生成 Token")
code, data = await call_node(node, "GET", "/api/fleet/stats", timeout=15.0)
if code >= 400:
_raise_node_error(code, data)
if not isinstance(data, dict):
raise HTTPException(status_code=502, detail="策略机统计返回异常")
return data
@router.post("/{node_id}/start")
async def node_start(
node_id: int,