feat: CMA P1+P2 Round1 — 成本法对比+杜邦分析+本量利
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,31 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# CMA预警检查 — 通过wrapper脚本避免systemd引号冲突
|
||||
# CMA预警检查 — 通过API端点执行
|
||||
set -euo pipefail
|
||||
|
||||
cd /root/cma-management/backend
|
||||
|
||||
VENV="/root/cma-management/backend/venv"
|
||||
# 通过HTTP API执行预警检查
|
||||
RESULT=$(curl -s -X POST http://localhost:8010/api/cma/admin/alerts/check \
|
||||
-H "Content-Type: application/json" 2>&1)
|
||||
|
||||
# 1. KPI阈值检查
|
||||
"$VENV/bin/python3" -c "
|
||||
from app.database import get_db_session
|
||||
from app.api.alert_rules import check_all_kpi_alerts
|
||||
db = next(get_db_session())
|
||||
try:
|
||||
count = check_all_kpi_alerts(db)
|
||||
print(f'KPI预警检查完成: 新增{count}条')
|
||||
finally:
|
||||
db.close()
|
||||
" 2>&1
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 预警检查结果: $RESULT"
|
||||
|
||||
# 2. 差异预警推送检查
|
||||
"$VENV/bin/python3" -c "
|
||||
from app.database import get_db_session
|
||||
from app.api.deviation_push import check_all_push
|
||||
db = next(get_db_session())
|
||||
try:
|
||||
count = check_all_push(db)
|
||||
print(f'差异预警检查完成: 新增{count}条')
|
||||
finally:
|
||||
db.close()
|
||||
" 2>&1
|
||||
# 验证是否成功
|
||||
if echo "$RESULT" | grep -q '"new_alerts"'; then
|
||||
NEW_ALERTS=$(echo "$RESULT" | python3 -c "import json,sys; print(json.load(sys.stdin).get('result',{}).get('new_alerts','unknown'))" 2>/dev/null || echo "parse_error")
|
||||
echo "新增预警数: $NEW_ALERTS"
|
||||
exit 0
|
||||
else
|
||||
echo "预警检查失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# CMA预警检查 — 通过wrapper脚本避免systemd引号冲突
|
||||
set -euo pipefail
|
||||
|
||||
cd /root/cma-management/backend
|
||||
|
||||
VENV="/root/cma-management/backend/venv"
|
||||
|
||||
# 1. KPI阈值检查
|
||||
"$VENV/bin/python3" -c "
|
||||
from app.database import get_db_session
|
||||
from app.api.alert_rules import check_all_kpi_alerts
|
||||
db = next(get_db_session())
|
||||
try:
|
||||
count = check_all_kpi_alerts(db)
|
||||
print(f'KPI预警检查完成: 新增{count}条')
|
||||
finally:
|
||||
db.close()
|
||||
" 2>&1
|
||||
|
||||
# 2. 差异预警推送检查
|
||||
"$VENV/bin/python3" -c "
|
||||
from app.database import get_db_session
|
||||
from app.api.deviation_push import check_all_push
|
||||
db = next(get_db_session())
|
||||
try:
|
||||
count = check_all_push(db)
|
||||
print(f'差异预警检查完成: 新增{count}条')
|
||||
finally:
|
||||
db.close()
|
||||
" 2>&1
|
||||
Reference in New Issue
Block a user