aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid O'Rourke <david.orourke@gmail.com>2020-06-02 12:07:09 +0100
committerJohannes 'fish' Ziemke <github@freigeist.org>2020-06-03 11:33:10 +0200
commit03450a4d7ddb96145a72cffc6029b99751bedc7a (patch)
tree4a488ec2cff3708f54ebb1d57d21262ce13d71db
parentd6fbce15293500b62ac6560df303d92f1e2cf69f (diff)
downloadprometheus_node_collector-03450a4d7ddb96145a72cffc6029b99751bedc7a.tar.bz2
prometheus_node_collector-03450a4d7ddb96145a72cffc6029b99751bedc7a.tar.xz
prometheus_node_collector-03450a4d7ddb96145a72cffc6029b99751bedc7a.zip
filesystem_freebsd: Use bytesToString to get label values
Signed-off-by: David O'Rourke <david.orourke@gmail.com>
-rw-r--r--collector/filesystem_freebsd.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/collector/filesystem_freebsd.go b/collector/filesystem_freebsd.go
index 8bc8314..1d377b1 100644
--- a/collector/filesystem_freebsd.go
+++ b/collector/filesystem_freebsd.go
@@ -16,8 +16,6 @@
16package collector 16package collector
17 17
18import ( 18import (
19 "bytes"
20
21 "github.com/go-kit/kit/log/level" 19 "github.com/go-kit/kit/log/level"
22 "golang.org/x/sys/unix" 20 "golang.org/x/sys/unix"
23) 21)
@@ -42,19 +40,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
42 } 40 }
43 stats := []filesystemStats{} 41 stats := []filesystemStats{}
44 for _, fs := range buf { 42 for _, fs := range buf {
45 // We need to work out the lengths of the actual strings here, 43 mountpoint := bytesToString(fs.Mntonname[:])
46 // otherwuse we will end up with null bytes in our label values.
47 mountpoint_len := bytes.Index(fs.Mntonname[:], []byte{0})
48 mountpoint := string(fs.Mntonname[:mountpoint_len])
49 if c.ignoredMountPointsPattern.MatchString(mountpoint) { 44 if c.ignoredMountPointsPattern.MatchString(mountpoint) {
50 level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint) 45 level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint)
51 continue 46 continue
52 } 47 }
53 48
54 device_len := bytes.Index(fs.Mntfromname[:], []byte{0}) 49 device := bytesToString(fs.Mntfromname[:])
55 fstype_len := bytes.Index(fs.Fstypename[:], []byte{0}) 50 fstype := bytesToString(fs.Fstypename[:])
56 device := string(fs.Mntfromname[:device_len])
57 fstype := string(fs.Fstypename[:fstype_len])
58 if c.ignoredFSTypesPattern.MatchString(fstype) { 51 if c.ignoredFSTypesPattern.MatchString(fstype) {
59 level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype) 52 level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype)
60 continue 53 continue