From c0541f7bc9d02ea4569f336713c891628933ab01 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Wed, 25 Feb 2026 14:57:16 +1000 Subject: [PATCH] fix: exclude virtual/pseudo filesystems from disk metrics squashfs loop mounts (snap packages) are always 100% full by design and were skewing the max disk usage shown in the UI. Now filters the same set of pseudo-filesystems that 'df' excludes by default, plus any /dev/loop* devices regardless of fstype. --- main.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/main.go b/main.go index 6011bc9..869d756 100644 --- a/main.go +++ b/main.go @@ -744,6 +744,45 @@ func collectAndSend(config *Config) { log.Printf("Successfully sent metrics at %s", time.Now().Format(time.RFC3339)) } +// virtualFSTypes are filesystem types that should be excluded from disk +// reporting — pseudo, read-only, or kernel-managed mounts that aren't +// real storage (snap loop devices, tmpfs, container overlays, etc.). +var virtualFSTypes = map[string]bool{ + "squashfs": true, // snap packages — always 100% full + "tmpfs": true, + "devtmpfs": true, + "ramfs": true, + "overlay": true, + "overlayfs": true, + "proc": true, + "sysfs": true, + "devfs": true, + "cgroup": true, + "cgroup2": true, + "pstore": true, + "efivarfs": true, + "bpf": true, + "fusectl": true, + "hugetlbfs": true, + "mqueue": true, + "debugfs": true, + "tracefs": true, + "securityfs": true, + "configfs": true, + "autofs": true, +} + +func isVirtualFS(fstype, device string) bool { + if virtualFSTypes[fstype] { + return true + } + // Loop devices back read-only images (snaps, ISOs, etc.) + if strings.HasPrefix(device, "/dev/loop") { + return true + } + return false +} + func collectMetrics(config *Config) (*Metrics, error) { metrics := &Metrics{ Timestamp: time.Now().UTC(), @@ -847,6 +886,9 @@ func collectMetrics(config *Config) (*Metrics, error) { return nil, fmt.Errorf("failed to get disk partitions: %w", err) } for _, p := range partitions { + if isVirtualFS(p.Fstype, p.Device) { + continue + } usage, err := disk.Usage(p.Mountpoint) if err != nil { continue