feat: init pc-monitor project
- Client: Go-based Windows hardware monitoring (CPU, GPU, memory, disk, network, power) - Server: Go + Gin + SQLite backend with REST API - Frontend: Vue 3 + Element Plus dashboard - Docker deployment support - Windows service installation script
This commit is contained in:
24
client/collector/memory.go
Normal file
24
client/collector/memory.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package collector
|
||||
|
||||
import (
|
||||
"github.com/shirou/gopsutil/v3/mem"
|
||||
)
|
||||
|
||||
type MemoryInfo struct {
|
||||
Total uint64 `json:"total"`
|
||||
Used uint64 `json:"used"`
|
||||
Usage float64 `json:"usage"`
|
||||
}
|
||||
|
||||
func CollectMemory() (*MemoryInfo, error) {
|
||||
vmStat, err := mem.VirtualMemory()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MemoryInfo{
|
||||
Total: vmStat.Total,
|
||||
Used: vmStat.Used,
|
||||
Usage: vmStat.UsedPercent,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user