feat(alert-center): 添加飞书Webhook通知渠道 + 告警引擎实时通知
- 后端: NotifyChannel 模型新增 feishu 类型, FeishuWebhookConfig - 后端: TestNotifyChannel 真实发送飞书测试消息(文本格式) - 后端: 告警引擎触发/恢复时自动发送飞书通知(sendFeishuAlert/sendFeishuRecovery) - 后端: AlertEngine 新增 tcp_time_wait/tcp_close_wait/service_process 指标检测 - 后端: NetworkStatModel 新增 TCPCloseWait 字段 - 后端: QuickSetupRules 一键创建6条告警规则(CPU/内存/磁盘/TIME_WAIT/CLOSE_WAIT/进程) - 后端: 注册 /alerts/quick-setup 路由 - 前端: AlertChannelDialog 新增飞书类型选项 - 前端: helpers 新增 getChannelIcon/getChannelTypeLabel 支持 feishu/dingtalk/wechat
This commit is contained in:
1 parent
7bc5169e8f
commit
5333f6f04a
30 files changed
+2406
-1001
No files matched your search
+16
-11
@@ -6,17 +6,22 @@ package model
|
||||
|
||||
// Report 为单次采集周期的完整上报报文
|
||||
type Report struct {
|
||||
Hostname string `json:"hostname"` // 主机名
|
||||
IP string `json:"ip,omitempty"` // 本机 IP(Agent 启动时探测)
|
||||
Timestamp string `json:"timestamp"` // RFC3339 格式的 UTC 时间戳
|
||||
AgentVersion string `json:"agent_version"` // Agent 版本号
|
||||
CPU CPUStat `json:"cpu"` // CPU 指标
|
||||
Memory MemoryStat `json:"memory"` // 内存指标
|
||||
Disks []DiskStat `json:"disks"` // 磁盘指标列表
|
||||
Ports []PortStat `json:"ports"` // 监听端口列表
|
||||
Network NetworkStat `json:"network"` // 网络指标
|
||||
DiskIO DiskIOStat `json:"disk_io"` // 磁盘 IO
|
||||
System *SystemStat `json:"system,omitempty"` // 系统信息(首次采集后携带)
|
||||
Hostname string `json:"hostname"` // 主机名
|
||||
IP string `json:"ip,omitempty"` // 本机 IP(Agent 启动时探测)
|
||||
Timestamp string `json:"timestamp"` // RFC3339 UTC 时间戳
|
||||
AgentVersion string `json:"agent_version"` // Agent 版本号
|
||||
CPU CPUStat `json:"cpu"` // CPU 指标
|
||||
Memory MemoryStat `json:"memory"` // 内存指标
|
||||
Swap *SwapStat `json:"swap,omitempty"` // 交换分区(有 swap 才上报)
|
||||
Disks []DiskStat `json:"disks"` // 磁盘指标列表
|
||||
Ports []PortStat `json:"ports"` // 监听端口列表
|
||||
Network NetworkStat `json:"network"` // 网络指标
|
||||
DiskIO DiskIOStat `json:"disk_io"` // 磁盘 IO
|
||||
System *SystemStat `json:"system,omitempty"` // 系统信息(首次采集后携带)
|
||||
ProcessTop []ProcessStat `json:"process_top,omitempty"` // 进程 TOP N
|
||||
FD *SocketFDStat `json:"fd,omitempty"` // 系统文件句柄
|
||||
ContextSwitches *ContextSwitchStat `json:"context_switches,omitempty"` // 上下文切换
|
||||
Heartbeat AgentHeartbeat `json:"heartbeat"` // Agent 自检
|
||||
}
|
||||
|
||||
// CPUStat CPU 相关指标
|
||||
|
||||
@@ -18,11 +18,41 @@ type DiskIOStat struct {
|
||||
WriteIOPS float64 `json:"write_iops"` // 写入 IOPS (count/s)
|
||||
}
|
||||
|
||||
// SwapStat 交换分区指标(OOM 前兆判断)
|
||||
type SwapStat struct {
|
||||
TotalGB float64 `json:"total_gb"`
|
||||
UsedGB float64 `json:"used_gb"`
|
||||
UsagePercent float64 `json:"usage_percent"`
|
||||
}
|
||||
|
||||
// SocketFDStat 系统级 FD 使用情况
|
||||
type SocketFDStat struct {
|
||||
Allocated int `json:"allocated"` // 已分配的 file handles (fs.file-nr 第一列)
|
||||
Max int64 `json:"max"` // 系统上限 (fs.file-max)
|
||||
UsagePct float64 `json:"usage_pct"`
|
||||
}
|
||||
|
||||
// ContextSwitchStat 上下文切换(决定是否开中断合并/CPU 隔离)
|
||||
type ContextSwitchStat struct {
|
||||
CTXPerSec float64 `json:"ctx_per_sec"` // 每秒上下文切换次数
|
||||
IRQPerSec float64 `json:"irq_per_sec"` // 每秒中断次数
|
||||
}
|
||||
|
||||
// AgentHeartbeat Agent 自检心跳(随每次上报附带,极小 payload)
|
||||
type AgentHeartbeat struct {
|
||||
Version string `json:"version"`
|
||||
UptimeSec int64 `json:"uptime_sec"`
|
||||
LastErr string `json:"last_err,omitempty"`
|
||||
SelfCPU float64 `json:"self_cpu_pct"`
|
||||
SelfRSSMB float64 `json:"self_rss_mb"`
|
||||
ReportSeq uint64 `json:"report_seq"` // 单调递增序列号,用于丢包检测
|
||||
}
|
||||
|
||||
// SystemStat 系统信息(启动时采集一次)
|
||||
type SystemStat struct {
|
||||
OSVersion string `json:"os_version"` // OS 版本 (如 "Ubuntu 22.04")
|
||||
Kernel string `json:"kernel"` // 内核版本
|
||||
Uptime int64 `json:"uptime"` // 运行秒数
|
||||
UlimitNofile int64 `json:"ulimit_nofile"` // ulimit -n (最大文件描述符)
|
||||
UlimitNproc int64 `json:"ulimit_nproc"` // ulimit -u (最大进程数)
|
||||
OSVersion string `json:"os_version"` // OS 版本 (如 "Ubuntu 22.04")
|
||||
Kernel string `json:"kernel"` // 内核版本
|
||||
Uptime int64 `json:"uptime"` // 运行秒数
|
||||
UlimitNofile int64 `json:"ulimit_nofile"` // ulimit -n (最大文件描述符)
|
||||
UlimitNproc int64 `json:"ulimit_nproc"` // ulimit -u (最大进程数)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package model
|
||||
|
||||
// ProcessStat 单个进程统计(TOP N 采集)
|
||||
type ProcessStat struct {
|
||||
PID int `json:"pid"`
|
||||
Name string `json:"name"`
|
||||
MemoryMB float64 `json:"memory_mb"` // 物理内存 (MB)
|
||||
FDCount int `json:"fd_count"` // 打开的文件句柄数
|
||||
Threads int `json:"threads"` // 线程数
|
||||
}
|
||||
Reference in new issue
Block a user