feat: 新增设备巡检模块实现完整的巡检告警功能

新增设备巡检模块核心功能,包括:
- 巡检数据存储与调度系统
- 华为/H3C交换机及Linux服务器采集器
- 设备扩展配置与告警规则管理
- 主机详情页巡检配置入口
- 产品名称自定义设置功能
- 网络设备SSH exec通道兼容处理
This commit is contained in:
2026-10-09 10:37:48 +08:00
parent 9202506c46
commit c64e00d835
75 changed files with 12087 additions and 446 deletions

View File

@@ -156,6 +156,7 @@ import { VaultViewLayout } from "./vault/VaultViewLayout";
import { useVaultHostCollections } from "./vault/useVaultHostCollections";
import { useVaultImportHandlers } from "../application/state/useVaultImportHandlers";
import { useVaultGroupDragHandlers } from "./vault/useVaultGroupDragHandlers";
import { useInspectionScheduler } from "../application/state/useInspectionScheduler";
const LazyProtocolSelectDialog = lazy(() => import("./ProtocolSelectDialog"));
const LazyConnectionLogsManager = lazy(() => import("./ConnectionLogsManager"));
@@ -172,7 +173,10 @@ export type VaultSection =
| "notes"
| "port"
| "knownhosts"
| "logs";
| "logs"
| "inspection"
| "alerts"
| "alertRules";
const haveSameHostOrderResult = (previous: Host[], next: Host[]) => {
if (previous.length !== next.length) return false;
@@ -298,6 +302,7 @@ interface VaultViewProps {
keepaliveInterval: number;
keepaliveCountMax: number;
};
productName?: string;
}
const VaultViewInner: React.FC<VaultViewProps> = ({
@@ -327,6 +332,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
onUpdateKeys,
onImportOrReuseKey,
onUpdateIdentities,
productName,
onUpdateProxyProfiles,
onUpdateSnippets,
onUpdateSnippetPackages,
@@ -429,6 +435,32 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
}
}, [navigateToSection, onNavigateToSectionHandled]);
// 巡检调度器
const inspectionScheduler = useInspectionScheduler(hosts, keys);
// 监听 hosts 加载完成后触发一次巡检(StrictMode 下多次触发也没关系,scanLoop 有 runningRef 保护)
const prevHostsLenRef = useRef(0);
useEffect(() => {
if (hosts.length > 0 && prevHostsLenRef.current === 0) {
// hosts 从空变成非空,触发一次巡检(传入 hosts 参数,避免闭包问题)
console.log('[VaultView] hosts 加载完成,触发 scanLoop');
setTimeout(() => {
inspectionScheduler.scanLoop(hosts);
}, 500);
}
prevHostsLenRef.current = hosts.length;
}, [hosts.length]);
// 启动周期性巡检(30 秒一次)
useEffect(() => {
if (hosts.length === 0) return;
const id = setInterval(() => {
console.log('[VaultView] 定时触发 scanLoop');
inspectionScheduler.scanLoop(hosts);
}, 30000);
return () => clearInterval(id);
}, [hosts.length]);
// View mode, sorting, and tag filter state
const [viewMode, setViewMode] = useStoredViewMode(
STORAGE_KEY_VAULT_HOSTS_VIEW_MODE,
@@ -1532,6 +1564,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
protocolSelectHost,
proxyProfiles,
ProxyProfilesManager,
productName,
quickConnectTarget,
quickConnectWarnings,
QuickConnectWizard,
@@ -1684,7 +1717,8 @@ export const vaultViewAreEqual = (
prev.terminalSettings?.keepaliveInterval ===
next.terminalSettings?.keepaliveInterval &&
prev.terminalSettings?.keepaliveCountMax ===
next.terminalSettings?.keepaliveCountMax;
next.terminalSettings?.keepaliveCountMax &&
prev.productName === next.productName;
return isEqual;
};