|
|
@ -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
|
|
|
|