add machine_id

This commit is contained in:
boge
2025-03-18 15:56:00 +08:00
parent 58b470e95f
commit 6001907e8a
7 changed files with 286 additions and 27 deletions

View File

@@ -14,6 +14,10 @@ func NewMemoryInfo() models.MemoryInfo {
Total: 0,
Free: 0,
Available: 0,
Used: 0,
Buffers: 0,
Cached: 0,
Shared: 0,
}
}
@@ -46,9 +50,18 @@ func GetMemoryInfo() models.MemoryInfo {
memInfo.Free = value
case "MemAvailable:":
memInfo.Available = value
case "Buffers:":
memInfo.Buffers = value // 存储 Buffers 值
case "Cached:":
memInfo.Cached = value // 存储 Cached 值
case "Shmem:":
memInfo.Shared = value // 存储 Shared 值
}
}
// 计算已用内存
memInfo.Used = memInfo.Total - memInfo.Free - memInfo.Buffers - memInfo.Cached - memInfo.Shared
return memInfo
}