feat: Phase 6 Agent 系统信息+进程监控采集器
- 新增 collector/system.go: SystemCollector(OS/内核/ulimit) + ProcessCollector(Top 5 CPU/内存) - 模型新增 SystemStat + ProcessStat + ProcessInfo - Report 结构新增 System + Processes 字段 - Agent 启动时采集系统信息,每周期采集进程列表
This commit is contained in:
1 parent
2e71371257
commit
06d7451cf9
3 files changed
+265
No files matched your search
@@ -15,6 +15,8 @@ type Report struct {
|
||||
Network NetworkStat `json:"network"` // 网络指标
|
||||
DiskIO DiskIOStat `json:"disk_io"` // 磁盘 IO 指标
|
||||
Middleware MiddlewareStat `json:"middleware,omitempty"` // 中间件指标(Redis/MySQL)
|
||||
System SystemStat `json:"system,omitempty"` // 系统信息(OS/内核/ulimit)
|
||||
Processes ProcessStat `json:"processes,omitempty"` // Top N 进程
|
||||
}
|
||||
|
||||
// MiddlewareStat 中间件综合指标 — 包含 Redis + MySQL
|
||||
@@ -79,3 +81,27 @@ type PortStat struct {
|
||||
Process string `json:"process"` // 进程名(可执行文件名)
|
||||
PID int `json:"pid"` // 进程 PID(无法解析时为 0)
|
||||
}
|
||||
|
||||
// SystemStat 系统信息指标
|
||||
type SystemStat struct {
|
||||
OS string `json:"os"` // 操作系统名称
|
||||
Kernel string `json:"kernel"` // 内核版本
|
||||
Arch string `json:"arch"` // 系统架构
|
||||
Hostname string `json:"hostname"` // 主机名
|
||||
UlimitNofile int64 `json:"ulimit_nofile"` // 文件句柄数上限
|
||||
UlimitNproc int64 `json:"ulimit_nproc"` // 进程数上限
|
||||
}
|
||||
|
||||
// ProcessStat 进程监控指标
|
||||
type ProcessStat struct {
|
||||
TopCPU []ProcessInfo `json:"top_cpu"` // Top 5 CPU 进程
|
||||
TopMem []ProcessInfo `json:"top_mem"` // Top 5 内存进程
|
||||
}
|
||||
|
||||
// ProcessInfo 单个进程信息
|
||||
type ProcessInfo struct {
|
||||
PID int `json:"pid"` // 进程 ID
|
||||
Name string `json:"name"` // 进程名
|
||||
CPUPercent float64 `json:"cpu_percent"` // CPU 使用率 (%)
|
||||
RSSKB int64 `json:"rss_kb"` // 物理内存 (KB)
|
||||
}
|
||||
Reference in new issue
Block a user