Initial commit: NetMesh smart ops platform with 3D topology, inspection reports, RCA and AI ops assistant
Some checks failed
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled

This commit is contained in:
2026-10-15 13:53:04 +08:00
commit 2f9f8da48e
3299 changed files with 926841 additions and 0 deletions

View File

@@ -0,0 +1,189 @@
"use strict";
/**
* 设备类型数据模型 + 预置数据
*
* 设备类型(device_catalog):定义一类设备的采集能力和默认配置。
* 预置 6 种设备类型,用户可在界面上新增。
*/
const { DEVICE_CATALOG_TYPES, ALERT_LEVELS, DEVICE_TIERS } = require("./types.cjs");
/**
* 默认告警阈值 - 用于设备类型的预置配置
* 格式:{ metric, operator, threshold, level, duration }
*/
const DEFAULT_THRESHOLDS = {
linux: [
{ metric: "cpu_usage", operator: ">", threshold: "80", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "cpu_usage", operator: ">", threshold: "70", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "memory_usage", operator: ">", threshold: "85", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "memory_usage", operator: ">", threshold: "75", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "online", operator: "==", threshold: "false", level: ALERT_LEVELS.CRITICAL, duration: 1 },
],
windows: [
{ metric: "cpu_usage", operator: ">", threshold: "80", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "cpu_usage", operator: ">", threshold: "70", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "memory_usage", operator: ">", threshold: "85", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "memory_usage", operator: ">", threshold: "75", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "online", operator: "==", threshold: "false", level: ALERT_LEVELS.CRITICAL, duration: 1 },
],
huawei_h3c_switch: [
{ metric: "cpu_usage", operator: ">", threshold: "80", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "cpu_usage", operator: ">", threshold: "70", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "memory_usage", operator: ">", threshold: "85", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "memory_usage", operator: ">", threshold: "75", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "online", operator: "==", threshold: "false", level: ALERT_LEVELS.CRITICAL, duration: 1 },
],
cisco_switch: [
{ metric: "cpu_usage", operator: ">", threshold: "80", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "cpu_usage", operator: ">", threshold: "70", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "memory_usage", operator: ">", threshold: "85", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "memory_usage", operator: ">", threshold: "75", level: ALERT_LEVELS.WARNING, duration: 2 },
{ metric: "online", operator: "==", threshold: "false", level: ALERT_LEVELS.CRITICAL, duration: 1 },
],
huawei_firewall: [
{ metric: "cpu_usage", operator: ">", threshold: "80", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "memory_usage", operator: ">", threshold: "85", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "online", operator: "==", threshold: "false", level: ALERT_LEVELS.CRITICAL, duration: 1 },
],
fortinet_firewall: [
{ metric: "cpu_usage", operator: ">", threshold: "80", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "memory_usage", operator: ">", threshold: "85", level: ALERT_LEVELS.CRITICAL, duration: 1 },
{ metric: "online", operator: "==", threshold: "false", level: ALERT_LEVELS.CRITICAL, duration: 1 },
],
};
/**
* 预置设备类型列表
* 每条记录对应一条 device_catalog 数据
*/
const PRESET_DEVICE_CATALOG = [
{
id: "linux",
type_key: DEVICE_CATALOG_TYPES.LINUX,
name: "Linux 服务器",
vendor: "Linux",
adapter_class: "LinuxServerAdapter",
supported_metrics: [
"cpu_usage",
"memory_usage",
"disk_usage",
"load_avg",
"uptime",
"process_count",
"online",
],
default_thresholds: DEFAULT_THRESHOLDS.linux,
default_interval: 5, // 默认 5 分钟
description: "通用 Linux 服务器,支持 Ubuntu/CentOS/Debian/Alpine 等发行版",
preset: true,
},
{
id: "windows",
type_key: DEVICE_CATALOG_TYPES.WINDOWS,
name: "Windows 服务器",
vendor: "Microsoft",
adapter_class: "WindowsServerAdapter",
supported_metrics: [
"cpu_usage",
"memory_usage",
"disk_usage",
"uptime",
"process_count",
"service_status",
"online",
],
default_thresholds: DEFAULT_THRESHOLDS.windows,
default_interval: 5,
description: "Windows Server 2012/2016/2019/2022,通过 SSH + PowerShell 采集",
preset: true,
},
{
id: "huawei_h3c_switch",
type_key: DEVICE_CATALOG_TYPES.HUAWEI_H3C_SWITCH,
name: "华为/H3C 交换机",
vendor: "华为/H3C",
adapter_class: "HuaweiH3CSwitchAdapter",
supported_metrics: [
"cpu_usage",
"memory_usage",
"port_status",
"power_status",
"fan_status",
"device_info",
"online",
],
default_thresholds: DEFAULT_THRESHOLDS.huawei_h3c_switch,
default_interval: 10, // 交换机默认 10 分钟
description: "华为 S3000/S5000/S7000/S9000 系列、H3C S5100/S5500 等交换机",
preset: true,
},
{
id: "cisco_switch",
type_key: DEVICE_CATALOG_TYPES.CISCO_SWITCH,
name: "Cisco 交换机",
vendor: "Cisco",
adapter_class: "CiscoSwitchAdapter",
supported_metrics: [
"cpu_usage",
"memory_usage",
"port_status",
"power_status",
"fan_status",
"online",
],
default_thresholds: DEFAULT_THRESHOLDS.cisco_switch,
default_interval: 10,
description: "Cisco Catalyst 2960/3650/3850/4500/6500 等交换机",
preset: true,
},
{
id: "huawei_firewall",
type_key: DEVICE_CATALOG_TYPES.HUAWEI_FIREWALL,
name: "华为防火墙",
vendor: "华为",
adapter_class: "HuaweiFirewallAdapter",
supported_metrics: [
"cpu_usage",
"memory_usage",
"session_count",
"online",
],
default_thresholds: DEFAULT_THRESHOLDS.huawei_firewall,
default_interval: 5, // 防火墙重要,默认 5 分钟
description: "华为 USG 系列防火墙",
preset: true,
},
{
id: "fortinet_firewall",
type_key: DEVICE_CATALOG_TYPES.FORTINET_FIREWALL,
name: "飞塔防火墙",
vendor: "Fortinet",
adapter_class: "FortinetFirewallAdapter",
supported_metrics: [
"cpu_usage",
"memory_usage",
"session_count",
"online",
],
default_thresholds: DEFAULT_THRESHOLDS.fortinet_firewall,
default_interval: 5,
description: "Fortinet FortiGate 系列防火墙",
preset: true,
},
];
/**
* 获取预置设备类型数据
* @returns {Array}
*/
function getPresetCatalog() {
return JSON.parse(JSON.stringify(PRESET_DEVICE_CATALOG));
}
module.exports = {
PRESET_DEVICE_CATALOG,
DEFAULT_THRESHOLDS,
getPresetCatalog,
};