Initial Proxmox dashboard with host and guest metrics

This commit is contained in:
maxim
2026-07-31 19:51:22 +03:00
commit 584ff7e8ee
21 changed files with 1780 additions and 0 deletions

29
storage.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import "syscall"
type StorageMetrics struct {
Mountpoint string `json:"mountpoint"`
TotalBytes uint64 `json:"totalBytes"`
UsedBytes uint64 `json:"usedBytes"`
FreeBytes uint64 `json:"freeBytes"`
UsagePercent float64 `json:"usagePercent"`
}
func readStorageMetrics(path string) (StorageMetrics, error) {
var stat syscall.Statfs_t
if err := syscall.Statfs(path, &stat); err != nil {
return StorageMetrics{}, err
}
total := stat.Blocks * uint64(stat.Bsize)
free := stat.Bavail * uint64(stat.Bsize)
used := total - free
var percent float64
if total > 0 {
percent = float64(used) / float64(total) * 100
}
return StorageMetrics{
Mountpoint: path, TotalBytes: total, UsedBytes: used,
FreeBytes: free, UsagePercent: percent,
}, nil
}