Files
aiops/agent/model/model.go
T
attacker 4e3f8cb306 docs: update README, API reference, dev-log, project structure with Agent monitoring + quick-alarm + latest fixes
- README.md: React 19, default pwd 123456, Docker Compose deploy, correct module list
- api-reference.md: add Agent monitoring section (report/latest/rules/quick-setup/alerts/tasks/kline)
- dev-log.md: new entry documenting hostname/IP fix, system collector, offline detection, quick alarm
- project-structure.md: add agent/ directory, dev-log.md link, React 19
2026-06-18 16:11:13 +00:00

55 lines
2.6 KiB
Go
Raw 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"` // 内存指标
Disks []DiskStat `json:"disks"` // 磁盘指标列表
Ports []PortStat `json:"ports"` // 监听端口列表
Network NetworkStat `json:"network"` // 网络指标
DiskIO DiskIOStat `json:"disk_io"` // 磁盘 IO
System *SystemStat `json:"system,omitempty"` // 系统信息(首次采集后携带)
}
// 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)
}