- 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
50 lines
2.1 KiB
Go
50 lines
2.1 KiB
Go
// 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)
|
||
}
|