mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-23 03:33:53 +00:00
Surface read-only guest filesystems (refs #505)
This commit is contained in:
@@ -1964,12 +1964,14 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam
|
||||
for _, fs := range fsInfo {
|
||||
// Skip special filesystems and mounts
|
||||
skipReasons := []string{}
|
||||
reasonReadOnly := ""
|
||||
shouldSkip := false
|
||||
|
||||
// Check filesystem type
|
||||
fsTypeLower := strings.ToLower(fs.Type)
|
||||
if reason, skip := readOnlyFilesystemReason(fs.Type, fs.TotalBytes, fs.UsedBytes); skip {
|
||||
skipReasons = append(skipReasons, fmt.Sprintf("read-only-%s", reason))
|
||||
reasonReadOnly = reason
|
||||
shouldSkip = true
|
||||
}
|
||||
if fs.Type == "tmpfs" || fs.Type == "devtmpfs" ||
|
||||
@@ -2004,6 +2006,26 @@ func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceNam
|
||||
}
|
||||
|
||||
if shouldSkip {
|
||||
if reasonReadOnly != "" && fs.TotalBytes > 0 {
|
||||
individualDisks = append(individualDisks, models.Disk{
|
||||
Total: int64(fs.TotalBytes),
|
||||
Used: int64(fs.UsedBytes),
|
||||
Free: int64(fs.TotalBytes - fs.UsedBytes),
|
||||
Usage: safePercentage(float64(fs.UsedBytes), float64(fs.TotalBytes)),
|
||||
Mountpoint: fs.Mountpoint,
|
||||
Type: fs.Type,
|
||||
Device: fs.Disk,
|
||||
})
|
||||
log.Debug().
|
||||
Str("instance", instanceName).
|
||||
Str("vm", res.Name).
|
||||
Int("vmid", res.VMID).
|
||||
Str("mountpoint", fs.Mountpoint).
|
||||
Str("type", fs.Type).
|
||||
Float64("total_gb", float64(fs.TotalBytes)/1073741824).
|
||||
Float64("used_gb", float64(fs.UsedBytes)/1073741824).
|
||||
Msg("Tracking read-only filesystem separately from disk aggregation")
|
||||
}
|
||||
skippedFS = append(skippedFS, fmt.Sprintf("%s(%s,%s)",
|
||||
fs.Mountpoint, fs.Type, strings.Join(skipReasons, ",")))
|
||||
continue
|
||||
|
||||
@@ -316,36 +316,47 @@ func (m *Monitor) pollVMsWithNodesOptimized(ctx context.Context, instanceName st
|
||||
// For Windows, mountpoints are like "C:\\" or "D:\\" - don't skip those
|
||||
isWindowsDrive := len(fs.Mountpoint) >= 2 && fs.Mountpoint[1] == ':' && strings.Contains(fs.Mountpoint, "\\")
|
||||
|
||||
if !isWindowsDrive {
|
||||
if reason, skip := readOnlyFilesystemReason(fs.Type, fs.TotalBytes, fs.UsedBytes); skip {
|
||||
log.Debug().
|
||||
Str("vm", vm.Name).
|
||||
Str("mountpoint", fs.Mountpoint).
|
||||
Str("type", fs.Type).
|
||||
Str("skipReason", reason).
|
||||
Uint64("total", fs.TotalBytes).
|
||||
Uint64("used", fs.UsedBytes).
|
||||
Msg("Skipping read-only filesystem from guest agent")
|
||||
continue
|
||||
}
|
||||
if !isWindowsDrive {
|
||||
if reason, skip := readOnlyFilesystemReason(fs.Type, fs.TotalBytes, fs.UsedBytes); skip {
|
||||
if fs.TotalBytes > 0 {
|
||||
individualDisks = append(individualDisks, models.Disk{
|
||||
Total: int64(fs.TotalBytes),
|
||||
Used: int64(fs.UsedBytes),
|
||||
Free: int64(fs.TotalBytes - fs.UsedBytes),
|
||||
Usage: safePercentage(float64(fs.UsedBytes), float64(fs.TotalBytes)),
|
||||
Mountpoint: fs.Mountpoint,
|
||||
Type: fs.Type,
|
||||
Device: fs.Disk,
|
||||
})
|
||||
}
|
||||
log.Debug().
|
||||
Str("vm", vm.Name).
|
||||
Str("mountpoint", fs.Mountpoint).
|
||||
Str("type", fs.Type).
|
||||
Str("skipReason", reason).
|
||||
Uint64("total", fs.TotalBytes).
|
||||
Uint64("used", fs.UsedBytes).
|
||||
Msg("Skipping read-only filesystem from guest agent")
|
||||
continue
|
||||
}
|
||||
|
||||
if fs.Type == "tmpfs" || fs.Type == "devtmpfs" ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/dev") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/proc") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/sys") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/run") ||
|
||||
fs.Mountpoint == "/boot/efi" ||
|
||||
fs.Mountpoint == "System Reserved" ||
|
||||
strings.Contains(fs.Mountpoint, "System Reserved") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/snap") { // Skip snap mounts
|
||||
log.Debug().
|
||||
Str("vm", vm.Name).
|
||||
Str("mountpoint", fs.Mountpoint).
|
||||
Str("type", fs.Type).
|
||||
Msg("Skipping special filesystem")
|
||||
continue
|
||||
}
|
||||
}
|
||||
if fs.Type == "tmpfs" || fs.Type == "devtmpfs" ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/dev") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/proc") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/sys") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/run") ||
|
||||
fs.Mountpoint == "/boot/efi" ||
|
||||
fs.Mountpoint == "System Reserved" ||
|
||||
strings.Contains(fs.Mountpoint, "System Reserved") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/snap") { // Skip snap mounts
|
||||
log.Debug().
|
||||
Str("vm", vm.Name).
|
||||
Str("mountpoint", fs.Mountpoint).
|
||||
Str("type", fs.Type).
|
||||
Msg("Skipping special filesystem")
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Skip if we've already seen this device (duplicate mount point)
|
||||
if fs.Disk != "" && seenDevices[fs.Disk] {
|
||||
|
||||
Reference in New Issue
Block a user