- 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
39 lines
742 B
Go
39 lines
742 B
Go
package collector
|
|
|
|
import (
|
|
"github.com/shirou/gopsutil/v3/disk"
|
|
)
|
|
|
|
type DiskInfo struct {
|
|
MountPoint string `json:"mount_point"`
|
|
Total uint64 `json:"total"`
|
|
Used uint64 `json:"used"`
|
|
Usage float64 `json:"usage"`
|
|
FileSystem string `json:"file_system"`
|
|
}
|
|
|
|
func CollectDisks() ([]DiskInfo, error) {
|
|
partitions, err := disk.Partitions(false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var disks []DiskInfo
|
|
for _, p := range partitions {
|
|
usage, err := disk.Usage(p.Mountpoint)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
|
|
disks = append(disks, DiskInfo{
|
|
MountPoint: p.Mountpoint,
|
|
Total: usage.Total,
|
|
Used: usage.Used,
|
|
Usage: usage.UsedPercent,
|
|
FileSystem: p.Fstype,
|
|
})
|
|
}
|
|
|
|
return disks, nil
|
|
}
|