diff options
author | Ben Kochie <superq@gmail.com> | 2020-05-14 20:52:48 +0200 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2020-05-14 21:02:21 +0200 |
commit | b532c81da7854036f6ea6c971a020b4025b7cb34 (patch) | |
tree | 9cdcaee3799fad1e793120281cc72a54d99c0a5f /collector | |
parent | cdb9e7d2b89a8e0e4a64bad8af34fd146eb888ab (diff) | |
download | prometheus_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.go | 18 |
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 @@ | |||
16 | package collector | 16 | package collector |
17 | 17 | ||
18 | import ( | 18 | import ( |
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 | ||
33 | func 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. |
43 | func (c *filesystemCollector) GetStats() ([]filesystemStats, error) { | 31 | func (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 |