aboutsummaryrefslogtreecommitdiff
path: root/collector/filesystem_linux.go
diff options
context:
space:
mode:
authorWill Rouesnel <w.rouesnel@gmail.com>2015-11-10 19:25:04 +1100
committerWilliam Rouesnel <William.Rouesnel@netregistry.com.au>2015-11-12 14:11:07 +1100
commit05539ee156c854ae172c509e5b6e221185cf866d (patch)
tree2ca5b4dde9f466a7d59e00984aba0b6aced160d7 /collector/filesystem_linux.go
parent7eb7917eeaa502032a91d52830148826a9080bed (diff)
downloadprometheus_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_linux.go')
-rw-r--r--collector/filesystem_linux.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go
index 847cc5c..7fafcfb 100644
--- a/collector/filesystem_linux.go
+++ b/collector/filesystem_linux.go
@@ -26,6 +26,7 @@ import (
26 26
27const ( 27const (
28 defIgnoredMountPoints = "^/(sys|proc|dev)($|/)" 28 defIgnoredMountPoints = "^/(sys|proc|dev)($|/)"
29 ST_RDONLY = 0x1
29) 30)
30 31
31type filesystemDetails struct { 32type filesystemDetails struct {
@@ -54,6 +55,11 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {
54 continue 55 continue
55 } 56 }
56 57
58 var ro float64
59 if buf.Flags & ST_RDONLY != 0 {
60 ro = 1
61 }
62
57 labelValues := []string{mpd.device, mpd.mountPoint, mpd.fsType} 63 labelValues := []string{mpd.device, mpd.mountPoint, mpd.fsType}
58 stats = append(stats, filesystemStats{ 64 stats = append(stats, filesystemStats{
59 labelValues: labelValues, 65 labelValues: labelValues,
@@ -62,6 +68,7 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {
62 avail: float64(buf.Bavail) * float64(buf.Bsize), 68 avail: float64(buf.Bavail) * float64(buf.Bsize),
63 files: float64(buf.Files), 69 files: float64(buf.Files),
64 filesFree: float64(buf.Ffree), 70 filesFree: float64(buf.Ffree),
71 ro: ro,
65 }) 72 })
66 } 73 }
67 return stats, nil 74 return stats, nil