Skip to content

Commit

Permalink
Ignore filesystems flagged as MNT_IGNORE. (#2227)
Browse files Browse the repository at this point in the history
* Ignore filesystems flagges as MNT_IGNORE.
Closes #2152.

Signed-off-by: Lapo Luchini <lapo@lapo.it>
  • Loading branch information
lapo-luchini authored Dec 1, 2021
1 parent 1d5afd0 commit 3136901
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions collector/filesystem_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ import (
const (
defMountPointsExcluded = "^/(dev)($|/)"
defFSTypesExcluded = "^devfs$"
readOnly = 0x1 // MNT_RDONLY
noWait = 0x2 // MNT_NOWAIT
)

// Expose filesystem fullness.
func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
n, err := unix.Getfsstat(nil, noWait)
n, err := unix.Getfsstat(nil, unix.MNT_NOWAIT)
if err != nil {
return nil, err
}
buf := make([]unix.Statfs_t, n)
_, err = unix.Getfsstat(buf, noWait)
_, err = unix.Getfsstat(buf, unix.MNT_NOWAIT)
if err != nil {
return nil, err
}
Expand All @@ -54,8 +52,13 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
continue
}

if (fs.Flags & unix.MNT_IGNORE) != 0 {
level.Debug(c.logger).Log("msg", "Ignoring mount flagged as ignore", "mountpoint", mountpoint)
continue
}

var ro float64
if (fs.Flags & readOnly) != 0 {
if (fs.Flags & unix.MNT_RDONLY) != 0 {
ro = 1
}

Expand Down

0 comments on commit 3136901

Please sign in to comment.