feature/alerts-and-map #2

Closed
v6ole wants to merge 8 commits from feature/alerts-and-map into main
2 changed files with 16 additions and 6 deletions
Showing only changes of commit 0d3fa8dd51 - Show all commits
+6
View File
@@ -112,3 +112,9 @@ def health_check():
status["db"] = "error"
status["status"] = "degraded"
return status
@app.get("/api/health")
def api_health_check():
"""API 路径下的健康检查(用于前端通过 /api/ 代理访问)"""
return health_check()
+10 -6
View File
@@ -103,8 +103,10 @@ class CheckService:
"online": online_count,
"offline": offline_count,
}
finally:
ssh.close()
except Exception:
# 连接异常时清除缓存,下次自动重连
_conn_pool.pop(olt_id, None)
raise
def check_single_device(self, device_id: int) -> Dict:
"""通过 SSH 单独查询一台 ONU 设备的当前状态和距离。
@@ -251,8 +253,9 @@ class CheckService:
"offline": offline_count,
"new_discovered": new_count,
}
finally:
ssh.close()
except Exception:
_conn_pool.pop(olt_id, None)
raise
async def scan_olt(self, olt_id: int) -> Dict:
"""仅扫描 OLT,返回发现的设备列表(不写入数据库)"""
@@ -300,8 +303,9 @@ class CheckService:
"devices": devices,
"duplicates": duplicates,
}
finally:
ssh.close()
except Exception:
_conn_pool.pop(olt_id, None)
raise
def _save_duplicate_macs(self, olt_id: int, duplicate_dict: dict):
for mac, records in duplicate_dict.items():