summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/prometheus/procfs/sysfs
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-06-21 19:06:17 -0700
committerCorey Hulen <corey@hulen.com>2017-06-21 19:06:17 -0700
commit42f28ab8e374137fe3f5d25424489d879d4724f8 (patch)
tree20353f2446b506d32e6d353b72a57bf48f070389 /vendor/github.com/prometheus/procfs/sysfs
parent6b39c308d882a0aeac533f8ab1d90b48a2ae4b5a (diff)
downloadchat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.gz
chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.bz2
chat-42f28ab8e374137fe3f5d25424489d879d4724f8.zip
Updating server dependancies (#6712)
Diffstat (limited to 'vendor/github.com/prometheus/procfs/sysfs')
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/.gitignore1
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fixtures.tar.gzbin0 -> 2865 bytes
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats1
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats1
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fs.go26
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fs_test.go42
6 files changed, 69 insertions, 2 deletions
diff --git a/vendor/github.com/prometheus/procfs/sysfs/.gitignore b/vendor/github.com/prometheus/procfs/sysfs/.gitignore
new file mode 100644
index 000000000..67fc140b9
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/sysfs/.gitignore
@@ -0,0 +1 @@
+fixtures/
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fixtures.tar.gz b/vendor/github.com/prometheus/procfs/sysfs/fixtures.tar.gz
new file mode 100644
index 000000000..88035b7ce
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/sysfs/fixtures.tar.gz
Binary files differ
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats b/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats
deleted file mode 100644
index 0db7520bf..000000000
--- a/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats
+++ /dev/null
@@ -1 +0,0 @@
-extent_alloc 1 0 0 0
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats b/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats
deleted file mode 100644
index 85a038402..000000000
--- a/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats
+++ /dev/null
@@ -1 +0,0 @@
-extent_alloc 2 0 0 0
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fs.go b/vendor/github.com/prometheus/procfs/sysfs/fs.go
index 8e8380083..fb15d438a 100644
--- a/vendor/github.com/prometheus/procfs/sysfs/fs.go
+++ b/vendor/github.com/prometheus/procfs/sysfs/fs.go
@@ -18,6 +18,7 @@ import (
"os"
"path/filepath"
+ "github.com/prometheus/procfs/bcache"
"github.com/prometheus/procfs/xfs"
)
@@ -80,3 +81,28 @@ func (fs FS) XFSStats() ([]*xfs.Stats, error) {
return stats, nil
}
+
+// BcacheStats retrieves bcache runtime statistics for each bcache.
+func (fs FS) BcacheStats() ([]*bcache.Stats, error) {
+ matches, err := filepath.Glob(fs.Path("fs/bcache/*-*"))
+ if err != nil {
+ return nil, err
+ }
+
+ stats := make([]*bcache.Stats, 0, len(matches))
+ for _, uuidPath := range matches {
+ // "*-*" in glob above indicates the name of the bcache.
+ name := filepath.Base(uuidPath)
+
+ // stats
+ s, err := bcache.GetStats(uuidPath)
+ if err != nil {
+ return nil, err
+ }
+
+ s.Name = name
+ stats = append(stats, s)
+ }
+
+ return stats, nil
+}
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fs_test.go b/vendor/github.com/prometheus/procfs/sysfs/fs_test.go
index d7f2b736b..2b7402eca 100644
--- a/vendor/github.com/prometheus/procfs/sysfs/fs_test.go
+++ b/vendor/github.com/prometheus/procfs/sysfs/fs_test.go
@@ -64,3 +64,45 @@ func TestFSXFSStats(t *testing.T) {
}
}
}
+
+func TestFSBcacheStats(t *testing.T) {
+ stats, err := FS("fixtures").BcacheStats()
+ if err != nil {
+ t.Fatalf("failed to parse bcache stats: %v", err)
+ }
+
+ tests := []struct {
+ name string
+ bdevs int
+ caches int
+ }{
+ {
+ name: "deaddd54-c735-46d5-868e-f331c5fd7c74",
+ bdevs: 1,
+ caches: 1,
+ },
+ }
+
+ const expect = 1
+
+ if l := len(stats); l != expect {
+ t.Fatalf("unexpected number of bcache stats: %d", l)
+ }
+ if l := len(tests); l != expect {
+ t.Fatalf("unexpected number of tests: %d", l)
+ }
+
+ for i, tt := range tests {
+ if want, got := tt.name, stats[i].Name; want != got {
+ t.Errorf("unexpected stats name:\nwant: %q\nhave: %q", want, got)
+ }
+
+ if want, got := tt.bdevs, len(stats[i].Bdevs); want != got {
+ t.Errorf("unexpected value allocated:\nwant: %d\nhave: %d", want, got)
+ }
+
+ if want, got := tt.caches, len(stats[i].Caches); want != got {
+ t.Errorf("unexpected value allocated:\nwant: %d\nhave: %d", want, got)
+ }
+ }
+}