32 lines
773 B
Bash
Executable File
32 lines
773 B
Bash
Executable File
#!/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
|