Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugins/inputs/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
66 changes: 66 additions & 0 deletions plugins/inputs/disk/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading