feat: 新增设备巡检模块实现完整的巡检告警功能
新增设备巡检模块核心功能,包括: - 巡检数据存储与调度系统 - 华为/H3C交换机及Linux服务器采集器 - 设备扩展配置与告警规则管理 - 主机详情页巡检配置入口 - 产品名称自定义设置功能 - 网络设备SSH exec通道兼容处理
This commit is contained in:
@@ -2528,6 +2528,36 @@ function cleanupAllSessions() {
|
||||
terminalOutputChannel?.closeAll?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主机地址查找会话(用于巡检复用连接)
|
||||
*/
|
||||
function findSessionByHost(hostname, port = 22) {
|
||||
const DEBUG = process.env.INSPECTION_DEBUG === "1";
|
||||
if (DEBUG) {
|
||||
console.log("[TerminalBridge] 查找会话,总会话数:", sessions?.size || 0);
|
||||
}
|
||||
if (!sessions) {
|
||||
if (DEBUG) console.log("[TerminalBridge] sessions 未初始化");
|
||||
return null;
|
||||
}
|
||||
for (const session of sessions.values()) {
|
||||
if (!session) continue;
|
||||
// SSH 会话才有 conn
|
||||
if (!session.conn) continue;
|
||||
// 匹配主机地址(hostname 或 host 字段)
|
||||
const sessionHost = session.hostname || session.host || "";
|
||||
if (DEBUG) {
|
||||
console.log("[TerminalBridge] SSH会话:", sessionHost,
|
||||
"| port:", session.port, "| 目标:", hostname);
|
||||
}
|
||||
if (sessionHost === hostname) {
|
||||
if (DEBUG) console.log("[TerminalBridge] 匹配到会话:", sessionHost);
|
||||
return session;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init,
|
||||
registerHandlers,
|
||||
@@ -2558,4 +2588,5 @@ module.exports = {
|
||||
cleanupAllSessions,
|
||||
getDefaultShell,
|
||||
validatePath,
|
||||
findSessionByHost,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user