Update filesystem freebsd

Upstream x/sys/unix changed types.

Signed-off-by: Ben Kochie <superq@gmail.com>
pull/1705/head
Ben Kochie 5 years ago
parent cdb9e7d2b8
commit b532c81da7
No known key found for this signature in database
GPG Key ID: C646B23C9E3245F1

@ -16,9 +16,6 @@
package collector package collector
import ( import (
"bytes"
"unsafe"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -30,15 +27,6 @@ const (
noWait = 0x2 // MNT_NOWAIT noWait = 0x2 // MNT_NOWAIT
) )
func gostring(b []int8) string {
bb := *(*[]byte)(unsafe.Pointer(&b))
idx := bytes.IndexByte(bb, 0)
if idx < 0 {
return ""
}
return string(bb[:idx])
}
// Expose filesystem fullness. // Expose filesystem fullness.
func (c *filesystemCollector) GetStats() ([]filesystemStats, error) { func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
n, err := unix.Getfsstat(nil, noWait) n, err := unix.Getfsstat(nil, noWait)
@ -52,14 +40,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
} }
stats := []filesystemStats{} stats := []filesystemStats{}
for _, fs := range buf { for _, fs := range buf {
mountpoint := gostring(fs.Mntonname[:]) mountpoint := string(fs.Mntonname[:])
if c.ignoredMountPointsPattern.MatchString(mountpoint) { if c.ignoredMountPointsPattern.MatchString(mountpoint) {
level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint) level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint)
continue continue
} }
device := gostring(fs.Mntfromname[:]) device := string(fs.Mntfromname[:])
fstype := gostring(fs.Fstypename[:]) fstype := string(fs.Fstypename[:])
if c.ignoredFSTypesPattern.MatchString(fstype) { if c.ignoredFSTypesPattern.MatchString(fstype) {
level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype) level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype)
continue continue

Loading…
Cancel
Save