add agent

This commit is contained in:
boge
2025-03-14 17:29:09 +08:00
parent f7ccf7d461
commit 55abec4a72
14 changed files with 672 additions and 23 deletions

View File

@@ -1,14 +1,66 @@
package models
// CPUInfo 结构体用于存储 CPU 信息
type CPUInfo struct {
ModelName string `json:"model_name"`
Cores int `json:"cores"`
Architecture string `json:"architecture"`
}
// MemoryInfo holds the memory information.
type MemoryInfo struct {
Total uint64 `json:"total"`
Free uint64 `json:"free"`
Available uint64 `json:"available"`
}
// DiskInfo holds the disk information similar to df -Th output.
type DiskInfo struct {
Device string `json:"device"` // 逻辑分区设备名称
Filesystem string `json:"filesystem"` // 逻辑分区
Type string `json:"type"` // 文件系统类型
Size uint64 `json:"size"` // 总大小
Used uint64 `json:"used"` // 已用空间
Available uint64 `json:"available"` // 可用空间
UsePercent string `json:"use_percent"` // 使用百分比
MountPoint string `json:"mountpoint"` // 挂载点
PhysicalDevice string `json:"physical_device"` // 物理设备名称
PhysicalSize uint64 `json:"physical_size"` // 物理盘大小
}
// NetworkInterfaceInfo 结构体用于存储网卡信息
type NetworkInterfaceInfo struct {
Name string `json:"name"`
MACAddress string `json:"mac_address"`
IPAddresses []string `json:"ip_addresses"`
}
// MotherboardInfo holds the motherboard information.
type MotherboardInfo struct {
Manufacturer string `json:"manufacturer"`
Product string `json:"product"`
Version string `json:"version"`
Serial string `json:"serial"`
}
// HostInfo 主机信息模型
type HostInfo struct {
UUID string `json:"uuid"` // 主机UUID
CPU string `json:"cpu"` // CPU信息
Motherboard string `json:"motherboard"` // 主板信息
MAC string `json:"mac"` // MAC地址
Disk string `json:"disk"` // 硬盘信息
CPUInfo CPUInfo `json:"cpu_info"`
DiskInfo []DiskInfo `json:"disk_info"`
MemoryInfo MemoryInfo `json:"memory_info"`
NetInfo []NetworkInterfaceInfo `json:"net_info"`
MotherboardInfo MotherboardInfo `json:"motherboard_info"`
}
//// HostInfo 主机信息模型
//type HostInfo struct {
// UUID string `json:"uuid"` // 主机UUID
// CPU string `json:"cpu"` // CPU信息
// Motherboard string `json:"motherboard"` // 主板信息
// MAC string `json:"mac"` // MAC地址
// Disk string `json:"disk"` // 硬盘信息
//}
// HeartbeatRequest 心跳请求
type HeartbeatRequest struct {
HostInfo HostInfo `json:"host_info"` // 主机信息