-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filesystems monitor: Strip mountpoint dim properly (#1190)
If there is a hostFSPath configured and the mountpoint is the root of that path, insert a / after the stripping out of the hostFSPath. Also add doc about migrating from collectd/df.
- Loading branch information
1 parent
68449db
commit 52b2ecd
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package filesystems | ||
|
||
import ( | ||
"testing" | ||
|
||
gopsutil "github.com/shirou/gopsutil/disk" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCommonDimensions(t *testing.T) { | ||
cases := []struct { | ||
hostFSPath string | ||
ps *gopsutil.PartitionStat | ||
expectedDims map[string]string | ||
}{ | ||
{ | ||
hostFSPath: "/hostfs", | ||
ps: &gopsutil.PartitionStat{ | ||
Device: "/dev/sdb1", | ||
Mountpoint: "/hostfs/var/lib", | ||
Fstype: "ext4", | ||
}, | ||
expectedDims: map[string]string{ | ||
"mountpoint": "/var/lib", | ||
"device": "/dev/sdb1", | ||
"fs_type": "ext4", | ||
}, | ||
}, | ||
{ | ||
hostFSPath: "/hostfs", | ||
ps: &gopsutil.PartitionStat{ | ||
Device: "/dev/sdb1", | ||
Mountpoint: "/hostfs", | ||
Fstype: "ext4", | ||
}, | ||
expectedDims: map[string]string{ | ||
"mountpoint": "/", | ||
"device": "/dev/sdb1", | ||
"fs_type": "ext4", | ||
}, | ||
}, | ||
{ | ||
hostFSPath: "", | ||
ps: &gopsutil.PartitionStat{ | ||
Device: "/dev/sdb1", | ||
Mountpoint: "/", | ||
Fstype: "ext4", | ||
}, | ||
expectedDims: map[string]string{ | ||
"mountpoint": "/", | ||
"device": "/dev/sdb1", | ||
"fs_type": "ext4", | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range cases { | ||
m := Monitor{ | ||
hostFSPath: tt.hostFSPath, | ||
} | ||
|
||
dims := m.getCommonDimensions(tt.ps) | ||
|
||
assert.Equal(t, tt.expectedDims, dims) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters