diff options
author | Will Rouesnel <w.rouesnel@gmail.com> | 2015-11-10 19:25:04 +1100 |
---|---|---|
committer | William Rouesnel <William.Rouesnel@netregistry.com.au> | 2015-11-12 14:11:07 +1100 |
commit | 05539ee156c854ae172c509e5b6e221185cf866d (patch) | |
tree | 2ca5b4dde9f466a7d59e00984aba0b6aced160d7 /collector/filesystem_bsd.go | |
parent | 7eb7917eeaa502032a91d52830148826a9080bed (diff) | |
download | prometheus_node_collector-05539ee156c854ae172c509e5b6e221185cf866d.tar.bz2 prometheus_node_collector-05539ee156c854ae172c509e5b6e221185cf866d.tar.xz prometheus_node_collector-05539ee156c854ae172c509e5b6e221185cf866d.zip |
Add filesystem read-only metric node_filesystem_readonly
This is a boolean metric which is set to 1 when the filesystem is flagged as
read-only.
Diffstat (limited to 'collector/filesystem_bsd.go')
-rw-r--r-- | collector/filesystem_bsd.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/collector/filesystem_bsd.go b/collector/filesystem_bsd.go index 6aefb01..9daa899 100644 --- a/collector/filesystem_bsd.go +++ b/collector/filesystem_bsd.go | |||
@@ -33,6 +33,7 @@ import "C" | |||
33 | 33 | ||
34 | const ( | 34 | const ( |
35 | defIgnoredMountPoints = "^/(dev)($|/)" | 35 | defIgnoredMountPoints = "^/(dev)($|/)" |
36 | MNT_RDONLY = 0x1 | ||
36 | ) | 37 | ) |
37 | 38 | ||
38 | // Expose filesystem fullness. | 39 | // Expose filesystem fullness. |
@@ -55,6 +56,11 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { | |||
55 | device := C.GoString(&mnt[i].f_mntfromname[0]) | 56 | device := C.GoString(&mnt[i].f_mntfromname[0]) |
56 | fstype := C.GoString(&mnt[i].f_fstypename[0]) | 57 | fstype := C.GoString(&mnt[i].f_fstypename[0]) |
57 | 58 | ||
59 | var ro float64 | ||
60 | if mnt[i].f_flags & MNT_RDONLY { | ||
61 | ro = 1 | ||
62 | } | ||
63 | |||
58 | labelValues := []string{device, mountpoint, fstype} | 64 | labelValues := []string{device, mountpoint, fstype} |
59 | stats = append(stats, filesystemStats{ | 65 | stats = append(stats, filesystemStats{ |
60 | labelValues: labelValues, | 66 | labelValues: labelValues, |
@@ -63,6 +69,7 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { | |||
63 | avail: float64(mnt[i].f_bavail) * float64(mnt[i].f_bsize), | 69 | avail: float64(mnt[i].f_bavail) * float64(mnt[i].f_bsize), |
64 | files: float64(mnt[i].f_files), | 70 | files: float64(mnt[i].f_files), |
65 | filesFree: float64(mnt[i].f_ffree), | 71 | filesFree: float64(mnt[i].f_ffree), |
72 | ro: ro, | ||
66 | }) | 73 | }) |
67 | } | 74 | } |
68 | return stats, nil | 75 | return stats, nil |