summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/prometheus/procfs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/prometheus/procfs')
-rw-r--r--vendor/github.com/prometheus/procfs/AUTHORS.md21
-rw-r--r--vendor/github.com/prometheus/procfs/CONTRIBUTING.md6
-rw-r--r--vendor/github.com/prometheus/procfs/MAINTAINERS.md1
-rw-r--r--vendor/github.com/prometheus/procfs/README.md1
-rw-r--r--vendor/github.com/prometheus/procfs/buddyinfo.go95
-rw-r--r--vendor/github.com/prometheus/procfs/buddyinfo_test.go64
-rw-r--r--vendor/github.com/prometheus/procfs/fixtures/buddyinfo/short/buddyinfo3
-rw-r--r--vendor/github.com/prometheus/procfs/fixtures/buddyinfo/sizemismatch/buddyinfo3
-rw-r--r--vendor/github.com/prometheus/procfs/fixtures/buddyinfo/valid/buddyinfo3
-rw-r--r--vendor/github.com/prometheus/procfs/fixtures/fs/xfs/stat23
-rw-r--r--vendor/github.com/prometheus/procfs/fs.go13
-rw-r--r--vendor/github.com/prometheus/procfs/fs_test.go13
-rw-r--r--vendor/github.com/prometheus/procfs/ipvs_test.go16
-rw-r--r--vendor/github.com/prometheus/procfs/mdstat_test.go14
-rw-r--r--vendor/github.com/prometheus/procfs/mountstats.go4
-rw-r--r--vendor/github.com/prometheus/procfs/mountstats_test.go9
-rw-r--r--vendor/github.com/prometheus/procfs/xfs/parse.go361
-rw-r--r--vendor/github.com/prometheus/procfs/xfs/parse_test.go446
-rw-r--r--vendor/github.com/prometheus/procfs/xfs/xfs.go158
19 files changed, 1207 insertions, 47 deletions
diff --git a/vendor/github.com/prometheus/procfs/AUTHORS.md b/vendor/github.com/prometheus/procfs/AUTHORS.md
deleted file mode 100644
index d55863560..000000000
--- a/vendor/github.com/prometheus/procfs/AUTHORS.md
+++ /dev/null
@@ -1,21 +0,0 @@
-The Prometheus project was started by Matt T. Proud (emeritus) and
-Julius Volz in 2012.
-
-Maintainers of this repository:
-
-* Tobias Schmidt <ts@soundcloud.com>
-
-The following individuals have contributed code to this repository
-(listed in alphabetical order):
-
-* Armen Baghumian <abaghumian@noggin.com.au>
-* Bjoern Rabenstein <beorn@soundcloud.com>
-* David Cournapeau <cournape@gmail.com>
-* Ji-Hoon, Seol <jihoon.seol@gmail.com>
-* Jonas Große Sundrup <cherti@letopolis.de>
-* Julius Volz <julius.volz@gmail.com>
-* Matt Layher <mdlayher@gmail.com>
-* Matthias Rampke <mr@soundcloud.com>
-* Nicky Gerritsen <nicky@streamone.nl>
-* Rémi Audebert <contact@halfr.net>
-* Tobias Schmidt <tobidt@gmail.com>
diff --git a/vendor/github.com/prometheus/procfs/CONTRIBUTING.md b/vendor/github.com/prometheus/procfs/CONTRIBUTING.md
index 5705f0fbe..40503edbf 100644
--- a/vendor/github.com/prometheus/procfs/CONTRIBUTING.md
+++ b/vendor/github.com/prometheus/procfs/CONTRIBUTING.md
@@ -2,9 +2,9 @@
Prometheus uses GitHub to manage reviews of pull requests.
-* If you have a trivial fix or improvement, go ahead and create a pull
- request, addressing (with `@...`) one or more of the maintainers
- (see [AUTHORS.md](AUTHORS.md)) in the description of the pull request.
+* If you have a trivial fix or improvement, go ahead and create a pull request,
+ addressing (with `@...`) the maintainer of this repository (see
+ [MAINTAINERS.md](MAINTAINERS.md)) in the description of the pull request.
* If you plan to do something more involved, first discuss your ideas
on our [mailing list](https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers).
diff --git a/vendor/github.com/prometheus/procfs/MAINTAINERS.md b/vendor/github.com/prometheus/procfs/MAINTAINERS.md
new file mode 100644
index 000000000..35993c41c
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/MAINTAINERS.md
@@ -0,0 +1 @@
+* Tobias Schmidt <tobidt@gmail.com>
diff --git a/vendor/github.com/prometheus/procfs/README.md b/vendor/github.com/prometheus/procfs/README.md
index 6e7ee6b8b..209549471 100644
--- a/vendor/github.com/prometheus/procfs/README.md
+++ b/vendor/github.com/prometheus/procfs/README.md
@@ -8,3 +8,4 @@ backwards-incompatible ways without warnings. Use it at your own risk.
[![GoDoc](https://godoc.org/github.com/prometheus/procfs?status.png)](https://godoc.org/github.com/prometheus/procfs)
[![Build Status](https://travis-ci.org/prometheus/procfs.svg?branch=master)](https://travis-ci.org/prometheus/procfs)
+[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/procfs)](https://goreportcard.com/report/github.com/prometheus/procfs)
diff --git a/vendor/github.com/prometheus/procfs/buddyinfo.go b/vendor/github.com/prometheus/procfs/buddyinfo.go
new file mode 100644
index 000000000..680a9842a
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/buddyinfo.go
@@ -0,0 +1,95 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package procfs
+
+import (
+ "bufio"
+ "fmt"
+ "io"
+ "os"
+ "strconv"
+ "strings"
+)
+
+// A BuddyInfo is the details parsed from /proc/buddyinfo.
+// The data is comprised of an array of free fragments of each size.
+// The sizes are 2^n*PAGE_SIZE, where n is the array index.
+type BuddyInfo struct {
+ Node string
+ Zone string
+ Sizes []float64
+}
+
+// NewBuddyInfo reads the buddyinfo statistics.
+func NewBuddyInfo() ([]BuddyInfo, error) {
+ fs, err := NewFS(DefaultMountPoint)
+ if err != nil {
+ return nil, err
+ }
+
+ return fs.NewBuddyInfo()
+}
+
+// NewBuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem.
+func (fs FS) NewBuddyInfo() ([]BuddyInfo, error) {
+ file, err := os.Open(fs.Path("buddyinfo"))
+ if err != nil {
+ return nil, err
+ }
+ defer file.Close()
+
+ return parseBuddyInfo(file)
+}
+
+func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
+ var (
+ buddyInfo = []BuddyInfo{}
+ scanner = bufio.NewScanner(r)
+ bucketCount = -1
+ )
+
+ for scanner.Scan() {
+ var err error
+ line := scanner.Text()
+ parts := strings.Fields(string(line))
+
+ if len(parts) < 4 {
+ return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo")
+ }
+
+ node := strings.TrimRight(parts[1], ",")
+ zone := strings.TrimRight(parts[3], ",")
+ arraySize := len(parts[4:])
+
+ if bucketCount == -1 {
+ bucketCount = arraySize
+ } else {
+ if bucketCount != arraySize {
+ return nil, fmt.Errorf("mismatch in number of buddyinfo buckets, previous count %d, new count %d", bucketCount, arraySize)
+ }
+ }
+
+ sizes := make([]float64, arraySize)
+ for i := 0; i < arraySize; i++ {
+ sizes[i], err = strconv.ParseFloat(parts[i+4], 64)
+ if err != nil {
+ return nil, fmt.Errorf("invalid value in buddyinfo: %s", err)
+ }
+ }
+
+ buddyInfo = append(buddyInfo, BuddyInfo{node, zone, sizes})
+ }
+
+ return buddyInfo, scanner.Err()
+}
diff --git a/vendor/github.com/prometheus/procfs/buddyinfo_test.go b/vendor/github.com/prometheus/procfs/buddyinfo_test.go
new file mode 100644
index 000000000..bcf9355ca
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/buddyinfo_test.go
@@ -0,0 +1,64 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package procfs
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestBuddyInfo(t *testing.T) {
+ buddyInfo, err := FS("fixtures/buddyinfo/valid").NewBuddyInfo()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if want, got := "DMA", buddyInfo[0].Zone; want != got {
+ t.Errorf("want Node 0, Zone %s, got %s", want, got)
+ }
+
+ if want, got := "Normal", buddyInfo[2].Zone; want != got {
+ t.Errorf("want Node 0, Zone %s, got %s", want, got)
+ }
+
+ if want, got := 4381.0, buddyInfo[2].Sizes[0]; want != got {
+ t.Errorf("want Node 0, Zone Normal %f, got %f", want, got)
+ }
+
+ if want, got := 572.0, buddyInfo[1].Sizes[1]; want != got {
+ t.Errorf("want Node 0, Zone DMA32 %f, got %f", want, got)
+ }
+}
+
+func TestBuddyInfoShort(t *testing.T) {
+ _, err := FS("fixtures/buddyinfo/short").NewBuddyInfo()
+ if err == nil {
+ t.Errorf("expected error, but none occurred")
+ }
+
+ if want, got := "invalid number of fields when parsing buddyinfo", err.Error(); want != got {
+ t.Errorf("wrong error returned, wanted %q, got %q", want, got)
+ }
+}
+
+func TestBuddyInfoSizeMismatch(t *testing.T) {
+ _, err := FS("fixtures/buddyinfo/sizemismatch").NewBuddyInfo()
+ if err == nil {
+ t.Errorf("expected error, but none occurred")
+ }
+
+ if want, got := "mismatch in number of buddyinfo buckets", err.Error(); !strings.HasPrefix(got, want) {
+ t.Errorf("wrong error returned, wanted prefix %q, got %q", want, got)
+ }
+}
diff --git a/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/short/buddyinfo b/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/short/buddyinfo
new file mode 100644
index 000000000..40e71ca35
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/short/buddyinfo
@@ -0,0 +1,3 @@
+Node 0, zone
+Node 0, zone
+Node 0, zone
diff --git a/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/sizemismatch/buddyinfo b/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/sizemismatch/buddyinfo
new file mode 100644
index 000000000..945636182
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/sizemismatch/buddyinfo
@@ -0,0 +1,3 @@
+Node 0, zone DMA 1 0 1 0 2 1 1 0 1 1 3
+Node 0, zone DMA32 759 572 791 475 194 45 12 0 0 0 0 0
+Node 0, zone Normal 4381 1093 185 1530 567 102 4 0 0 0
diff --git a/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/valid/buddyinfo b/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/valid/buddyinfo
new file mode 100644
index 000000000..f90594a81
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/fixtures/buddyinfo/valid/buddyinfo
@@ -0,0 +1,3 @@
+Node 0, zone DMA 1 0 1 0 2 1 1 0 1 1 3
+Node 0, zone DMA32 759 572 791 475 194 45 12 0 0 0 0
+Node 0, zone Normal 4381 1093 185 1530 567 102 4 0 0 0 0
diff --git a/vendor/github.com/prometheus/procfs/fixtures/fs/xfs/stat b/vendor/github.com/prometheus/procfs/fixtures/fs/xfs/stat
new file mode 100644
index 000000000..f7ca7f940
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/fixtures/fs/xfs/stat
@@ -0,0 +1,23 @@
+extent_alloc 92447 97589 92448 93751
+abt 0 0 0 0
+blk_map 1767055 188820 184891 92447 92448 2140766 0
+bmbt 0 0 0 0
+dir 185039 92447 92444 136422
+trans 706 944304 0
+ig 185045 58807 0 126238 0 33637 22
+log 2883 113448 9 17360 739
+push_ail 945014 0 134260 15483 0 3940 464 159985 0 40
+xstrat 92447 0
+rw 107739 94045
+attr 4 0 0 0
+icluster 8677 7849 135802
+vnodes 92601 0 0 0 92444 92444 92444 0
+buf 2666287 7122 2659202 3599 2 7085 0 10297 7085
+abtb2 184941 1277345 13257 13278 0 0 0 0 0 0 0 0 0 0 2746147
+abtc2 345295 2416764 172637 172658 0 0 0 0 0 0 0 0 0 0 21406023
+bmbt2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ibt2 343004 1358467 0 0 0 0 0 0 0 0 0 0 0 0 0
+fibt2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+qm 0 0 0 0 0 0 0 0
+xpc 399724544 92823103 86219234
+debug 0
diff --git a/vendor/github.com/prometheus/procfs/fs.go b/vendor/github.com/prometheus/procfs/fs.go
index 49aaab050..17546756b 100644
--- a/vendor/github.com/prometheus/procfs/fs.go
+++ b/vendor/github.com/prometheus/procfs/fs.go
@@ -4,6 +4,8 @@ import (
"fmt"
"os"
"path"
+
+ "github.com/prometheus/procfs/xfs"
)
// FS represents the pseudo-filesystem proc, which provides an interface to
@@ -31,3 +33,14 @@ func NewFS(mountPoint string) (FS, error) {
func (fs FS) Path(p ...string) string {
return path.Join(append([]string{string(fs)}, p...)...)
}
+
+// XFSStats retrieves XFS filesystem runtime statistics.
+func (fs FS) XFSStats() (*xfs.Stats, error) {
+ f, err := os.Open(fs.Path("fs/xfs/stat"))
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+
+ return xfs.ParseStats(f)
+}
diff --git a/vendor/github.com/prometheus/procfs/fs_test.go b/vendor/github.com/prometheus/procfs/fs_test.go
index 91f1c6c97..e492cde55 100644
--- a/vendor/github.com/prometheus/procfs/fs_test.go
+++ b/vendor/github.com/prometheus/procfs/fs_test.go
@@ -11,3 +11,16 @@ func TestNewFS(t *testing.T) {
t.Error("want NewFS to fail if mount point is not a directory")
}
}
+
+func TestFSXFSStats(t *testing.T) {
+ stats, err := FS("fixtures").XFSStats()
+ if err != nil {
+ t.Fatalf("failed to parse XFS stats: %v", err)
+ }
+
+ // Very lightweight test just to sanity check the path used
+ // to open XFS stats. Heavier tests in package xfs.
+ if want, got := uint32(92447), stats.ExtentAllocation.ExtentsAllocated; want != got {
+ t.Errorf("unexpected extents allocated:\nwant: %d\nhave: %d", want, got)
+ }
+}
diff --git a/vendor/github.com/prometheus/procfs/ipvs_test.go b/vendor/github.com/prometheus/procfs/ipvs_test.go
index c836c23ac..796ee5b88 100644
--- a/vendor/github.com/prometheus/procfs/ipvs_test.go
+++ b/vendor/github.com/prometheus/procfs/ipvs_test.go
@@ -14,7 +14,7 @@ var (
OutgoingBytes: 0,
}
expectedIPVSBackendStatuses = []IPVSBackendStatus{
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.22"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.82.22"),
@@ -24,7 +24,7 @@ var (
ActiveConn: 248,
InactConn: 2,
},
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.22"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.83.24"),
@@ -34,7 +34,7 @@ var (
ActiveConn: 248,
InactConn: 2,
},
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.22"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.83.21"),
@@ -44,7 +44,7 @@ var (
ActiveConn: 248,
InactConn: 1,
},
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.57"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.84.22"),
@@ -54,7 +54,7 @@ var (
ActiveConn: 0,
InactConn: 0,
},
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.57"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.82.21"),
@@ -64,7 +64,7 @@ var (
ActiveConn: 1499,
InactConn: 0,
},
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.57"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.50.21"),
@@ -74,7 +74,7 @@ var (
ActiveConn: 1498,
InactConn: 0,
},
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.55"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.50.26"),
@@ -84,7 +84,7 @@ var (
ActiveConn: 0,
InactConn: 0,
},
- IPVSBackendStatus{
+ {
LocalAddress: net.ParseIP("192.168.0.55"),
LocalPort: 3306,
RemoteAddress: net.ParseIP("192.168.49.32"),
diff --git a/vendor/github.com/prometheus/procfs/mdstat_test.go b/vendor/github.com/prometheus/procfs/mdstat_test.go
index ca5fe4d1b..fa463c2fb 100644
--- a/vendor/github.com/prometheus/procfs/mdstat_test.go
+++ b/vendor/github.com/prometheus/procfs/mdstat_test.go
@@ -11,13 +11,13 @@ func TestMDStat(t *testing.T) {
}
refs := map[string]MDStat{
- "md3": MDStat{"md3", "active", 8, 8, 5853468288, 5853468288},
- "md127": MDStat{"md127", "active", 2, 2, 312319552, 312319552},
- "md0": MDStat{"md0", "active", 2, 2, 248896, 248896},
- "md4": MDStat{"md4", "inactive", 2, 2, 4883648, 4883648},
- "md6": MDStat{"md6", "active", 1, 2, 195310144, 16775552},
- "md8": MDStat{"md8", "active", 2, 2, 195310144, 16775552},
- "md7": MDStat{"md7", "active", 3, 4, 7813735424, 7813735424},
+ "md3": {"md3", "active", 8, 8, 5853468288, 5853468288},
+ "md127": {"md127", "active", 2, 2, 312319552, 312319552},
+ "md0": {"md0", "active", 2, 2, 248896, 248896},
+ "md4": {"md4", "inactive", 2, 2, 4883648, 4883648},
+ "md6": {"md6", "active", 1, 2, 195310144, 16775552},
+ "md8": {"md8", "active", 2, 2, 195310144, 16775552},
+ "md7": {"md7", "active", 3, 4, 7813735424, 7813735424},
}
if want, have := len(refs), len(mdStates); want != have {
diff --git a/vendor/github.com/prometheus/procfs/mountstats.go b/vendor/github.com/prometheus/procfs/mountstats.go
index 47ab0a744..fe8f1f6a2 100644
--- a/vendor/github.com/prometheus/procfs/mountstats.go
+++ b/vendor/github.com/prometheus/procfs/mountstats.go
@@ -123,7 +123,7 @@ type NFSEventsStats struct {
VFSFlush uint64
// Number of times fsync() has been called on directories and files.
VFSFsync uint64
- // Number of times locking has been attemped on a file.
+ // Number of times locking has been attempted on a file.
VFSLock uint64
// Number of times files have been closed and released.
VFSFileRelease uint64
@@ -356,7 +356,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
}
// When encountering "per-operation statistics", we must break this
- // loop and parse them seperately to ensure we can terminate parsing
+ // loop and parse them separately to ensure we can terminate parsing
// before reaching another device entry; hence why this 'if' statement
// is not just another switch case
if ss[0] == fieldPerOpStats {
diff --git a/vendor/github.com/prometheus/procfs/mountstats_test.go b/vendor/github.com/prometheus/procfs/mountstats_test.go
index e65707939..75fd4a0f1 100644
--- a/vendor/github.com/prometheus/procfs/mountstats_test.go
+++ b/vendor/github.com/prometheus/procfs/mountstats_test.go
@@ -12,7 +12,6 @@ func TestMountStats(t *testing.T) {
tests := []struct {
name string
s string
- fs bool
mounts []*Mount
invalid bool
}{
@@ -113,7 +112,6 @@ func TestMountStats(t *testing.T) {
},
{
name: "fixtures OK",
- fs: true,
mounts: []*Mount{
{
Device: "rootfs",
@@ -201,10 +199,9 @@ func TestMountStats(t *testing.T) {
if tt.s != "" {
mounts, err = parseMountStats(strings.NewReader(tt.s))
- }
- if tt.fs {
- proc, err := FS("fixtures").NewProc(26231)
- if err != nil {
+ } else {
+ proc, e := FS("fixtures").NewProc(26231)
+ if e != nil {
t.Fatalf("failed to create proc: %v", err)
}
diff --git a/vendor/github.com/prometheus/procfs/xfs/parse.go b/vendor/github.com/prometheus/procfs/xfs/parse.go
new file mode 100644
index 000000000..d1285fa6c
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/xfs/parse.go
@@ -0,0 +1,361 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package xfs
+
+import (
+ "bufio"
+ "fmt"
+ "io"
+ "log"
+ "strconv"
+ "strings"
+)
+
+// ParseStats parses a Stats from an input io.Reader, using the format
+// found in /proc/fs/xfs/stat.
+func ParseStats(r io.Reader) (*Stats, error) {
+ const (
+ // Fields parsed into stats structures.
+ fieldExtentAlloc = "extent_alloc"
+ fieldAbt = "abt"
+ fieldBlkMap = "blk_map"
+ fieldBmbt = "bmbt"
+ fieldDir = "dir"
+ fieldTrans = "trans"
+ fieldIg = "ig"
+ fieldLog = "log"
+ fieldRw = "rw"
+ fieldAttr = "attr"
+ fieldIcluster = "icluster"
+ fieldVnodes = "vnodes"
+ fieldBuf = "buf"
+ fieldXpc = "xpc"
+
+ // Unimplemented at this time due to lack of documentation.
+ fieldPushAil = "push_ail"
+ fieldXstrat = "xstrat"
+ fieldAbtb2 = "abtb2"
+ fieldAbtc2 = "abtc2"
+ fieldBmbt2 = "bmbt2"
+ fieldIbt2 = "ibt2"
+ fieldFibt2 = "fibt2"
+ fieldQm = "qm"
+ fieldDebug = "debug"
+ )
+
+ var xfss Stats
+
+ s := bufio.NewScanner(r)
+ for s.Scan() {
+ // Expect at least a string label and a single integer value, ex:
+ // - abt 0
+ // - rw 1 2
+ ss := strings.Fields(string(s.Bytes()))
+ if len(ss) < 2 {
+ continue
+ }
+ label := ss[0]
+
+ // Extended precision counters are uint64 values.
+ if label == fieldXpc {
+ us, err := parseUint64s(ss[1:])
+ if err != nil {
+ return nil, err
+ }
+
+ xfss.ExtendedPrecision, err = extendedPrecisionStats(us)
+ if err != nil {
+ return nil, err
+ }
+
+ continue
+ }
+
+ // All other counters are uint32 values.
+ us, err := parseUint32s(ss[1:])
+ if err != nil {
+ return nil, err
+ }
+
+ switch label {
+ case fieldExtentAlloc:
+ xfss.ExtentAllocation, err = extentAllocationStats(us)
+ case fieldAbt:
+ xfss.AllocationBTree, err = btreeStats(us)
+ case fieldBlkMap:
+ xfss.BlockMapping, err = blockMappingStats(us)
+ case fieldBmbt:
+ xfss.BlockMapBTree, err = btreeStats(us)
+ case fieldDir:
+ xfss.DirectoryOperation, err = directoryOperationStats(us)
+ case fieldTrans:
+ xfss.Transaction, err = transactionStats(us)
+ case fieldIg:
+ xfss.InodeOperation, err = inodeOperationStats(us)
+ case fieldLog:
+ xfss.LogOperation, err = logOperationStats(us)
+ case fieldRw:
+ xfss.ReadWrite, err = readWriteStats(us)
+ case fieldAttr:
+ xfss.AttributeOperation, err = attributeOperationStats(us)
+ case fieldIcluster:
+ xfss.InodeClustering, err = inodeClusteringStats(us)
+ case fieldVnodes:
+ xfss.Vnode, err = vnodeStats(us)
+ case fieldBuf:
+ xfss.Buffer, err = bufferStats(us)
+ }
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return &xfss, s.Err()
+}
+
+// extentAllocationStats builds an ExtentAllocationStats from a slice of uint32s.
+func extentAllocationStats(us []uint32) (ExtentAllocationStats, error) {
+ if l := len(us); l != 4 {
+ return ExtentAllocationStats{}, fmt.Errorf("incorrect number of values for XFS extent allocation stats: %d", l)
+ }
+
+ return ExtentAllocationStats{
+ ExtentsAllocated: us[0],
+ BlocksAllocated: us[1],
+ ExtentsFreed: us[2],
+ BlocksFreed: us[3],
+ }, nil
+}
+
+// btreeStats builds a BTreeStats from a slice of uint32s.
+func btreeStats(us []uint32) (BTreeStats, error) {
+ if l := len(us); l != 4 {
+ return BTreeStats{}, fmt.Errorf("incorrect number of values for XFS btree stats: %d", l)
+ }
+
+ return BTreeStats{
+ Lookups: us[0],
+ Compares: us[1],
+ RecordsInserted: us[2],
+ RecordsDeleted: us[3],
+ }, nil
+}
+
+// BlockMappingStat builds a BlockMappingStats from a slice of uint32s.
+func blockMappingStats(us []uint32) (BlockMappingStats, error) {
+ if l := len(us); l != 7 {
+ return BlockMappingStats{}, fmt.Errorf("incorrect number of values for XFS block mapping stats: %d", l)
+ }
+
+ return BlockMappingStats{
+ Reads: us[0],
+ Writes: us[1],
+ Unmaps: us[2],
+ ExtentListInsertions: us[3],
+ ExtentListDeletions: us[4],
+ ExtentListLookups: us[5],
+ ExtentListCompares: us[6],
+ }, nil
+}
+
+// DirectoryOperationStats builds a DirectoryOperationStats from a slice of uint32s.
+func directoryOperationStats(us []uint32) (DirectoryOperationStats, error) {
+ if l := len(us); l != 4 {
+ return DirectoryOperationStats{}, fmt.Errorf("incorrect number of values for XFS directory operation stats: %d", l)
+ }
+
+ return DirectoryOperationStats{
+ Lookups: us[0],
+ Creates: us[1],
+ Removes: us[2],
+ Getdents: us[3],
+ }, nil
+}
+
+// TransactionStats builds a TransactionStats from a slice of uint32s.
+func transactionStats(us []uint32) (TransactionStats, error) {
+ if l := len(us); l != 3 {
+ return TransactionStats{}, fmt.Errorf("incorrect number of values for XFS transaction stats: %d", l)
+ }
+
+ return TransactionStats{
+ Sync: us[0],
+ Async: us[1],
+ Empty: us[2],
+ }, nil
+}
+
+// InodeOperationStats builds an InodeOperationStats from a slice of uint32s.
+func inodeOperationStats(us []uint32) (InodeOperationStats, error) {
+ if l := len(us); l != 7 {
+ return InodeOperationStats{}, fmt.Errorf("incorrect number of values for XFS inode operation stats: %d", l)
+ }
+
+ return InodeOperationStats{
+ Attempts: us[0],
+ Found: us[1],
+ Recycle: us[2],
+ Missed: us[3],
+ Duplicate: us[4],
+ Reclaims: us[5],
+ AttributeChange: us[6],
+ }, nil
+}
+
+// LogOperationStats builds a LogOperationStats from a slice of uint32s.
+func logOperationStats(us []uint32) (LogOperationStats, error) {
+ if l := len(us); l != 5 {
+ return LogOperationStats{}, fmt.Errorf("incorrect number of values for XFS log operation stats: %d", l)
+ }
+
+ return LogOperationStats{
+ Writes: us[0],
+ Blocks: us[1],
+ NoInternalBuffers: us[2],
+ Force: us[3],
+ ForceSleep: us[4],
+ }, nil
+}
+
+// ReadWriteStats builds a ReadWriteStats from a slice of uint32s.
+func readWriteStats(us []uint32) (ReadWriteStats, error) {
+ if l := len(us); l != 2 {
+ return ReadWriteStats{}, fmt.Errorf("incorrect number of values for XFS read write stats: %d", l)
+ }
+
+ return ReadWriteStats{
+ Read: us[0],
+ Write: us[1],
+ }, nil
+}
+
+// AttributeOperationStats builds an AttributeOperationStats from a slice of uint32s.
+func attributeOperationStats(us []uint32) (AttributeOperationStats, error) {
+ if l := len(us); l != 4 {
+ return AttributeOperationStats{}, fmt.Errorf("incorrect number of values for XFS attribute operation stats: %d", l)
+ }
+
+ return AttributeOperationStats{
+ Get: us[0],
+ Set: us[1],
+ Remove: us[2],
+ List: us[3],
+ }, nil
+}
+
+// InodeClusteringStats builds an InodeClusteringStats from a slice of uint32s.
+func inodeClusteringStats(us []uint32) (InodeClusteringStats, error) {
+ if l := len(us); l != 3 {
+ return InodeClusteringStats{}, fmt.Errorf("incorrect number of values for XFS inode clustering stats: %d", l)
+ }
+
+ return InodeClusteringStats{
+ Iflush: us[0],
+ Flush: us[1],
+ FlushInode: us[2],
+ }, nil
+}
+
+// VnodeStats builds a VnodeStats from a slice of uint32s.
+func vnodeStats(us []uint32) (VnodeStats, error) {
+ // The attribute "Free" appears to not be available on older XFS
+ // stats versions. Therefore, 7 or 8 elements may appear in
+ // this slice.
+ l := len(us)
+ log.Println(l)
+ if l != 7 && l != 8 {
+ return VnodeStats{}, fmt.Errorf("incorrect number of values for XFS vnode stats: %d", l)
+ }
+
+ s := VnodeStats{
+ Active: us[0],
+ Allocate: us[1],
+ Get: us[2],
+ Hold: us[3],
+ Release: us[4],
+ Reclaim: us[5],
+ Remove: us[6],
+ }
+
+ // Skip adding free, unless it is present. The zero value will
+ // be used in place of an actual count.
+ if l == 7 {
+ return s, nil
+ }
+
+ s.Free = us[7]
+ return s, nil
+}
+
+// BufferStats builds a BufferStats from a slice of uint32s.
+func bufferStats(us []uint32) (BufferStats, error) {
+ if l := len(us); l != 9 {
+ return BufferStats{}, fmt.Errorf("incorrect number of values for XFS buffer stats: %d", l)
+ }
+
+ return BufferStats{
+ Get: us[0],
+ Create: us[1],
+ GetLocked: us[2],
+ GetLockedWaited: us[3],
+ BusyLocked: us[4],
+ MissLocked: us[5],
+ PageRetries: us[6],
+ PageFound: us[7],
+ GetRead: us[8],
+ }, nil
+}
+
+// ExtendedPrecisionStats builds an ExtendedPrecisionStats from a slice of uint32s.
+func extendedPrecisionStats(us []uint64) (ExtendedPrecisionStats, error) {
+ if l := len(us); l != 3 {
+ return ExtendedPrecisionStats{}, fmt.Errorf("incorrect number of values for XFS extended precision stats: %d", l)
+ }
+
+ return ExtendedPrecisionStats{
+ FlushBytes: us[0],
+ WriteBytes: us[1],
+ ReadBytes: us[2],
+ }, nil
+}
+
+// parseUint32s parses a slice of strings into a slice of uint32s.
+func parseUint32s(ss []string) ([]uint32, error) {
+ us := make([]uint32, 0, len(ss))
+ for _, s := range ss {
+ u, err := strconv.ParseUint(s, 10, 32)
+ if err != nil {
+ return nil, err
+ }
+
+ us = append(us, uint32(u))
+ }
+
+ return us, nil
+}
+
+// parseUint64s parses a slice of strings into a slice of uint64s.
+func parseUint64s(ss []string) ([]uint64, error) {
+ us := make([]uint64, 0, len(ss))
+ for _, s := range ss {
+ u, err := strconv.ParseUint(s, 10, 64)
+ if err != nil {
+ return nil, err
+ }
+
+ us = append(us, u)
+ }
+
+ return us, nil
+}
diff --git a/vendor/github.com/prometheus/procfs/xfs/parse_test.go b/vendor/github.com/prometheus/procfs/xfs/parse_test.go
new file mode 100644
index 000000000..11ddb7425
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/xfs/parse_test.go
@@ -0,0 +1,446 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package xfs_test
+
+import (
+ "log"
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/prometheus/procfs"
+ "github.com/prometheus/procfs/xfs"
+)
+
+func TestParseStats(t *testing.T) {
+ tests := []struct {
+ name string
+ s string
+ fs bool
+ stats *xfs.Stats
+ invalid bool
+ }{
+ {
+ name: "empty file OK",
+ },
+ {
+ name: "short or empty lines and unknown labels ignored",
+ s: "one\n\ntwo 1 2 3\n",
+ stats: &xfs.Stats{},
+ },
+ {
+ name: "bad uint32",
+ s: "extent_alloc XXX",
+ invalid: true,
+ },
+ {
+ name: "bad uint64",
+ s: "xpc XXX",
+ invalid: true,
+ },
+ {
+ name: "extent_alloc bad",
+ s: "extent_alloc 1",
+ invalid: true,
+ },
+ {
+ name: "extent_alloc OK",
+ s: "extent_alloc 1 2 3 4",
+ stats: &xfs.Stats{
+ ExtentAllocation: xfs.ExtentAllocationStats{
+ ExtentsAllocated: 1,
+ BlocksAllocated: 2,
+ ExtentsFreed: 3,
+ BlocksFreed: 4,
+ },
+ },
+ },
+ {
+ name: "abt bad",
+ s: "abt 1",
+ invalid: true,
+ },
+ {
+ name: "abt OK",
+ s: "abt 1 2 3 4",
+ stats: &xfs.Stats{
+ AllocationBTree: xfs.BTreeStats{
+ Lookups: 1,
+ Compares: 2,
+ RecordsInserted: 3,
+ RecordsDeleted: 4,
+ },
+ },
+ },
+ {
+ name: "blk_map bad",
+ s: "blk_map 1",
+ invalid: true,
+ },
+ {
+ name: "blk_map OK",
+ s: "blk_map 1 2 3 4 5 6 7",
+ stats: &xfs.Stats{
+ BlockMapping: xfs.BlockMappingStats{
+ Reads: 1,
+ Writes: 2,
+ Unmaps: 3,
+ ExtentListInsertions: 4,
+ ExtentListDeletions: 5,
+ ExtentListLookups: 6,
+ ExtentListCompares: 7,
+ },
+ },
+ },
+ {
+ name: "bmbt bad",
+ s: "bmbt 1",
+ invalid: true,
+ },
+ {
+ name: "bmbt OK",
+ s: "bmbt 1 2 3 4",
+ stats: &xfs.Stats{
+ BlockMapBTree: xfs.BTreeStats{
+ Lookups: 1,
+ Compares: 2,
+ RecordsInserted: 3,
+ RecordsDeleted: 4,
+ },
+ },
+ },
+ {
+ name: "dir bad",
+ s: "dir 1",
+ invalid: true,
+ },
+ {
+ name: "dir OK",
+ s: "dir 1 2 3 4",
+ stats: &xfs.Stats{
+ DirectoryOperation: xfs.DirectoryOperationStats{
+ Lookups: 1,
+ Creates: 2,
+ Removes: 3,
+ Getdents: 4,
+ },
+ },
+ },
+ {
+ name: "trans bad",
+ s: "trans 1",
+ invalid: true,
+ },
+ {
+ name: "trans OK",
+ s: "trans 1 2 3",
+ stats: &xfs.Stats{
+ Transaction: xfs.TransactionStats{
+ Sync: 1,
+ Async: 2,
+ Empty: 3,
+ },
+ },
+ },
+ {
+ name: "ig bad",
+ s: "ig 1",
+ invalid: true,
+ },
+ {
+ name: "ig OK",
+ s: "ig 1 2 3 4 5 6 7",
+ stats: &xfs.Stats{
+ InodeOperation: xfs.InodeOperationStats{
+ Attempts: 1,
+ Found: 2,
+ Recycle: 3,
+ Missed: 4,
+ Duplicate: 5,
+ Reclaims: 6,
+ AttributeChange: 7,
+ },
+ },
+ },
+ {
+ name: "log bad",
+ s: "log 1",
+ invalid: true,
+ },
+ {
+ name: "log OK",
+ s: "log 1 2 3 4 5",
+ stats: &xfs.Stats{
+ LogOperation: xfs.LogOperationStats{
+ Writes: 1,
+ Blocks: 2,
+ NoInternalBuffers: 3,
+ Force: 4,
+ ForceSleep: 5,
+ },
+ },
+ },
+ {
+ name: "rw bad",
+ s: "rw 1",
+ invalid: true,
+ },
+ {
+ name: "rw OK",
+ s: "rw 1 2",
+ stats: &xfs.Stats{
+ ReadWrite: xfs.ReadWriteStats{
+ Read: 1,
+ Write: 2,
+ },
+ },
+ },
+ {
+ name: "attr bad",
+ s: "attr 1",
+ invalid: true,
+ },
+ {
+ name: "attr OK",
+ s: "attr 1 2 3 4",
+ stats: &xfs.Stats{
+ AttributeOperation: xfs.AttributeOperationStats{
+ Get: 1,
+ Set: 2,
+ Remove: 3,
+ List: 4,
+ },
+ },
+ },
+ {
+ name: "icluster bad",
+ s: "icluster 1",
+ invalid: true,
+ },
+ {
+ name: "icluster OK",
+ s: "icluster 1 2 3",
+ stats: &xfs.Stats{
+ InodeClustering: xfs.InodeClusteringStats{
+ Iflush: 1,
+ Flush: 2,
+ FlushInode: 3,
+ },
+ },
+ },
+ {
+ name: "vnodes bad",
+ s: "vnodes 1",
+ invalid: true,
+ },
+ {
+ name: "vnodes (missing free) OK",
+ s: "vnodes 1 2 3 4 5 6 7",
+ stats: &xfs.Stats{
+ Vnode: xfs.VnodeStats{
+ Active: 1,
+ Allocate: 2,
+ Get: 3,
+ Hold: 4,
+ Release: 5,
+ Reclaim: 6,
+ Remove: 7,
+ },
+ },
+ },
+ {
+ name: "vnodes (with free) OK",
+ s: "vnodes 1 2 3 4 5 6 7 8",
+ stats: &xfs.Stats{
+ Vnode: xfs.VnodeStats{
+ Active: 1,
+ Allocate: 2,
+ Get: 3,
+ Hold: 4,
+ Release: 5,
+ Reclaim: 6,
+ Remove: 7,
+ Free: 8,
+ },
+ },
+ },
+ {
+ name: "buf bad",
+ s: "buf 1",
+ invalid: true,
+ },
+ {
+ name: "buf OK",
+ s: "buf 1 2 3 4 5 6 7 8 9",
+ stats: &xfs.Stats{
+ Buffer: xfs.BufferStats{
+ Get: 1,
+ Create: 2,
+ GetLocked: 3,
+ GetLockedWaited: 4,
+ BusyLocked: 5,
+ MissLocked: 6,
+ PageRetries: 7,
+ PageFound: 8,
+ GetRead: 9,
+ },
+ },
+ },
+ {
+ name: "xpc bad",
+ s: "xpc 1",
+ invalid: true,
+ },
+ {
+ name: "xpc OK",
+ s: "xpc 1 2 3",
+ stats: &xfs.Stats{
+ ExtendedPrecision: xfs.ExtendedPrecisionStats{
+ FlushBytes: 1,
+ WriteBytes: 2,
+ ReadBytes: 3,
+ },
+ },
+ },
+ {
+ name: "fixtures OK",
+ fs: true,
+ stats: &xfs.Stats{
+ ExtentAllocation: xfs.ExtentAllocationStats{
+ ExtentsAllocated: 92447,
+ BlocksAllocated: 97589,
+ ExtentsFreed: 92448,
+ BlocksFreed: 93751,
+ },
+ AllocationBTree: xfs.BTreeStats{
+ Lookups: 0,
+ Compares: 0,
+ RecordsInserted: 0,
+ RecordsDeleted: 0,
+ },
+ BlockMapping: xfs.BlockMappingStats{
+ Reads: 1767055,
+ Writes: 188820,
+ Unmaps: 184891,
+ ExtentListInsertions: 92447,
+ ExtentListDeletions: 92448,
+ ExtentListLookups: 2140766,
+ ExtentListCompares: 0,
+ },
+ BlockMapBTree: xfs.BTreeStats{
+ Lookups: 0,
+ Compares: 0,
+ RecordsInserted: 0,
+ RecordsDeleted: 0,
+ },
+ DirectoryOperation: xfs.DirectoryOperationStats{
+ Lookups: 185039,
+ Creates: 92447,
+ Removes: 92444,
+ Getdents: 136422,
+ },
+ Transaction: xfs.TransactionStats{
+ Sync: 706,
+ Async: 944304,
+ Empty: 0,
+ },
+ InodeOperation: xfs.InodeOperationStats{
+ Attempts: 185045,
+ Found: 58807,
+ Recycle: 0,
+ Missed: 126238,
+ Duplicate: 0,
+ Reclaims: 33637,
+ AttributeChange: 22,
+ },
+ LogOperation: xfs.LogOperationStats{
+ Writes: 2883,
+ Blocks: 113448,
+ NoInternalBuffers: 9,
+ Force: 17360,
+ ForceSleep: 739,
+ },
+ ReadWrite: xfs.ReadWriteStats{
+ Read: 107739,
+ Write: 94045,
+ },
+ AttributeOperation: xfs.AttributeOperationStats{
+ Get: 4,
+ Set: 0,
+ Remove: 0,
+ List: 0,
+ },
+ InodeClustering: xfs.InodeClusteringStats{
+ Iflush: 8677,
+ Flush: 7849,
+ FlushInode: 135802,
+ },
+ Vnode: xfs.VnodeStats{
+ Active: 92601,
+ Allocate: 0,
+ Get: 0,
+ Hold: 0,
+ Release: 92444,
+ Reclaim: 92444,
+ Remove: 92444,
+ Free: 0,
+ },
+ Buffer: xfs.BufferStats{
+ Get: 2666287,
+ Create: 7122,
+ GetLocked: 2659202,
+ GetLockedWaited: 3599,
+ BusyLocked: 2,
+ MissLocked: 7085,
+ PageRetries: 0,
+ PageFound: 10297,
+ GetRead: 7085,
+ },
+ ExtendedPrecision: xfs.ExtendedPrecisionStats{
+ FlushBytes: 399724544,
+ WriteBytes: 92823103,
+ ReadBytes: 86219234,
+ },
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ t.Logf("[%02d] test %q", i, tt.name)
+
+ var (
+ stats *xfs.Stats
+ err error
+ )
+
+ if tt.s != "" {
+ stats, err = xfs.ParseStats(strings.NewReader(tt.s))
+ }
+ if tt.fs {
+ stats, err = procfs.FS("../fixtures").XFSStats()
+ }
+
+ if tt.invalid && err == nil {
+ t.Error("expected an error, but none occurred")
+ }
+ if !tt.invalid && err != nil {
+ t.Errorf("unexpected error: %v", err)
+ }
+
+ if want, have := tt.stats, stats; !reflect.DeepEqual(want, have) {
+ log.Printf("stats: %#v", have)
+ t.Errorf("unexpected XFS stats:\nwant:\n%v\nhave:\n%v", want, have)
+ }
+ }
+}
diff --git a/vendor/github.com/prometheus/procfs/xfs/xfs.go b/vendor/github.com/prometheus/procfs/xfs/xfs.go
new file mode 100644
index 000000000..ed77d907a
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/xfs/xfs.go
@@ -0,0 +1,158 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package xfs provides access to statistics exposed by the XFS filesystem.
+package xfs
+
+// Stats contains XFS filesystem runtime statistics, parsed from
+// /proc/fs/xfs/stat.
+//
+// The names and meanings of each statistic were taken from
+// http://xfs.org/index.php/Runtime_Stats and xfs_stats.h in the Linux
+// kernel source. Most counters are uint32s (same data types used in
+// xfs_stats.h), but some of the "extended precision stats" are uint64s.
+type Stats struct {
+ ExtentAllocation ExtentAllocationStats
+ AllocationBTree BTreeStats
+ BlockMapping BlockMappingStats
+ BlockMapBTree BTreeStats
+ DirectoryOperation DirectoryOperationStats
+ Transaction TransactionStats
+ InodeOperation InodeOperationStats
+ LogOperation LogOperationStats
+ ReadWrite ReadWriteStats
+ AttributeOperation AttributeOperationStats
+ InodeClustering InodeClusteringStats
+ Vnode VnodeStats
+ Buffer BufferStats
+ ExtendedPrecision ExtendedPrecisionStats
+}
+
+// ExtentAllocationStats contains statistics regarding XFS extent allocations.
+type ExtentAllocationStats struct {
+ ExtentsAllocated uint32
+ BlocksAllocated uint32
+ ExtentsFreed uint32
+ BlocksFreed uint32
+}
+
+// BTreeStats contains statistics regarding an XFS internal B-tree.
+type BTreeStats struct {
+ Lookups uint32
+ Compares uint32
+ RecordsInserted uint32
+ RecordsDeleted uint32
+}
+
+// BlockMappingStats contains statistics regarding XFS block maps.
+type BlockMappingStats struct {
+ Reads uint32
+ Writes uint32
+ Unmaps uint32
+ ExtentListInsertions uint32
+ ExtentListDeletions uint32
+ ExtentListLookups uint32
+ ExtentListCompares uint32
+}
+
+// DirectoryOperationStats contains statistics regarding XFS directory entries.
+type DirectoryOperationStats struct {
+ Lookups uint32
+ Creates uint32
+ Removes uint32
+ Getdents uint32
+}
+
+// TransactionStats contains statistics regarding XFS metadata transactions.
+type TransactionStats struct {
+ Sync uint32
+ Async uint32
+ Empty uint32
+}
+
+// InodeOperationStats contains statistics regarding XFS inode operations.
+type InodeOperationStats struct {
+ Attempts uint32
+ Found uint32
+ Recycle uint32
+ Missed uint32
+ Duplicate uint32
+ Reclaims uint32
+ AttributeChange uint32
+}
+
+// LogOperationStats contains statistics regarding the XFS log buffer.
+type LogOperationStats struct {
+ Writes uint32
+ Blocks uint32
+ NoInternalBuffers uint32
+ Force uint32
+ ForceSleep uint32
+}
+
+// ReadWriteStats contains statistics regarding the number of read and write
+// system calls for XFS filesystems.
+type ReadWriteStats struct {
+ Read uint32
+ Write uint32
+}
+
+// AttributeOperationStats contains statistics regarding manipulation of
+// XFS extended file attributes.
+type AttributeOperationStats struct {
+ Get uint32
+ Set uint32
+ Remove uint32
+ List uint32
+}
+
+// InodeClusteringStats contains statistics regarding XFS inode clustering
+// operations.
+type InodeClusteringStats struct {
+ Iflush uint32
+ Flush uint32
+ FlushInode uint32
+}
+
+// VnodeStats contains statistics regarding XFS vnode operations.
+type VnodeStats struct {
+ Active uint32
+ Allocate uint32
+ Get uint32
+ Hold uint32
+ Release uint32
+ Reclaim uint32
+ Remove uint32
+ Free uint32
+}
+
+// BufferStats contains statistics regarding XFS read/write I/O buffers.
+type BufferStats struct {
+ Get uint32
+ Create uint32
+ GetLocked uint32
+ GetLockedWaited uint32
+ BusyLocked uint32
+ MissLocked uint32
+ PageRetries uint32
+ PageFound uint32
+ GetRead uint32
+}
+
+// ExtendedPrecisionStats contains high precision counters used to track the
+// total number of bytes read, written, or flushed, during XFS operations.
+type ExtendedPrecisionStats struct {
+ FlushBytes uint64
+ WriteBytes uint64
+ ReadBytes uint64
+}