mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 03:20:11 +00:00
Ignore read-only guest filesystems in disk aggregation
This commit is contained in:
parent
261bd7ac74
commit
78889ffedc
3 changed files with 68 additions and 18 deletions
|
|
@ -243,7 +243,7 @@ The agent reports all mounted filesystems. Pulse automatically filters out:
|
|||
- Special filesystems (proc, sys, tmpfs, devtmpfs, etc.)
|
||||
- Special Windows partitions ("System Reserved")
|
||||
- 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.
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,19 @@ package monitoring
|
|||
|
||||
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
|
||||
// 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
|
||||
|
|
@ -14,23 +27,12 @@ func readOnlyFilesystemReason(fsType string, totalBytes, usedBytes uint64) (stri
|
|||
}
|
||||
|
||||
// Common read-only filesystem types used for immutable system partitions.
|
||||
if strings.Contains(ft, "erofs") {
|
||||
return "erofs", true
|
||||
}
|
||||
if strings.Contains(ft, "squashfs") || strings.Contains(ft, "squash-fs") {
|
||||
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
|
||||
for _, pattern := range readOnlyFilesystemPatterns {
|
||||
for _, needle := range pattern.substrings {
|
||||
if strings.Contains(ft, needle) {
|
||||
return pattern.reason, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Overlay-style filesystems can report 100% usage even though writes are
|
||||
|
|
|
|||
|
|
@ -51,6 +51,54 @@ func TestReadOnlyFilesystemReason(t *testing.T) {
|
|||
reason: "squashfs",
|
||||
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",
|
||||
fsType: "overlay",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue