From d1703ce4e9d2fb06a947c498d4880d3893e45b8d Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Thu, 4 Sep 2025 10:59:59 +0000 Subject: [PATCH] improve: skip Windows System Reserved partitions in disk usage calculation (addresses #414) - Windows System Reserved partitions now excluded from disk usage - Added better handling for filesystems with zero total bytes - Improved debug logging for skipped filesystems - Prevents incorrect disk usage display for Windows VMs --- internal/monitoring/monitor.go | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go index 8e42110b0..f42cab79e 100644 --- a/internal/monitoring/monitor.go +++ b/internal/monitoring/monitor.go @@ -1152,12 +1152,15 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam strings.HasPrefix(fs.Mountpoint, "/proc") || strings.HasPrefix(fs.Mountpoint, "/sys") || strings.HasPrefix(fs.Mountpoint, "/run") || - fs.Mountpoint == "/boot/efi" { + fs.Mountpoint == "/boot/efi" || + fs.Mountpoint == "System Reserved" || // Windows System Reserved partition + strings.Contains(fs.Mountpoint, "System Reserved") { // Various Windows reserved formats skippedFS = append(skippedFS, fmt.Sprintf("%s(%s)", fs.Mountpoint, fs.Type)) continue } - // Only count real filesystems + // Only count real filesystems with valid data + // Some filesystems report 0 bytes (like unformatted or system partitions) if fs.TotalBytes > 0 { totalBytes += fs.TotalBytes usedBytes += fs.UsedBytes @@ -1169,6 +1172,13 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam Uint64("total", fs.TotalBytes). Uint64("used", fs.UsedBytes). Msg("Including filesystem in disk usage calculation") + } else if fs.TotalBytes == 0 && len(fs.Mountpoint) > 0 { + log.Debug(). + Str("instance", instanceName). + Str("vm", res.Name). + Str("mountpoint", fs.Mountpoint). + Str("type", fs.Type). + Msg("Skipping filesystem with zero total bytes") } } @@ -1600,12 +1610,14 @@ func (m *Monitor) pollVMsWithNodes(ctx context.Context, instanceName string, cli strings.HasPrefix(fs.Mountpoint, "/proc") || strings.HasPrefix(fs.Mountpoint, "/sys") || strings.HasPrefix(fs.Mountpoint, "/run") || - fs.Mountpoint == "/boot/efi" { + fs.Mountpoint == "/boot/efi" || + fs.Mountpoint == "System Reserved" || // Windows System Reserved partition + strings.Contains(fs.Mountpoint, "System Reserved") { // Various Windows reserved formats skippedFS = append(skippedFS, fmt.Sprintf("%s(%s)", fs.Mountpoint, fs.Type)) continue } - // Only count real filesystems (ext4, xfs, btrfs, ntfs, etc.) + // Only count real filesystems (ext4, xfs, btrfs, ntfs, etc.) with valid data if fs.TotalBytes > 0 { totalBytes += fs.TotalBytes usedBytes += fs.UsedBytes @@ -1617,6 +1629,13 @@ func (m *Monitor) pollVMsWithNodes(ctx context.Context, instanceName string, cli Uint64("total", fs.TotalBytes). Uint64("used", fs.UsedBytes). Msg("Including filesystem in disk usage calculation (legacy API)") + } else if fs.TotalBytes == 0 && len(fs.Mountpoint) > 0 { + log.Debug(). + Str("instance", instanceName). + Str("vm", vm.Name). + Str("mountpoint", fs.Mountpoint). + Str("type", fs.Type). + Msg("Skipping filesystem with zero total bytes (legacy API)") } }