aboutsummaryrefslogtreecommitdiff
path: root/collector
diff options
context:
space:
mode:
authorBen Kochie <superq@gmail.com>2020-05-14 20:52:48 +0200
committerBen Kochie <superq@gmail.com>2020-05-14 21:02:21 +0200
commitb532c81da7854036f6ea6c971a020b4025b7cb34 (patch)
tree9cdcaee3799fad1e793120281cc72a54d99c0a5f /collector
parentcdb9e7d2b89a8e0e4a64bad8af34fd146eb888ab (diff)
downloadprometheus_node_collector-b532c81da7854036f6ea6c971a020b4025b7cb34.tar.bz2
prometheus_node_collector-b532c81da7854036f6ea6c971a020b4025b7cb34.tar.xz
prometheus_node_collector-b532c81da7854036f6ea6c971a020b4025b7cb34.zip
Update filesystem freebsd
Upstream x/sys/unix changed types. Signed-off-by: Ben Kochie <superq@gmail.com>
Diffstat (limited to 'collector')
-rw-r--r--collector/filesystem_freebsd.go18
1 files changed, 3 insertions, 15 deletions
diff --git a/collector/filesystem_freebsd.go b/collector/filesystem_freebsd.go
index 8fceba7..f37029e 100644
--- a/collector/filesystem_freebsd.go
+++ b/collector/filesystem_freebsd.go
@@ -16,9 +16,6 @@
16package collector 16package collector
17 17
18import ( 18import (
19 "bytes"
20 "unsafe"
21
22 "github.com/go-kit/kit/log/level" 19 "github.com/go-kit/kit/log/level"
23 "golang.org/x/sys/unix" 20 "golang.org/x/sys/unix"
24) 21)
@@ -30,15 +27,6 @@ const (
30 noWait = 0x2 // MNT_NOWAIT 27 noWait = 0x2 // MNT_NOWAIT
31) 28)
32 29
33func gostring(b []int8) string {
34 bb := *(*[]byte)(unsafe.Pointer(&b))
35 idx := bytes.IndexByte(bb, 0)
36 if idx < 0 {
37 return ""
38 }
39 return string(bb[:idx])
40}
41
42// Expose filesystem fullness. 30// Expose filesystem fullness.
43func (c *filesystemCollector) GetStats() ([]filesystemStats, error) { 31func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
44 n, err := unix.Getfsstat(nil, noWait) 32 n, err := unix.Getfsstat(nil, noWait)
@@ -52,14 +40,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
52 } 40 }
53 stats := []filesystemStats{} 41 stats := []filesystemStats{}
54 for _, fs := range buf { 42 for _, fs := range buf {
55 mountpoint := gostring(fs.Mntonname[:]) 43 mountpoint := string(fs.Mntonname[:])
56 if c.ignoredMountPointsPattern.MatchString(mountpoint) { 44 if c.ignoredMountPointsPattern.MatchString(mountpoint) {
57 level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint) 45 level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint)
58 continue 46 continue
59 } 47 }
60 48
61 device := gostring(fs.Mntfromname[:]) 49 device := string(fs.Mntfromname[:])
62 fstype := gostring(fs.Fstypename[:]) 50 fstype := string(fs.Fstypename[:])
63 if c.ignoredFSTypesPattern.MatchString(fstype) { 51 if c.ignoredFSTypesPattern.MatchString(fstype) {
64 level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype) 52 level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype)
65 continue 53 continue