Ignore read-only guest filesystems in disk aggregation

This commit is contained in:
rcourtman 2025-10-14 16:13:53 +00:00
parent 261bd7ac74
commit 78889ffedc
3 changed files with 68 additions and 18 deletions

View file

@ -243,7 +243,7 @@ The agent reports all mounted filesystems. Pulse automatically filters out:
- Special filesystems (proc, sys, tmpfs, devtmpfs, etc.) - Special filesystems (proc, sys, tmpfs, devtmpfs, etc.)
- Special Windows partitions ("System Reserved") - Special Windows partitions ("System Reserved")
- Bind mounts and overlays - Bind mounts and overlays
- CD/DVD filesystems (iso9660, CDFS) - Read-only appliance or optical images (squashfs, erofs, iso9660, CDFS, UDF, cramfs, romfs, fuse.cdfs)
Only local disk usage is counted toward the VM's total. Only local disk usage is counted toward the VM's total.

View file

@ -2,6 +2,19 @@ package monitoring
import "strings" import "strings"
var readOnlyFilesystemPatterns = []struct {
reason string
substrings []string
}{
{reason: "erofs", substrings: []string{"erofs"}},
{reason: "squashfs", substrings: []string{"squashfs", "squash-fs"}},
{reason: "iso9660", substrings: []string{"iso9660"}},
{reason: "cdfs", substrings: []string{"cdfs"}},
{reason: "udf", substrings: []string{"udf"}},
{reason: "cramfs", substrings: []string{"cramfs"}},
{reason: "romfs", substrings: []string{"romfs"}},
}
// readOnlyFilesystemReason returns a label explaining why a filesystem should be // readOnlyFilesystemReason returns a label explaining why a filesystem should be
// ignored for usage calculations, along with a boolean indicating whether it is // ignored for usage calculations, along with a boolean indicating whether it is
// a read-only filesystem that always reports full usage. This helps us avoid // a read-only filesystem that always reports full usage. This helps us avoid
@ -14,23 +27,12 @@ func readOnlyFilesystemReason(fsType string, totalBytes, usedBytes uint64) (stri
} }
// Common read-only filesystem types used for immutable system partitions. // Common read-only filesystem types used for immutable system partitions.
if strings.Contains(ft, "erofs") { for _, pattern := range readOnlyFilesystemPatterns {
return "erofs", true for _, needle := range pattern.substrings {
} if strings.Contains(ft, needle) {
if strings.Contains(ft, "squashfs") || strings.Contains(ft, "squash-fs") { return pattern.reason, true
return "squashfs", true }
} }
if strings.Contains(ft, "iso9660") {
return "iso9660", true
}
if strings.Contains(ft, "udf") {
return "udf", true
}
if strings.Contains(ft, "cramfs") {
return "cramfs", true
}
if strings.Contains(ft, "romfs") {
return "romfs", true
} }
// Overlay-style filesystems can report 100% usage even though writes are // Overlay-style filesystems can report 100% usage even though writes are

View file

@ -51,6 +51,54 @@ func TestReadOnlyFilesystemReason(t *testing.T) {
reason: "squashfs", reason: "squashfs",
skip: true, skip: true,
}, },
{
name: "iso9660 filesystem",
fsType: "iso9660",
totalBytes: 700 * 1024 * 1024,
usedBytes: 700 * 1024 * 1024,
reason: "iso9660",
skip: true,
},
{
name: "cdfs filesystem",
fsType: "CDFS",
totalBytes: 600 * 1024 * 1024,
usedBytes: 600 * 1024 * 1024,
reason: "cdfs",
skip: true,
},
{
name: "udf optical media",
fsType: "udf",
totalBytes: 4 * 1024 * 1024 * 1024,
usedBytes: 4 * 1024 * 1024 * 1024,
reason: "udf",
skip: true,
},
{
name: "cramfs image",
fsType: "cramfs",
totalBytes: 128 * 1024 * 1024,
usedBytes: 128 * 1024 * 1024,
reason: "cramfs",
skip: true,
},
{
name: "romfs firmware partition",
fsType: "romfs",
totalBytes: 16 * 1024 * 1024,
usedBytes: 16 * 1024 * 1024,
reason: "romfs",
skip: true,
},
{
name: "fuse iso image",
fsType: "fuse.cdfs",
totalBytes: 700 * 1024 * 1024,
usedBytes: 700 * 1024 * 1024,
reason: "cdfs",
skip: true,
},
{ {
name: "overlay below capacity", name: "overlay below capacity",
fsType: "overlay", fsType: "overlay",