Files
attacker 8240a88a84 feat(k8s): M14 Namespace 管理看板(资源配额 + 命名空间 CRUD)
- 后端: ListNamespacesDetailed/CreateNamespace/DeleteNamespace/ListResourceQuotas/ListLimitRanges
- 后端: GetNamespacesDetail handler (6 API calls aggregate, not N×3)
- 后端: CreateNamespaceHandler + DeleteNamespaceHandler (system NS protection)
- 前端: NamespaceManagementPage.tsx (~280行) — 表格+概览卡片+创建/删除弹框
- 路由: GET/POST/DELETE /:clusterCode/namespaces + GET /namespace/:ns/detail
- 验证: 9/9 通过 (urllib), TS 零错误, Vite 构建成功
2026-06-24 23:46:52 +08:00

65 lines
3.7 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package model 定义 AIOps Agent 与后端之间交互的数据结构。
// 这些结构经 JSON 序列化后上报至后端 /api/v1/agent/report 接口。
//
// 署名 Logan.Li
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"` // 内存指标
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 自检
ProbeResults []ProbeResult `json:"probe_results,omitempty"` // v2.1 健康探针结果
}
// CPUStat CPU 相关指标
type CPUStat struct {
UsagePercent float64 `json:"usage_percent"` // CPU 总体使用率(百分比)
IOWait float64 `json:"iowait"` // CPU 等待 IO 的时间占比(百分比)
CoreCount int `json:"core_count"` // CPU 逻辑核心数
Load1 float64 `json:"load1"` // 1 分钟平均负载
Load5 float64 `json:"load5"` // 5 分钟平均负载
Load15 float64 `json:"load15"` // 15 分钟平均负载
}
// MemoryStat 内存相关指标
type MemoryStat struct {
TotalGB float64 `json:"total_gb"` // 总内存(GB)
UsedGB float64 `json:"used_gb"` // 已用内存(GB)
CachedGB float64 `json:"cached_gb"` // 缓存(Buffers + Cached,GB)
AvailableGB float64 `json:"available_gb"` // 可用内存(GB),含可回收缓存 — 真实剩余可用
SwapUsedGB float64 `json:"swap_used_gb"` // Swap 已用量(GB)— OOM 金标准
UsagePercent float64 `json:"usage_percent"` // 内存使用率(百分比)
}
// DiskStat 单个挂载点的磁盘使用情况
type DiskStat struct {
Mount string `json:"mount"` // 挂载点
Device string `json:"device"` // 设备名
TotalGB float64 `json:"total_gb"` // 总容量(GB)
UsedGB float64 `json:"used_gb"` // 已用容量(GB)
UsagePercent float64 `json:"usage_percent"` // 使用率(百分比)
InodeUsagePct float64 `json:"inode_usage_pct"` // inode 使用率(百分比)— 防止文件数爆炸
}
// PortStat 监听端口及其归属进程
type PortStat struct {
Port int `json:"port"` // 监听端口
Protocol string `json:"protocol"` // 协议:tcp / tcp6
Process string `json:"process"` // 进程名(可执行文件名)
PID int `json:"pid"` // 进程 PID(无法解析时为 0)
}