Ignore filesystems flagged as MNT_IGNORE. (#2227)
* Ignore filesystems flagges as MNT_IGNORE. Closes #2152. Signed-off-by: Lapo Luchini <lapo@lapo.it>
This commit is contained in:
parent
6af0c6306a
commit
8433364845
|
@ -24,18 +24,16 @@ import (
|
||||||
const (
|
const (
|
||||||
defMountPointsExcluded = "^/(dev)($|/)"
|
defMountPointsExcluded = "^/(dev)($|/)"
|
||||||
defFSTypesExcluded = "^devfs$"
|
defFSTypesExcluded = "^devfs$"
|
||||||
readOnly = 0x1 // MNT_RDONLY
|
|
||||||
noWait = 0x2 // MNT_NOWAIT
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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, unix.MNT_NOWAIT)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
buf := make([]unix.Statfs_t, n)
|
buf := make([]unix.Statfs_t, n)
|
||||||
_, err = unix.Getfsstat(buf, noWait)
|
_, err = unix.Getfsstat(buf, unix.MNT_NOWAIT)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -54,8 +52,13 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
|
||||||
continue
|
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
|
var ro float64
|
||||||
if (fs.Flags & readOnly) != 0 {
|
if (fs.Flags & unix.MNT_RDONLY) != 0 {
|
||||||
ro = 1
|
ro = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue