Add extra disks to system table

This commit is contained in:
Sven van Ginkel
2025-11-02 20:59:34 +01:00
parent f60b3bbbfb
commit c98472ca0b
4 changed files with 107 additions and 1 deletions

View File

@@ -155,6 +155,7 @@ func (a *Agent) gatherStats(cacheTimeMs uint16) *system.CombinedData {
}
data.Stats.ExtraFs = make(map[string]*system.FsStats)
data.Info.ExtraFsPct = make(map[string]system.ExtraFsInfo)
for name, stats := range a.fsStats {
if !stats.Root && stats.DiskTotal > 0 {
// Use custom name if available, otherwise use device name
@@ -163,6 +164,11 @@ func (a *Agent) gatherStats(cacheTimeMs uint16) *system.CombinedData {
key = stats.Name
}
data.Stats.ExtraFs[key] = stats
// Add percentage info to Info struct for dashboard
if stats.DiskTotal > 0 {
pct := (stats.DiskUsed / stats.DiskTotal) * 100
data.Info.ExtraFsPct[key] = system.ExtraFsInfo{DiskPct: pct}
}
}
}
slog.Debug("Extra FS", "data", data.Stats.ExtraFs)