From ebf3ef32f1f433ba8014e609118685f9847a2c04 Mon Sep 17 00:00:00 2001 From: Nick Owens Date: Sun, 1 Nov 2015 19:25:21 -0800 Subject: [PATCH] collector: sync bsd filesystem collector labels with linux --- collector/filesystem_bsd.go | 15 +++++++-------- collector/filesystem_common.go | 2 ++ collector/filesystem_linux.go | 4 ---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/collector/filesystem_bsd.go b/collector/filesystem_bsd.go index c78a6549..6aefb015 100644 --- a/collector/filesystem_bsd.go +++ b/collector/filesystem_bsd.go @@ -35,10 +35,6 @@ const ( defIgnoredMountPoints = "^/(dev)($|/)" ) -var ( - filesystemLabelNames = []string{"filesystem"} -) - // Expose filesystem fullness. func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { var mntbuf *C.struct_statfs @@ -50,13 +46,16 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { mnt := (*[1 << 30]C.struct_statfs)(unsafe.Pointer(mntbuf)) stats = []filesystemStats{} for i := 0; i < int(count); i++ { - name := C.GoString(&mnt[i].f_mntonname[0]) - if c.ignoredMountPointsPattern.MatchString(name) { - log.Debugf("Ignoring mount point: %s", name) + mountpoint := C.GoString(&mnt[i].f_mntonname[0]) + if c.ignoredMountPointsPattern.MatchString(mountpoint) { + log.Debugf("Ignoring mount point: %s", mountpoint) continue } - labelValues := []string{name} + device := C.GoString(&mnt[i].f_mntfromname[0]) + fstype := C.GoString(&mnt[i].f_fstypename[0]) + + labelValues := []string{device, mountpoint, fstype} stats = append(stats, filesystemStats{ labelValues: labelValues, size: float64(mnt[i].f_blocks) * float64(mnt[i].f_bsize), diff --git a/collector/filesystem_common.go b/collector/filesystem_common.go index 77c24847..35536951 100644 --- a/collector/filesystem_common.go +++ b/collector/filesystem_common.go @@ -33,6 +33,8 @@ var ( "collector.filesystem.ignored-mount-points", defIgnoredMountPoints, "Regexp of mount points to ignore for filesystem collector.") + + filesystemLabelNames = []string{"device", "mountpoint", "fstype"} ) type filesystemCollector struct { diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 3610668f..847cc5c6 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -28,10 +28,6 @@ const ( defIgnoredMountPoints = "^/(sys|proc|dev)($|/)" ) -var ( - filesystemLabelNames = []string{"device", "mountpoint", "fstype"} -) - type filesystemDetails struct { device string mountPoint string