feat: add monitoring agent (Go) + agent report API + cloud billing UI

- Go agent: CPU/mem/disk/port collectors, HTTP report, static binary
- Cross-compile: linux/amd64 + linux/arm64 (statically linked)
- One-line install script for all Linux distros
- Backend: POST /api/v1/agent/report (no JWT) + GET /agent/latest,history (JWT)
- CloudBilling.tsx: fixed syntax errors, stats/trends/records/alerts
- K8s menu renamed to Kubernetes管理

Signed-off-by: Logan.Li
This commit is contained in:
attacker committed 2026-06-14 21:27:14 +08:00
1 parent 77d13b07d5
commit ac0b8e75c0
17 files changed
+1267

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
// Package model 定义 AIOps Agent 与后端之间交互的数据结构。
// 这些结构经 JSON 序列化后上报至后端 /api/v1/agent/report 接口。
//
// 署名 Logan.Li
package model
// Report 为单次采集周期的完整上报报文
type Report struct {
Hostname string `json:"hostname"` // 主机名
Timestamp string `json:"timestamp"` // RFC3339 格式的 UTC 时间戳
CPU CPUStat `json:"cpu"` // CPU 指标
Memory MemoryStat `json:"memory"` // 内存指标
Disks []DiskStat `json:"disks"` // 磁盘指标列表
Ports []PortStat `json:"ports"` // 监听端口列表
}
// CPUStat CPU 相关指标
type CPUStat struct {
UsagePercent float64 `json:"usage_percent"` // CPU 总体使用率(百分比)
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)
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"` // 使用率(百分比)
}
// PortStat 监听端口及其归属进程
type PortStat struct {
Port int `json:"port"` // 监听端口
Protocol string `json:"protocol"` // 协议:tcp / tcp6
Process string `json:"process"` // 进程名(可执行文件名)
PID int `json:"pid"` // 进程 PID(无法解析时为 0)
}