From 10df0a99a9feba75128b749984ab50612f8ab406 Mon Sep 17 00:00:00 2001 From: skartikey <1942366+skartikey@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:13:01 +0000 Subject: [PATCH 1/2] fix(inputs.disk): preserve device tag for virtual filesystems gopsutil v4.26.1 changed disk.Partitions() to return "none" as the device for virtual filesystems (tmpfs, sysfs, etc.) instead of the mount source name. Fall back to the filesystem type when the device is "none" or empty to maintain backwards compatibility. --- plugins/inputs/disk/disk.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/inputs/disk/disk.go b/plugins/inputs/disk/disk.go index 66199f7ee5be7..0827c5bda62f0 100644 --- a/plugins/inputs/disk/disk.go +++ b/plugins/inputs/disk/disk.go @@ -49,6 +49,9 @@ func (ds *Disk) Gather(acc telegraf.Accumulator) error { } device := partitions[i].Device + if device == "none" || device == "" { + device = partitions[i].Fstype + } mountOpts := mountOptions(partitions[i].Opts) tags := map[string]string{ "path": du.Path, From 610cd70b92d5181313b8f22df01dd2e3e4094cfc Mon Sep 17 00:00:00 2001 From: skartikey <1942366+skartikey@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:18:34 +0000 Subject: [PATCH 2/2] test(inputs.disk): add tests for device tag fallback on virtual filesystems Cover both "none" and empty device name cases to verify that the fstype fallback preserves backwards compatibility with gopsutil v4.26.1. --- plugins/inputs/disk/disk_test.go | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/plugins/inputs/disk/disk_test.go b/plugins/inputs/disk/disk_test.go index 3df6af86bba95..2e2f7b65fbe81 100644 --- a/plugins/inputs/disk/disk_test.go +++ b/plugins/inputs/disk/disk_test.go @@ -273,6 +273,72 @@ func TestDiskUsageHostMountPrefix(t *testing.T) { "inodes_used_percent": float64(0), }, }, + { + name: "virtual filesystem with none device", + partitionStats: []disk.PartitionStat{ + { + Device: "none", + Mountpoint: "/tmp", + Fstype: "tmpfs", + Opts: []string{"rw"}, + }, + }, + usageStats: []*disk.UsageStat{ + { + Path: "/tmp", + Total: 42, + }, + }, + expectedTags: map[string]string{ + "path": fmt.Sprintf("%ctmp", os.PathSeparator), + "device": "tmpfs", + "fstype": "tmpfs", + "mode": "rw", + }, + expectedFields: map[string]interface{}{ + "total": uint64(42), + "used": uint64(0), + "free": uint64(0), + "inodes_total": uint64(0), + "inodes_free": uint64(0), + "inodes_used": uint64(0), + "used_percent": float64(0), + "inodes_used_percent": float64(0), + }, + }, + { + name: "virtual filesystem with empty device", + partitionStats: []disk.PartitionStat{ + { + Device: "", + Mountpoint: "/sys", + Fstype: "sysfs", + Opts: []string{"ro"}, + }, + }, + usageStats: []*disk.UsageStat{ + { + Path: "/sys", + Total: 42, + }, + }, + expectedTags: map[string]string{ + "path": fmt.Sprintf("%csys", os.PathSeparator), + "device": "sysfs", + "fstype": "sysfs", + "mode": "ro", + }, + expectedFields: map[string]interface{}{ + "total": uint64(42), + "used": uint64(0), + "free": uint64(0), + "inodes_total": uint64(0), + "inodes_free": uint64(0), + "inodes_used": uint64(0), + "used_percent": float64(0), + "inodes_used_percent": float64(0), + }, + }, } for _, tt := range tests {