Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Skip numbered block-device partitions in disk I/O
pulse-triage[bot]ab556fc21261
diff --git a/internal/hostmetrics/collector.go b/internal/hostmetrics/collector.goindex c82db8dc5b..f7d6977457 100644--- a/internal/hostmetrics/collector.go+++ b/internal/hostmetrics/collector.go@@ -519,18 +519,25 @@ func collectDiskIO(ctx context.Context, diskExclude []string) []agentshost.DiskI}// isPartition returns true if the device name looks like a partition-// e.g., sda1, nvme0n1p1, vda2+// e.g., sda1, nvme0n1p1, mmcblk0p1, vda2. Devices whose whole-disk name+// already ends in a digit use a p<partition-number> suffix; treating only+// NVMe that way lets the parent and partitions of MMC, MD, and persistent+// memory devices through and double-counts their kernel I/O counters.func isPartition(name string) bool {- // NVMe partitions: nvme0n1p1, nvme0n1p2- if strings.Contains(name, "n") && strings.Contains(name, "p") {- // Check if it ends with pN where N is a digit- idx := strings.LastIndex(name, "p")- if idx > 0 && idx < len(name)-1 {- rest := name[idx+1:]- if len(rest) > 0 && rest[0] >= '0' && rest[0] <= '9' {- return true+ // Whole-device names ending in a digit separate their partition number+ // with "p": nvme0n1p1, mmcblk0p1, md0p1, pmem0p1, and zd0p1.+ if idx := strings.LastIndexByte(name, 'p'); idx > 0 && idx < len(name)-1 && name[idx-1] >= '0' && name[idx-1] <= '9' {+ partitionNumber := name[idx+1:]+ allDigits := true+ for i := 0; i < len(partitionNumber); i++ {+ if partitionNumber[i] < '0' || partitionNumber[i] > '9' {+ allDigits = false+ break}}+ if allDigits {+ return true+ }}// Traditional partitions: sda1, vda2, hda1if len(name) > 2 {@@ -547,9 +554,5 @@ func isPartition(name string) bool {}}}- // ZFS devices: zd0p1, zd16p1- if strings.HasPrefix(name, "zd") && strings.Contains(name, "p") {- return true- }return false}diff --git a/internal/hostmetrics/coverage_additional_test.go b/internal/hostmetrics/coverage_additional_test.goindex c44c30e22e..8d579913ce 100644--- a/internal/hostmetrics/coverage_additional_test.go+++ b/internal/hostmetrics/coverage_additional_test.go@@ -184,6 +184,9 @@ func TestCollectDiskIOFiltersAndError(t *testing.T) {"sda1": {ReadBytes: 2},"nvme0n1": {ReadBytes: 3},"nvme0n1p1": {ReadBytes: 4},+ "mmcblk0": {ReadBytes: 17},+ "mmcblk0p1": {ReadBytes: 18},+ "md0p1": {ReadBytes: 19},"xvda10": {ReadBytes: 5},"loop0": {ReadBytes: 6},"ram0": {ReadBytes: 7},@@ -205,15 +208,15 @@ func TestCollectDiskIOFiltersAndError(t *testing.T) {}disks := collectDiskIO(context.Background(), []string{"sdb"})- if len(disks) != 5 {- t.Fatalf("expected 5 disk I/O entries after filtering, got %d: %+v", len(disks), disks)+ if len(disks) != 6 {+ t.Fatalf("expected 6 disk I/O entries after filtering, got %d: %+v", len(disks), disks)}gotDevices := make([]string, 0, len(disks))for _, disk := range disks {gotDevices = append(gotDevices, disk.Device)}- wantDevices := []string{"md0", "nvme0n1", "sda", "vda", "xvda"}+ wantDevices := []string{"md0", "mmcblk0", "nvme0n1", "sda", "vda", "xvda"}if !reflect.DeepEqual(gotDevices, wantDevices) {t.Fatalf("unexpected disk I/O devices: got %v, want %v", gotDevices, wantDevices)}@@ -237,8 +240,13 @@ func TestIsPartitionPatterns(t *testing.T) {{name: "virtio partition", device: "vda2", want: true},{name: "xen partition", device: "xvda12", want: true},{name: "nvme partition", device: "nvme0n1p1", want: true},+ {name: "mmc partition", device: "mmcblk0p1", want: true},+ {name: "md partition", device: "md0p1", want: true},+ {name: "persistent memory partition", device: "pmem0p2", want: true},{name: "zfs zd partition", device: "zd16p1", want: true},{name: "md whole device", device: "md0", want: false},+ {name: "mmc whole device", device: "mmcblk0", want: false},+ {name: "persistent memory whole device", device: "pmem0", want: false},{name: "loop device", device: "loop0", want: false},{name: "nvme whole device", device: "nvme0n1", want: false},{name: "traditional whole disk", device: "sda", want: false},