mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 04:29:57 +00:00
TUN-813: Clean up cloudflared dependencies
This commit is contained in:
84
vendor/github.com/prometheus/procfs/bcache/bcache.go
generated
vendored
84
vendor/github.com/prometheus/procfs/bcache/bcache.go
generated
vendored
@@ -1,84 +0,0 @@
|
||||
// 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 bcache provides access to statistics exposed by the bcache (Linux
|
||||
// block cache).
|
||||
package bcache
|
||||
|
||||
// Stats contains bcache runtime statistics, parsed from /sys/fs/bcache/.
|
||||
//
|
||||
// The names and meanings of each statistic were taken from bcache.txt and
|
||||
// files in drivers/md/bcache in the Linux kernel source. Counters are uint64
|
||||
// (in-kernel counters are mostly unsigned long).
|
||||
type Stats struct {
|
||||
// The name of the bcache used to source these statistics.
|
||||
Name string
|
||||
Bcache BcacheStats
|
||||
Bdevs []BdevStats
|
||||
Caches []CacheStats
|
||||
}
|
||||
|
||||
// BcacheStats contains statistics tied to a bcache ID.
|
||||
type BcacheStats struct {
|
||||
AverageKeySize uint64
|
||||
BtreeCacheSize uint64
|
||||
CacheAvailablePercent uint64
|
||||
Congested uint64
|
||||
RootUsagePercent uint64
|
||||
TreeDepth uint64
|
||||
Internal InternalStats
|
||||
FiveMin PeriodStats
|
||||
Total PeriodStats
|
||||
}
|
||||
|
||||
// BdevStats contains statistics for one backing device.
|
||||
type BdevStats struct {
|
||||
Name string
|
||||
DirtyData uint64
|
||||
FiveMin PeriodStats
|
||||
Total PeriodStats
|
||||
}
|
||||
|
||||
// CacheStats contains statistics for one cache device.
|
||||
type CacheStats struct {
|
||||
Name string
|
||||
IOErrors uint64
|
||||
MetadataWritten uint64
|
||||
Written uint64
|
||||
Priority PriorityStats
|
||||
}
|
||||
|
||||
// PriorityStats contains statistics from the priority_stats file.
|
||||
type PriorityStats struct {
|
||||
UnusedPercent uint64
|
||||
MetadataPercent uint64
|
||||
}
|
||||
|
||||
// InternalStats contains internal bcache statistics.
|
||||
type InternalStats struct {
|
||||
ActiveJournalEntries uint64
|
||||
BtreeNodes uint64
|
||||
BtreeReadAverageDurationNanoSeconds uint64
|
||||
CacheReadRaces uint64
|
||||
}
|
||||
|
||||
// PeriodStats contains statistics for a time period (5 min or total).
|
||||
type PeriodStats struct {
|
||||
Bypassed uint64
|
||||
CacheBypassHits uint64
|
||||
CacheBypassMisses uint64
|
||||
CacheHits uint64
|
||||
CacheMissCollisions uint64
|
||||
CacheMisses uint64
|
||||
CacheReadaheads uint64
|
||||
}
|
330
vendor/github.com/prometheus/procfs/bcache/get.go
generated
vendored
330
vendor/github.com/prometheus/procfs/bcache/get.go
generated
vendored
@@ -1,330 +0,0 @@
|
||||
// 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 bcache
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ParsePseudoFloat parses the peculiar format produced by bcache's bch_hprint.
|
||||
func parsePseudoFloat(str string) (float64, error) {
|
||||
ss := strings.Split(str, ".")
|
||||
|
||||
intPart, err := strconv.ParseFloat(ss[0], 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(ss) == 1 {
|
||||
// Pure integers are fine.
|
||||
return intPart, nil
|
||||
}
|
||||
fracPart, err := strconv.ParseFloat(ss[1], 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// fracPart is a number between 0 and 1023 divided by 100; it is off
|
||||
// by a small amount. Unexpected bumps in time lines may occur because
|
||||
// for bch_hprint .1 != .10 and .10 > .9 (at least up to Linux
|
||||
// v4.12-rc3).
|
||||
|
||||
// Restore the proper order:
|
||||
fracPart = fracPart / 10.24
|
||||
return intPart + fracPart, nil
|
||||
}
|
||||
|
||||
// Dehumanize converts a human-readable byte slice into a uint64.
|
||||
func dehumanize(hbytes []byte) (uint64, error) {
|
||||
ll := len(hbytes)
|
||||
if ll == 0 {
|
||||
return 0, fmt.Errorf("zero-length reply")
|
||||
}
|
||||
lastByte := hbytes[ll-1]
|
||||
mul := float64(1)
|
||||
var (
|
||||
mant float64
|
||||
err error
|
||||
)
|
||||
// If lastByte is beyond the range of ASCII digits, it must be a
|
||||
// multiplier.
|
||||
if lastByte > 57 {
|
||||
// Remove multiplier from slice.
|
||||
hbytes = hbytes[:len(hbytes)-1]
|
||||
|
||||
const (
|
||||
_ = 1 << (10 * iota)
|
||||
KiB
|
||||
MiB
|
||||
GiB
|
||||
TiB
|
||||
PiB
|
||||
EiB
|
||||
ZiB
|
||||
YiB
|
||||
)
|
||||
|
||||
multipliers := map[rune]float64{
|
||||
// Source for conversion rules:
|
||||
// linux-kernel/drivers/md/bcache/util.c:bch_hprint()
|
||||
'k': KiB,
|
||||
'M': MiB,
|
||||
'G': GiB,
|
||||
'T': TiB,
|
||||
'P': PiB,
|
||||
'E': EiB,
|
||||
'Z': ZiB,
|
||||
'Y': YiB,
|
||||
}
|
||||
mul = multipliers[rune(lastByte)]
|
||||
mant, err = parsePseudoFloat(string(hbytes))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
} else {
|
||||
// Not humanized by bch_hprint
|
||||
mant, err = strconv.ParseFloat(string(hbytes), 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
res := uint64(mant * mul)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
type parser struct {
|
||||
uuidPath string
|
||||
subDir string
|
||||
currentDir string
|
||||
err error
|
||||
}
|
||||
|
||||
func (p *parser) setSubDir(pathElements ...string) {
|
||||
p.subDir = path.Join(pathElements...)
|
||||
p.currentDir = path.Join(p.uuidPath, p.subDir)
|
||||
}
|
||||
|
||||
func (p *parser) readValue(fileName string) uint64 {
|
||||
if p.err != nil {
|
||||
return 0
|
||||
}
|
||||
path := path.Join(p.currentDir, fileName)
|
||||
byt, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
p.err = fmt.Errorf("failed to read: %s", path)
|
||||
return 0
|
||||
}
|
||||
// Remove trailing newline.
|
||||
byt = byt[:len(byt)-1]
|
||||
res, err := dehumanize(byt)
|
||||
p.err = err
|
||||
return res
|
||||
}
|
||||
|
||||
// ParsePriorityStats parses lines from the priority_stats file.
|
||||
func parsePriorityStats(line string, ps *PriorityStats) error {
|
||||
var (
|
||||
value uint64
|
||||
err error
|
||||
)
|
||||
switch {
|
||||
case strings.HasPrefix(line, "Unused:"):
|
||||
fields := strings.Fields(line)
|
||||
rawValue := fields[len(fields)-1]
|
||||
valueStr := strings.TrimSuffix(rawValue, "%")
|
||||
value, err = strconv.ParseUint(valueStr, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ps.UnusedPercent = value
|
||||
case strings.HasPrefix(line, "Metadata:"):
|
||||
fields := strings.Fields(line)
|
||||
rawValue := fields[len(fields)-1]
|
||||
valueStr := strings.TrimSuffix(rawValue, "%")
|
||||
value, err = strconv.ParseUint(valueStr, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ps.MetadataPercent = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *parser) getPriorityStats() PriorityStats {
|
||||
var res PriorityStats
|
||||
|
||||
if p.err != nil {
|
||||
return res
|
||||
}
|
||||
|
||||
path := path.Join(p.currentDir, "priority_stats")
|
||||
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
p.err = fmt.Errorf("failed to read: %s", path)
|
||||
return res
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
err = parsePriorityStats(scanner.Text(), &res)
|
||||
if err != nil {
|
||||
p.err = fmt.Errorf("failed to parse: %s (%s)", path, err)
|
||||
return res
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
p.err = fmt.Errorf("failed to parse: %s (%s)", path, err)
|
||||
return res
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// GetStats collects from sysfs files data tied to one bcache ID.
|
||||
func GetStats(uuidPath string) (*Stats, error) {
|
||||
var bs Stats
|
||||
|
||||
par := parser{uuidPath: uuidPath}
|
||||
|
||||
// bcache stats
|
||||
|
||||
// dir <uuidPath>
|
||||
par.setSubDir("")
|
||||
bs.Bcache.AverageKeySize = par.readValue("average_key_size")
|
||||
bs.Bcache.BtreeCacheSize = par.readValue("btree_cache_size")
|
||||
bs.Bcache.CacheAvailablePercent = par.readValue("cache_available_percent")
|
||||
bs.Bcache.Congested = par.readValue("congested")
|
||||
bs.Bcache.RootUsagePercent = par.readValue("root_usage_percent")
|
||||
bs.Bcache.TreeDepth = par.readValue("tree_depth")
|
||||
|
||||
// bcache stats (internal)
|
||||
|
||||
// dir <uuidPath>/internal
|
||||
par.setSubDir("internal")
|
||||
bs.Bcache.Internal.ActiveJournalEntries = par.readValue("active_journal_entries")
|
||||
bs.Bcache.Internal.BtreeNodes = par.readValue("btree_nodes")
|
||||
bs.Bcache.Internal.BtreeReadAverageDurationNanoSeconds = par.readValue("btree_read_average_duration_us")
|
||||
bs.Bcache.Internal.CacheReadRaces = par.readValue("cache_read_races")
|
||||
|
||||
// bcache stats (period)
|
||||
|
||||
// dir <uuidPath>/stats_five_minute
|
||||
par.setSubDir("stats_five_minute")
|
||||
bs.Bcache.FiveMin.Bypassed = par.readValue("bypassed")
|
||||
bs.Bcache.FiveMin.CacheHits = par.readValue("cache_hits")
|
||||
|
||||
bs.Bcache.FiveMin.Bypassed = par.readValue("bypassed")
|
||||
bs.Bcache.FiveMin.CacheBypassHits = par.readValue("cache_bypass_hits")
|
||||
bs.Bcache.FiveMin.CacheBypassMisses = par.readValue("cache_bypass_misses")
|
||||
bs.Bcache.FiveMin.CacheHits = par.readValue("cache_hits")
|
||||
bs.Bcache.FiveMin.CacheMissCollisions = par.readValue("cache_miss_collisions")
|
||||
bs.Bcache.FiveMin.CacheMisses = par.readValue("cache_misses")
|
||||
bs.Bcache.FiveMin.CacheReadaheads = par.readValue("cache_readaheads")
|
||||
|
||||
// dir <uuidPath>/stats_total
|
||||
par.setSubDir("stats_total")
|
||||
bs.Bcache.Total.Bypassed = par.readValue("bypassed")
|
||||
bs.Bcache.Total.CacheHits = par.readValue("cache_hits")
|
||||
|
||||
bs.Bcache.Total.Bypassed = par.readValue("bypassed")
|
||||
bs.Bcache.Total.CacheBypassHits = par.readValue("cache_bypass_hits")
|
||||
bs.Bcache.Total.CacheBypassMisses = par.readValue("cache_bypass_misses")
|
||||
bs.Bcache.Total.CacheHits = par.readValue("cache_hits")
|
||||
bs.Bcache.Total.CacheMissCollisions = par.readValue("cache_miss_collisions")
|
||||
bs.Bcache.Total.CacheMisses = par.readValue("cache_misses")
|
||||
bs.Bcache.Total.CacheReadaheads = par.readValue("cache_readaheads")
|
||||
|
||||
if par.err != nil {
|
||||
return nil, par.err
|
||||
}
|
||||
|
||||
// bdev stats
|
||||
|
||||
reg := path.Join(uuidPath, "bdev[0-9]*")
|
||||
bdevDirs, err := filepath.Glob(reg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bs.Bdevs = make([]BdevStats, len(bdevDirs))
|
||||
|
||||
for ii, bdevDir := range bdevDirs {
|
||||
var bds = &bs.Bdevs[ii]
|
||||
|
||||
bds.Name = filepath.Base(bdevDir)
|
||||
|
||||
par.setSubDir(bds.Name)
|
||||
bds.DirtyData = par.readValue("dirty_data")
|
||||
|
||||
// dir <uuidPath>/<bds.Name>/stats_five_minute
|
||||
par.setSubDir(bds.Name, "stats_five_minute")
|
||||
bds.FiveMin.Bypassed = par.readValue("bypassed")
|
||||
bds.FiveMin.CacheBypassHits = par.readValue("cache_bypass_hits")
|
||||
bds.FiveMin.CacheBypassMisses = par.readValue("cache_bypass_misses")
|
||||
bds.FiveMin.CacheHits = par.readValue("cache_hits")
|
||||
bds.FiveMin.CacheMissCollisions = par.readValue("cache_miss_collisions")
|
||||
bds.FiveMin.CacheMisses = par.readValue("cache_misses")
|
||||
bds.FiveMin.CacheReadaheads = par.readValue("cache_readaheads")
|
||||
|
||||
// dir <uuidPath>/<bds.Name>/stats_total
|
||||
par.setSubDir("stats_total")
|
||||
bds.Total.Bypassed = par.readValue("bypassed")
|
||||
bds.Total.CacheBypassHits = par.readValue("cache_bypass_hits")
|
||||
bds.Total.CacheBypassMisses = par.readValue("cache_bypass_misses")
|
||||
bds.Total.CacheHits = par.readValue("cache_hits")
|
||||
bds.Total.CacheMissCollisions = par.readValue("cache_miss_collisions")
|
||||
bds.Total.CacheMisses = par.readValue("cache_misses")
|
||||
bds.Total.CacheReadaheads = par.readValue("cache_readaheads")
|
||||
}
|
||||
|
||||
if par.err != nil {
|
||||
return nil, par.err
|
||||
}
|
||||
|
||||
// cache stats
|
||||
|
||||
reg = path.Join(uuidPath, "cache[0-9]*")
|
||||
cacheDirs, err := filepath.Glob(reg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bs.Caches = make([]CacheStats, len(cacheDirs))
|
||||
|
||||
for ii, cacheDir := range cacheDirs {
|
||||
var cs = &bs.Caches[ii]
|
||||
cs.Name = filepath.Base(cacheDir)
|
||||
|
||||
// dir is <uuidPath>/<cs.Name>
|
||||
par.setSubDir(cs.Name)
|
||||
cs.IOErrors = par.readValue("io_errors")
|
||||
cs.MetadataWritten = par.readValue("metadata_written")
|
||||
cs.Written = par.readValue("written")
|
||||
|
||||
ps := par.getPriorityStats()
|
||||
cs.Priority = ps
|
||||
}
|
||||
|
||||
if par.err != nil {
|
||||
return nil, par.err
|
||||
}
|
||||
|
||||
return &bs, nil
|
||||
}
|
114
vendor/github.com/prometheus/procfs/bcache/get_test.go
generated
vendored
114
vendor/github.com/prometheus/procfs/bcache/get_test.go
generated
vendored
@@ -1,114 +0,0 @@
|
||||
// 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 bcache
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDehumanizeTests(t *testing.T) {
|
||||
dehumanizeTests := []struct {
|
||||
in []byte
|
||||
out uint64
|
||||
invalid bool
|
||||
}{
|
||||
{
|
||||
in: []byte("542k"),
|
||||
out: 555008,
|
||||
},
|
||||
{
|
||||
in: []byte("322M"),
|
||||
out: 337641472,
|
||||
},
|
||||
{
|
||||
in: []byte("1.1k"),
|
||||
out: 1124,
|
||||
},
|
||||
{
|
||||
in: []byte("1.9k"),
|
||||
out: 1924,
|
||||
},
|
||||
{
|
||||
in: []byte("1.10k"),
|
||||
out: 2024,
|
||||
},
|
||||
{
|
||||
in: []byte(""),
|
||||
out: 0,
|
||||
invalid: true,
|
||||
},
|
||||
}
|
||||
for _, tst := range dehumanizeTests {
|
||||
got, err := dehumanize(tst.in)
|
||||
if tst.invalid && err == nil {
|
||||
t.Error("expected an error, but none occurred")
|
||||
}
|
||||
if !tst.invalid && err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if got != tst.out {
|
||||
t.Errorf("dehumanize: '%s', want %d, got %d", tst.in, tst.out, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePseudoFloatTests(t *testing.T) {
|
||||
parsePseudoFloatTests := []struct {
|
||||
in string
|
||||
out float64
|
||||
}{
|
||||
{
|
||||
in: "1.1",
|
||||
out: float64(1.097656),
|
||||
},
|
||||
{
|
||||
in: "1.9",
|
||||
out: float64(1.878906),
|
||||
},
|
||||
{
|
||||
in: "1.10",
|
||||
out: float64(1.976562),
|
||||
},
|
||||
}
|
||||
for _, tst := range parsePseudoFloatTests {
|
||||
got, err := parsePseudoFloat(tst.in)
|
||||
if err != nil || math.Abs(got-tst.out) > 0.0001 {
|
||||
t.Errorf("parsePseudoFloat: %s, want %f, got %f", tst.in, tst.out, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPriorityStats(t *testing.T) {
|
||||
var want = PriorityStats{
|
||||
UnusedPercent: 99,
|
||||
MetadataPercent: 5,
|
||||
}
|
||||
var (
|
||||
in string
|
||||
gotErr error
|
||||
got PriorityStats
|
||||
)
|
||||
in = "Metadata: 5%"
|
||||
gotErr = parsePriorityStats(in, &got)
|
||||
if gotErr != nil || got.MetadataPercent != want.MetadataPercent {
|
||||
t.Errorf("parsePriorityStats: '%s', want %d, got %d", in, want.MetadataPercent, got.MetadataPercent)
|
||||
}
|
||||
|
||||
in = "Unused: 99%"
|
||||
gotErr = parsePriorityStats(in, &got)
|
||||
if gotErr != nil || got.UnusedPercent != want.UnusedPercent {
|
||||
t.Errorf("parsePriorityStats: '%s', want %d, got %d", in, want.UnusedPercent, got.UnusedPercent)
|
||||
}
|
||||
}
|
64
vendor/github.com/prometheus/procfs/buddyinfo_test.go
generated
vendored
64
vendor/github.com/prometheus/procfs/buddyinfo_test.go
generated
vendored
@@ -1,64 +0,0 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
39
vendor/github.com/prometheus/procfs/fs_test.go
generated
vendored
39
vendor/github.com/prometheus/procfs/fs_test.go
generated
vendored
@@ -1,39 +0,0 @@
|
||||
// Copyright 2018 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 "testing"
|
||||
|
||||
func TestNewFS(t *testing.T) {
|
||||
if _, err := NewFS("foobar"); err == nil {
|
||||
t.Error("want NewFS to fail for non-existing mount point")
|
||||
}
|
||||
|
||||
if _, err := NewFS("procfs.go"); err == nil {
|
||||
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)
|
||||
}
|
||||
}
|
250
vendor/github.com/prometheus/procfs/ipvs_test.go
generated
vendored
250
vendor/github.com/prometheus/procfs/ipvs_test.go
generated
vendored
@@ -1,250 +0,0 @@
|
||||
// Copyright 2018 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 (
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
expectedIPVSStats = IPVSStats{
|
||||
Connections: 23765872,
|
||||
IncomingPackets: 3811989221,
|
||||
OutgoingPackets: 0,
|
||||
IncomingBytes: 89991519156915,
|
||||
OutgoingBytes: 0,
|
||||
}
|
||||
expectedIPVSBackendStatuses = []IPVSBackendStatus{
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.22"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.82.22"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 100,
|
||||
ActiveConn: 248,
|
||||
InactConn: 2,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.22"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.83.24"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 100,
|
||||
ActiveConn: 248,
|
||||
InactConn: 2,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.22"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.83.21"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 100,
|
||||
ActiveConn: 248,
|
||||
InactConn: 1,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.57"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.84.22"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 0,
|
||||
ActiveConn: 0,
|
||||
InactConn: 0,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.57"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.82.21"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 100,
|
||||
ActiveConn: 1499,
|
||||
InactConn: 0,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.57"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.50.21"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 100,
|
||||
ActiveConn: 1498,
|
||||
InactConn: 0,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.55"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.50.26"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 0,
|
||||
ActiveConn: 0,
|
||||
InactConn: 0,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("192.168.0.55"),
|
||||
LocalPort: 3306,
|
||||
RemoteAddress: net.ParseIP("192.168.49.32"),
|
||||
RemotePort: 3306,
|
||||
Proto: "TCP",
|
||||
Weight: 100,
|
||||
ActiveConn: 0,
|
||||
InactConn: 0,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("2620::1"),
|
||||
LocalPort: 80,
|
||||
RemoteAddress: net.ParseIP("2620::2"),
|
||||
RemotePort: 80,
|
||||
Proto: "TCP",
|
||||
Weight: 1,
|
||||
ActiveConn: 0,
|
||||
InactConn: 0,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("2620::1"),
|
||||
LocalPort: 80,
|
||||
RemoteAddress: net.ParseIP("2620::3"),
|
||||
RemotePort: 80,
|
||||
Proto: "TCP",
|
||||
Weight: 1,
|
||||
ActiveConn: 0,
|
||||
InactConn: 0,
|
||||
},
|
||||
{
|
||||
LocalAddress: net.ParseIP("2620::1"),
|
||||
LocalPort: 80,
|
||||
RemoteAddress: net.ParseIP("2620::4"),
|
||||
RemotePort: 80,
|
||||
Proto: "TCP",
|
||||
Weight: 1,
|
||||
ActiveConn: 1,
|
||||
InactConn: 1,
|
||||
},
|
||||
{
|
||||
LocalMark: "10001000",
|
||||
RemoteAddress: net.ParseIP("192.168.50.26"),
|
||||
RemotePort: 3306,
|
||||
Proto: "FWM",
|
||||
Weight: 0,
|
||||
ActiveConn: 0,
|
||||
InactConn: 1,
|
||||
},
|
||||
{
|
||||
LocalMark: "10001000",
|
||||
RemoteAddress: net.ParseIP("192.168.50.21"),
|
||||
RemotePort: 3306,
|
||||
Proto: "FWM",
|
||||
Weight: 0,
|
||||
ActiveConn: 0,
|
||||
InactConn: 2,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func TestIPVSStats(t *testing.T) {
|
||||
stats, err := FS("fixtures").NewIPVSStats()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if stats != expectedIPVSStats {
|
||||
t.Errorf("want %+v, have %+v", expectedIPVSStats, stats)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseIPPort(t *testing.T) {
|
||||
ip := net.ParseIP("192.168.0.22")
|
||||
port := uint16(3306)
|
||||
|
||||
gotIP, gotPort, err := parseIPPort("C0A80016:0CEA")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !(gotIP.Equal(ip) && port == gotPort) {
|
||||
t.Errorf("want %s:%d, have %s:%d", ip, port, gotIP, gotPort)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseIPPortInvalid(t *testing.T) {
|
||||
testcases := []string{
|
||||
"",
|
||||
"C0A80016",
|
||||
"C0A800:1234",
|
||||
"FOOBARBA:1234",
|
||||
"C0A80016:0CEA:1234",
|
||||
}
|
||||
|
||||
for _, s := range testcases {
|
||||
ip, port, err := parseIPPort(s)
|
||||
if ip != nil || port != uint16(0) || err == nil {
|
||||
t.Errorf("Expected error for input %s, have ip = %s, port = %v, err = %v", s, ip, port, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseIPPortIPv6(t *testing.T) {
|
||||
ip := net.ParseIP("dead:beef::1")
|
||||
port := uint16(8080)
|
||||
|
||||
gotIP, gotPort, err := parseIPPort("[DEAD:BEEF:0000:0000:0000:0000:0000:0001]:1F90")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !(gotIP.Equal(ip) && port == gotPort) {
|
||||
t.Errorf("want %s:%d, have %s:%d", ip, port, gotIP, gotPort)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIPVSBackendStatus(t *testing.T) {
|
||||
backendStats, err := FS("fixtures").NewIPVSBackendStatus()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want, have := len(expectedIPVSBackendStatuses), len(backendStats); want != have {
|
||||
t.Fatalf("want %d backend statuses, have %d", want, have)
|
||||
}
|
||||
|
||||
for idx, expect := range expectedIPVSBackendStatuses {
|
||||
if !backendStats[idx].LocalAddress.Equal(expect.LocalAddress) {
|
||||
t.Errorf("want LocalAddress %s, have %s", expect.LocalAddress, backendStats[idx].LocalAddress)
|
||||
}
|
||||
if backendStats[idx].LocalPort != expect.LocalPort {
|
||||
t.Errorf("want LocalPort %d, have %d", expect.LocalPort, backendStats[idx].LocalPort)
|
||||
}
|
||||
if !backendStats[idx].RemoteAddress.Equal(expect.RemoteAddress) {
|
||||
t.Errorf("want RemoteAddress %s, have %s", expect.RemoteAddress, backendStats[idx].RemoteAddress)
|
||||
}
|
||||
if backendStats[idx].RemotePort != expect.RemotePort {
|
||||
t.Errorf("want RemotePort %d, have %d", expect.RemotePort, backendStats[idx].RemotePort)
|
||||
}
|
||||
if backendStats[idx].Proto != expect.Proto {
|
||||
t.Errorf("want Proto %s, have %s", expect.Proto, backendStats[idx].Proto)
|
||||
}
|
||||
if backendStats[idx].Weight != expect.Weight {
|
||||
t.Errorf("want Weight %d, have %d", expect.Weight, backendStats[idx].Weight)
|
||||
}
|
||||
if backendStats[idx].ActiveConn != expect.ActiveConn {
|
||||
t.Errorf("want ActiveConn %d, have %d", expect.ActiveConn, backendStats[idx].ActiveConn)
|
||||
}
|
||||
if backendStats[idx].InactConn != expect.InactConn {
|
||||
t.Errorf("want InactConn %d, have %d", expect.InactConn, backendStats[idx].InactConn)
|
||||
}
|
||||
}
|
||||
}
|
44
vendor/github.com/prometheus/procfs/mdstat_test.go
generated
vendored
44
vendor/github.com/prometheus/procfs/mdstat_test.go
generated
vendored
@@ -1,44 +0,0 @@
|
||||
// Copyright 2018 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 (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMDStat(t *testing.T) {
|
||||
mdStates, err := FS("fixtures").ParseMDStat()
|
||||
if err != nil {
|
||||
t.Fatalf("parsing of reference-file failed entirely: %s", err)
|
||||
}
|
||||
|
||||
refs := map[string]MDStat{
|
||||
"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 {
|
||||
t.Errorf("want %d parsed md-devices, have %d", want, have)
|
||||
}
|
||||
for _, md := range mdStates {
|
||||
if want, have := refs[md.Name], md; want != have {
|
||||
t.Errorf("%s: want %v, have %v", md.Name, want, have)
|
||||
}
|
||||
}
|
||||
}
|
380
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
380
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
@@ -1,380 +0,0 @@
|
||||
// Copyright 2018 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 (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestMountStats(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
s string
|
||||
mounts []*Mount
|
||||
invalid bool
|
||||
}{
|
||||
{
|
||||
name: "no devices",
|
||||
s: `hello`,
|
||||
},
|
||||
{
|
||||
name: "device has too few fields",
|
||||
s: `device foo`,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "device incorrect format",
|
||||
s: `device rootfs BAD on / with fstype rootfs`,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "device incorrect format",
|
||||
s: `device rootfs mounted BAD / with fstype rootfs`,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "device incorrect format",
|
||||
s: `device rootfs mounted on / BAD fstype rootfs`,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "device incorrect format",
|
||||
s: `device rootfs mounted on / with BAD rootfs`,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "device rootfs cannot have stats",
|
||||
s: `device rootfs mounted on / with fstype rootfs stats`,
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with too little info",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nhello",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with bad bytes",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nbytes: 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with bad events",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nevents: 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with bad per-op stats",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nper-op statistics\nFOO 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with bad transport stats",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nxprt: tcp",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with bad transport version",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=foo\nxprt: tcp 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with bad transport stats version 1.0",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.0\nxprt: tcp 0 0 0 0 0 0 0 0 0 0 0 0 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv4 device with bad transport stats version 1.1",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nxprt: tcp 0 0 0 0 0 0 0 0 0 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device with bad transport protocol",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nxprt: tcpx 0 0 0 0 0 0 0 0 0 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using TCP with transport stats version 1.0 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.0\nxprt: tcp 1 2 3 4 5 6 7 8 9 10",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.0",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "tcp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 3,
|
||||
ConnectIdleTime: 4,
|
||||
IdleTime: 5 * time.Second,
|
||||
Sends: 6,
|
||||
Receives: 7,
|
||||
BadTransactionIDs: 8,
|
||||
CumulativeActiveRequests: 9,
|
||||
CumulativeBacklog: 10,
|
||||
MaximumRPCSlotsUsed: 0, // these three are not
|
||||
CumulativeSendingQueue: 0, // present in statvers=1.0
|
||||
CumulativePendingQueue: 0, //
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using UDP with transport stats version 1.0 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.0\nxprt: udp 1 2 3 4 5 6 7",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.0",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "udp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 0,
|
||||
ConnectIdleTime: 0,
|
||||
IdleTime: 0,
|
||||
Sends: 3,
|
||||
Receives: 4,
|
||||
BadTransactionIDs: 5,
|
||||
CumulativeActiveRequests: 6,
|
||||
CumulativeBacklog: 7,
|
||||
MaximumRPCSlotsUsed: 0, // these three are not
|
||||
CumulativeSendingQueue: 0, // present in statvers=1.0
|
||||
CumulativePendingQueue: 0, //
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using TCP with transport stats version 1.1 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.1\nxprt: tcp 1 2 3 4 5 6 7 8 9 10 11 12 13",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.1",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "tcp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 3,
|
||||
ConnectIdleTime: 4,
|
||||
IdleTime: 5 * time.Second,
|
||||
Sends: 6,
|
||||
Receives: 7,
|
||||
BadTransactionIDs: 8,
|
||||
CumulativeActiveRequests: 9,
|
||||
CumulativeBacklog: 10,
|
||||
MaximumRPCSlotsUsed: 11,
|
||||
CumulativeSendingQueue: 12,
|
||||
CumulativePendingQueue: 13,
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using UDP with transport stats version 1.1 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.1\nxprt: udp 1 2 3 4 5 6 7 8 9 10",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.1",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "udp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 0, // these three are not
|
||||
ConnectIdleTime: 0, // present for UDP
|
||||
IdleTime: 0, //
|
||||
Sends: 3,
|
||||
Receives: 4,
|
||||
BadTransactionIDs: 5,
|
||||
CumulativeActiveRequests: 6,
|
||||
CumulativeBacklog: 7,
|
||||
MaximumRPCSlotsUsed: 8,
|
||||
CumulativeSendingQueue: 9,
|
||||
CumulativePendingQueue: 10,
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "device rootfs OK",
|
||||
s: `device rootfs mounted on / with fstype rootfs`,
|
||||
mounts: []*Mount{{
|
||||
Device: "rootfs",
|
||||
Mount: "/",
|
||||
Type: "rootfs",
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device with minimal stats OK",
|
||||
s: `device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.1`,
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.1",
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "fixtures OK",
|
||||
mounts: []*Mount{
|
||||
{
|
||||
Device: "rootfs",
|
||||
Mount: "/",
|
||||
Type: "rootfs",
|
||||
},
|
||||
{
|
||||
Device: "sysfs",
|
||||
Mount: "/sys",
|
||||
Type: "sysfs",
|
||||
},
|
||||
{
|
||||
Device: "proc",
|
||||
Mount: "/proc",
|
||||
Type: "proc",
|
||||
},
|
||||
{
|
||||
Device: "/dev/sda1",
|
||||
Mount: "/",
|
||||
Type: "ext4",
|
||||
},
|
||||
{
|
||||
Device: "192.168.1.1:/srv/test",
|
||||
Mount: "/mnt/nfs/test",
|
||||
Type: "nfs4",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.1",
|
||||
Age: 13968 * time.Second,
|
||||
Bytes: NFSBytesStats{
|
||||
Read: 1207640230,
|
||||
ReadTotal: 1210214218,
|
||||
ReadPages: 295483,
|
||||
},
|
||||
Events: NFSEventsStats{
|
||||
InodeRevalidate: 52,
|
||||
DnodeRevalidate: 226,
|
||||
VFSOpen: 1,
|
||||
VFSLookup: 13,
|
||||
VFSAccess: 398,
|
||||
VFSReadPages: 331,
|
||||
VFSWritePages: 47,
|
||||
VFSFlush: 77,
|
||||
VFSFileRelease: 77,
|
||||
},
|
||||
Operations: []NFSOperationStats{
|
||||
{
|
||||
Operation: "NULL",
|
||||
},
|
||||
{
|
||||
Operation: "READ",
|
||||
Requests: 1298,
|
||||
Transmissions: 1298,
|
||||
BytesSent: 207680,
|
||||
BytesReceived: 1210292152,
|
||||
CumulativeQueueTime: 6 * time.Millisecond,
|
||||
CumulativeTotalResponseTime: 79386 * time.Millisecond,
|
||||
CumulativeTotalRequestTime: 79407 * time.Millisecond,
|
||||
},
|
||||
{
|
||||
Operation: "WRITE",
|
||||
},
|
||||
},
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "tcp",
|
||||
Port: 832,
|
||||
Connect: 1,
|
||||
IdleTime: 11 * time.Second,
|
||||
Sends: 6428,
|
||||
Receives: 6428,
|
||||
CumulativeActiveRequests: 12154,
|
||||
MaximumRPCSlotsUsed: 24,
|
||||
CumulativeSendingQueue: 26,
|
||||
CumulativePendingQueue: 5726,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
t.Logf("[%02d] test %q", i, tt.name)
|
||||
|
||||
var mounts []*Mount
|
||||
var err error
|
||||
|
||||
if tt.s != "" {
|
||||
mounts, err = parseMountStats(strings.NewReader(tt.s))
|
||||
} else {
|
||||
proc, e := FS("fixtures").NewProc(26231)
|
||||
if e != nil {
|
||||
t.Fatalf("failed to create proc: %v", err)
|
||||
}
|
||||
|
||||
mounts, err = proc.MountStats()
|
||||
}
|
||||
|
||||
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.mounts, mounts; !reflect.DeepEqual(want, have) {
|
||||
t.Errorf("mounts:\nwant:\n%v\nhave:\n%v", mountsStr(want), mountsStr(have))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mountsStr(mounts []*Mount) string {
|
||||
var out string
|
||||
for i, m := range mounts {
|
||||
out += fmt.Sprintf("[%d] %q on %q (%q)", i, m.Device, m.Mount, m.Type)
|
||||
|
||||
stats, ok := m.Stats.(*MountStatsNFS)
|
||||
if !ok {
|
||||
out += "\n"
|
||||
continue
|
||||
}
|
||||
|
||||
out += fmt.Sprintf("\n\t- v%s, age: %s", stats.StatVersion, stats.Age)
|
||||
out += fmt.Sprintf("\n\t- bytes: %v", stats.Bytes)
|
||||
out += fmt.Sprintf("\n\t- events: %v", stats.Events)
|
||||
out += fmt.Sprintf("\n\t- transport: %v", stats.Transport)
|
||||
out += fmt.Sprintf("\n\t- per-operation stats:")
|
||||
|
||||
for _, o := range stats.Operations {
|
||||
out += fmt.Sprintf("\n\t\t- %v", o)
|
||||
}
|
||||
|
||||
out += "\n"
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
86
vendor/github.com/prometheus/procfs/net_dev_test.go
generated
vendored
86
vendor/github.com/prometheus/procfs/net_dev_test.go
generated
vendored
@@ -1,86 +0,0 @@
|
||||
// Copyright 2018 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 (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNetDevParseLine(t *testing.T) {
|
||||
const rawLine = ` eth0: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16`
|
||||
|
||||
have, err := NetDev{}.parseLine(rawLine)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
want := NetDevLine{"eth0", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
|
||||
if want != *have {
|
||||
t.Errorf("want %v, have %v", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewNetDev(t *testing.T) {
|
||||
fs, err := NewFS("fixtures")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
nd, err := fs.NewNetDev()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
lines := map[string]NetDevLine{
|
||||
"vethf345468": {Name: "vethf345468", RxBytes: 648, RxPackets: 8, TxBytes: 438, TxPackets: 5},
|
||||
"lo": {Name: "lo", RxBytes: 1664039048, RxPackets: 1566805, TxBytes: 1664039048, TxPackets: 1566805},
|
||||
"docker0": {Name: "docker0", RxBytes: 2568, RxPackets: 38, TxBytes: 438, TxPackets: 5},
|
||||
"eth0": {Name: "eth0", RxBytes: 874354587, RxPackets: 1036395, TxBytes: 563352563, TxPackets: 732147},
|
||||
}
|
||||
|
||||
if want, have := len(lines), len(nd); want != have {
|
||||
t.Errorf("want %d parsed net/dev lines, have %d", want, have)
|
||||
}
|
||||
for _, line := range nd {
|
||||
if want, have := lines[line.Name], line; want != have {
|
||||
t.Errorf("%s: want %v, have %v", line.Name, want, have)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcNewNetDev(t *testing.T) {
|
||||
p, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
nd, err := p.NewNetDev()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
lines := map[string]NetDevLine{
|
||||
"lo": {Name: "lo"},
|
||||
"eth0": {Name: "eth0", RxBytes: 438, RxPackets: 5, TxBytes: 648, TxPackets: 8},
|
||||
}
|
||||
|
||||
if want, have := len(lines), len(nd); want != have {
|
||||
t.Errorf("want %d parsed net/dev lines, have %d", want, have)
|
||||
}
|
||||
for _, line := range nd {
|
||||
if want, have := lines[line.Name], line; want != have {
|
||||
t.Errorf("%s: want %v, have %v", line.Name, want, have)
|
||||
}
|
||||
}
|
||||
}
|
305
vendor/github.com/prometheus/procfs/nfs/parse_nfs_test.go
generated
vendored
305
vendor/github.com/prometheus/procfs/nfs/parse_nfs_test.go
generated
vendored
@@ -1,305 +0,0 @@
|
||||
// Copyright 2018 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 nfs_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/procfs/nfs"
|
||||
)
|
||||
|
||||
func TestNewNFSClientRPCStats(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
content string
|
||||
stats *nfs.ClientRPCStats
|
||||
invalid bool
|
||||
}{
|
||||
{
|
||||
name: "invalid file",
|
||||
content: "invalid",
|
||||
invalid: true,
|
||||
}, {
|
||||
name: "good old kernel version file",
|
||||
content: `net 70 70 69 45
|
||||
rpc 1218785755 374636 1218815394
|
||||
proc2 18 16 57 74 52 71 73 45 86 0 52 83 61 17 53 50 23 70 82
|
||||
proc3 22 0 1061909262 48906 4077635 117661341 5 29391916 2570425 2993289 590 0 0 7815 15 1130 0 3983 92385 13332 2 1 23729
|
||||
proc4 48 98 51 54 83 85 23 24 1 28 73 68 83 12 84 39 68 59 58 88 29 74 69 96 21 84 15 53 86 54 66 56 97 36 49 32 85 81 11 58 32 67 13 28 35 90 1 26 1337
|
||||
`,
|
||||
stats: &nfs.ClientRPCStats{
|
||||
Network: nfs.Network{
|
||||
NetCount: 70,
|
||||
UDPCount: 70,
|
||||
TCPCount: 69,
|
||||
TCPConnect: 45,
|
||||
},
|
||||
ClientRPC: nfs.ClientRPC{
|
||||
RPCCount: 1218785755,
|
||||
Retransmissions: 374636,
|
||||
AuthRefreshes: 1218815394,
|
||||
},
|
||||
V2Stats: nfs.V2Stats{
|
||||
Null: 16,
|
||||
GetAttr: 57,
|
||||
SetAttr: 74,
|
||||
Root: 52,
|
||||
Lookup: 71,
|
||||
ReadLink: 73,
|
||||
Read: 45,
|
||||
WrCache: 86,
|
||||
Write: 0,
|
||||
Create: 52,
|
||||
Remove: 83,
|
||||
Rename: 61,
|
||||
Link: 17,
|
||||
SymLink: 53,
|
||||
MkDir: 50,
|
||||
RmDir: 23,
|
||||
ReadDir: 70,
|
||||
FsStat: 82,
|
||||
},
|
||||
V3Stats: nfs.V3Stats{
|
||||
Null: 0,
|
||||
GetAttr: 1061909262,
|
||||
SetAttr: 48906,
|
||||
Lookup: 4077635,
|
||||
Access: 117661341,
|
||||
ReadLink: 5,
|
||||
Read: 29391916,
|
||||
Write: 2570425,
|
||||
Create: 2993289,
|
||||
MkDir: 590,
|
||||
SymLink: 0,
|
||||
MkNod: 0,
|
||||
Remove: 7815,
|
||||
RmDir: 15,
|
||||
Rename: 1130,
|
||||
Link: 0,
|
||||
ReadDir: 3983,
|
||||
ReadDirPlus: 92385,
|
||||
FsStat: 13332,
|
||||
FsInfo: 2,
|
||||
PathConf: 1,
|
||||
Commit: 23729},
|
||||
ClientV4Stats: nfs.ClientV4Stats{
|
||||
Null: 98,
|
||||
Read: 51,
|
||||
Write: 54,
|
||||
Commit: 83,
|
||||
Open: 85,
|
||||
OpenConfirm: 23,
|
||||
OpenNoattr: 24,
|
||||
OpenDowngrade: 1,
|
||||
Close: 28,
|
||||
Setattr: 73,
|
||||
FsInfo: 68,
|
||||
Renew: 83,
|
||||
SetClientID: 12,
|
||||
SetClientIDConfirm: 84,
|
||||
Lock: 39,
|
||||
Lockt: 68,
|
||||
Locku: 59,
|
||||
Access: 58,
|
||||
Getattr: 88,
|
||||
Lookup: 29,
|
||||
LookupRoot: 74,
|
||||
Remove: 69,
|
||||
Rename: 96,
|
||||
Link: 21,
|
||||
Symlink: 84,
|
||||
Create: 15,
|
||||
Pathconf: 53,
|
||||
StatFs: 86,
|
||||
ReadLink: 54,
|
||||
ReadDir: 66,
|
||||
ServerCaps: 56,
|
||||
DelegReturn: 97,
|
||||
GetACL: 36,
|
||||
SetACL: 49,
|
||||
FsLocations: 32,
|
||||
ReleaseLockowner: 85,
|
||||
Secinfo: 81,
|
||||
FsidPresent: 11,
|
||||
ExchangeID: 58,
|
||||
CreateSession: 32,
|
||||
DestroySession: 67,
|
||||
Sequence: 13,
|
||||
GetLeaseTime: 28,
|
||||
ReclaimComplete: 35,
|
||||
LayoutGet: 90,
|
||||
GetDeviceInfo: 1,
|
||||
LayoutCommit: 26,
|
||||
LayoutReturn: 1337,
|
||||
SecinfoNoName: 0,
|
||||
TestStateID: 0,
|
||||
FreeStateID: 0,
|
||||
GetDeviceList: 0,
|
||||
BindConnToSession: 0,
|
||||
DestroyClientID: 0,
|
||||
Seek: 0,
|
||||
Allocate: 0,
|
||||
DeAllocate: 0,
|
||||
LayoutStats: 0,
|
||||
Clone: 0,
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "good file",
|
||||
content: `net 18628 0 18628 6
|
||||
rpc 4329785 0 4338291
|
||||
proc2 18 2 69 0 0 4410 0 0 0 0 0 0 0 0 0 0 0 99 2
|
||||
proc3 22 1 4084749 29200 94754 32580 186 47747 7981 8639 0 6356 0 6962 0 7958 0 0 241 4 4 2 39
|
||||
proc4 61 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
`,
|
||||
stats: &nfs.ClientRPCStats{
|
||||
Network: nfs.Network{
|
||||
NetCount: 18628,
|
||||
UDPCount: 0,
|
||||
TCPCount: 18628,
|
||||
TCPConnect: 6,
|
||||
},
|
||||
ClientRPC: nfs.ClientRPC{
|
||||
RPCCount: 4329785,
|
||||
Retransmissions: 0,
|
||||
AuthRefreshes: 4338291,
|
||||
},
|
||||
V2Stats: nfs.V2Stats{
|
||||
Null: 2,
|
||||
GetAttr: 69,
|
||||
SetAttr: 0,
|
||||
Root: 0,
|
||||
Lookup: 4410,
|
||||
ReadLink: 0,
|
||||
Read: 0,
|
||||
WrCache: 0,
|
||||
Write: 0,
|
||||
Create: 0,
|
||||
Remove: 0,
|
||||
Rename: 0,
|
||||
Link: 0,
|
||||
SymLink: 0,
|
||||
MkDir: 0,
|
||||
RmDir: 0,
|
||||
ReadDir: 99,
|
||||
FsStat: 2,
|
||||
},
|
||||
V3Stats: nfs.V3Stats{
|
||||
Null: 1,
|
||||
GetAttr: 4084749,
|
||||
SetAttr: 29200,
|
||||
Lookup: 94754,
|
||||
Access: 32580,
|
||||
ReadLink: 186,
|
||||
Read: 47747,
|
||||
Write: 7981,
|
||||
Create: 8639,
|
||||
MkDir: 0,
|
||||
SymLink: 6356,
|
||||
MkNod: 0,
|
||||
Remove: 6962,
|
||||
RmDir: 0,
|
||||
Rename: 7958,
|
||||
Link: 0,
|
||||
ReadDir: 0,
|
||||
ReadDirPlus: 241,
|
||||
FsStat: 4,
|
||||
FsInfo: 4,
|
||||
PathConf: 2,
|
||||
Commit: 39,
|
||||
},
|
||||
ClientV4Stats: nfs.ClientV4Stats{
|
||||
Null: 1,
|
||||
Read: 0,
|
||||
Write: 0,
|
||||
Commit: 0,
|
||||
Open: 0,
|
||||
OpenConfirm: 0,
|
||||
OpenNoattr: 0,
|
||||
OpenDowngrade: 0,
|
||||
Close: 0,
|
||||
Setattr: 0,
|
||||
FsInfo: 0,
|
||||
Renew: 0,
|
||||
SetClientID: 1,
|
||||
SetClientIDConfirm: 1,
|
||||
Lock: 0,
|
||||
Lockt: 0,
|
||||
Locku: 0,
|
||||
Access: 0,
|
||||
Getattr: 0,
|
||||
Lookup: 0,
|
||||
LookupRoot: 0,
|
||||
Remove: 2,
|
||||
Rename: 0,
|
||||
Link: 0,
|
||||
Symlink: 0,
|
||||
Create: 0,
|
||||
Pathconf: 0,
|
||||
StatFs: 0,
|
||||
ReadLink: 0,
|
||||
ReadDir: 0,
|
||||
ServerCaps: 0,
|
||||
DelegReturn: 0,
|
||||
GetACL: 0,
|
||||
SetACL: 0,
|
||||
FsLocations: 0,
|
||||
ReleaseLockowner: 0,
|
||||
Secinfo: 0,
|
||||
FsidPresent: 0,
|
||||
ExchangeID: 0,
|
||||
CreateSession: 0,
|
||||
DestroySession: 0,
|
||||
Sequence: 0,
|
||||
GetLeaseTime: 0,
|
||||
ReclaimComplete: 0,
|
||||
LayoutGet: 0,
|
||||
GetDeviceInfo: 0,
|
||||
LayoutCommit: 0,
|
||||
LayoutReturn: 0,
|
||||
SecinfoNoName: 0,
|
||||
TestStateID: 0,
|
||||
FreeStateID: 0,
|
||||
GetDeviceList: 0,
|
||||
BindConnToSession: 0,
|
||||
DestroyClientID: 0,
|
||||
Seek: 0,
|
||||
Allocate: 0,
|
||||
DeAllocate: 0,
|
||||
LayoutStats: 0,
|
||||
Clone: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
stats, err := nfs.ParseClientRPCStats(strings.NewReader(tt.content))
|
||||
|
||||
if tt.invalid && err == nil {
|
||||
t.Fatal("expected an error, but none occurred")
|
||||
}
|
||||
if !tt.invalid && err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
if want, have := tt.stats, stats; !reflect.DeepEqual(want, have) {
|
||||
t.Fatalf("unexpected NFS stats:\nwant:\n%v\nhave:\n%v", want, have)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
196
vendor/github.com/prometheus/procfs/nfs/parse_nfsd_test.go
generated
vendored
196
vendor/github.com/prometheus/procfs/nfs/parse_nfsd_test.go
generated
vendored
@@ -1,196 +0,0 @@
|
||||
// Copyright 2018 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 nfs_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/procfs/nfs"
|
||||
)
|
||||
|
||||
func TestNewNFSdServerRPCStats(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
content string
|
||||
stats *nfs.ServerRPCStats
|
||||
invalid bool
|
||||
}{
|
||||
{
|
||||
name: "invalid file",
|
||||
content: "invalid",
|
||||
invalid: true,
|
||||
}, {
|
||||
name: "good file",
|
||||
content: `rc 0 6 18622
|
||||
fh 0 0 0 0 0
|
||||
io 157286400 0
|
||||
th 8 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
|
||||
ra 32 0 0 0 0 0 0 0 0 0 0 0
|
||||
net 18628 0 18628 6
|
||||
rpc 18628 0 0 0 0
|
||||
proc2 18 2 69 0 0 4410 0 0 0 0 0 0 0 0 0 0 0 99 2
|
||||
proc3 22 2 112 0 2719 111 0 0 0 0 0 0 0 0 0 0 0 27 216 0 2 1 0
|
||||
proc4 2 2 10853
|
||||
proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150 1272 0 0 0 1236 0 0 0 0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
`,
|
||||
stats: &nfs.ServerRPCStats{
|
||||
ReplyCache: nfs.ReplyCache{
|
||||
Hits: 0,
|
||||
Misses: 6,
|
||||
NoCache: 18622,
|
||||
},
|
||||
FileHandles: nfs.FileHandles{
|
||||
Stale: 0,
|
||||
TotalLookups: 0,
|
||||
AnonLookups: 0,
|
||||
DirNoCache: 0,
|
||||
NoDirNoCache: 0,
|
||||
},
|
||||
InputOutput: nfs.InputOutput{
|
||||
Read: 157286400,
|
||||
Write: 0,
|
||||
},
|
||||
Threads: nfs.Threads{
|
||||
Threads: 8,
|
||||
FullCnt: 0,
|
||||
},
|
||||
ReadAheadCache: nfs.ReadAheadCache{
|
||||
CacheSize: 32,
|
||||
CacheHistogram: []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
NotFound: 0,
|
||||
},
|
||||
Network: nfs.Network{
|
||||
NetCount: 18628,
|
||||
UDPCount: 0,
|
||||
TCPCount: 18628,
|
||||
TCPConnect: 6,
|
||||
},
|
||||
ServerRPC: nfs.ServerRPC{
|
||||
RPCCount: 18628,
|
||||
BadCnt: 0,
|
||||
BadFmt: 0,
|
||||
BadAuth: 0,
|
||||
BadcInt: 0,
|
||||
},
|
||||
V2Stats: nfs.V2Stats{
|
||||
Null: 2,
|
||||
GetAttr: 69,
|
||||
SetAttr: 0,
|
||||
Root: 0,
|
||||
Lookup: 4410,
|
||||
ReadLink: 0,
|
||||
Read: 0,
|
||||
WrCache: 0,
|
||||
Write: 0,
|
||||
Create: 0,
|
||||
Remove: 0,
|
||||
Rename: 0,
|
||||
Link: 0,
|
||||
SymLink: 0,
|
||||
MkDir: 0,
|
||||
RmDir: 0,
|
||||
ReadDir: 99,
|
||||
FsStat: 2,
|
||||
},
|
||||
V3Stats: nfs.V3Stats{
|
||||
Null: 2,
|
||||
GetAttr: 112,
|
||||
SetAttr: 0,
|
||||
Lookup: 2719,
|
||||
Access: 111,
|
||||
ReadLink: 0,
|
||||
Read: 0,
|
||||
Write: 0,
|
||||
Create: 0,
|
||||
MkDir: 0,
|
||||
SymLink: 0,
|
||||
MkNod: 0,
|
||||
Remove: 0,
|
||||
RmDir: 0,
|
||||
Rename: 0,
|
||||
Link: 0,
|
||||
ReadDir: 27,
|
||||
ReadDirPlus: 216,
|
||||
FsStat: 0,
|
||||
FsInfo: 2,
|
||||
PathConf: 1,
|
||||
Commit: 0,
|
||||
},
|
||||
ServerV4Stats: nfs.ServerV4Stats{
|
||||
Null: 2,
|
||||
Compound: 10853,
|
||||
},
|
||||
V4Ops: nfs.V4Ops{
|
||||
Op0Unused: 0,
|
||||
Op1Unused: 0,
|
||||
Op2Future: 0,
|
||||
Access: 1098,
|
||||
Close: 2,
|
||||
Commit: 0,
|
||||
Create: 0,
|
||||
DelegPurge: 0,
|
||||
DelegReturn: 0,
|
||||
GetAttr: 8179,
|
||||
GetFH: 5896,
|
||||
Link: 0,
|
||||
Lock: 0,
|
||||
Lockt: 0,
|
||||
Locku: 0,
|
||||
Lookup: 5900,
|
||||
LookupRoot: 0,
|
||||
Nverify: 0,
|
||||
Open: 2,
|
||||
OpenAttr: 0,
|
||||
OpenConfirm: 2,
|
||||
OpenDgrd: 0,
|
||||
PutFH: 9609,
|
||||
PutPubFH: 0,
|
||||
PutRootFH: 2,
|
||||
Read: 150,
|
||||
ReadDir: 1272,
|
||||
ReadLink: 0,
|
||||
Remove: 0,
|
||||
Rename: 0,
|
||||
Renew: 1236,
|
||||
RestoreFH: 0,
|
||||
SaveFH: 0,
|
||||
SecInfo: 0,
|
||||
SetAttr: 0,
|
||||
Verify: 3,
|
||||
Write: 3,
|
||||
RelLockOwner: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
stats, err := nfs.ParseServerRPCStats(strings.NewReader(tt.content))
|
||||
|
||||
if tt.invalid && err == nil {
|
||||
t.Fatal("expected an error, but none occurred")
|
||||
}
|
||||
if !tt.invalid && err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
if want, have := tt.stats, stats; !reflect.DeepEqual(want, have) {
|
||||
t.Fatalf("unexpected NFS stats:\nwant:\n%v\nhave:\n%v", want, have)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
46
vendor/github.com/prometheus/procfs/proc_io_test.go
generated
vendored
46
vendor/github.com/prometheus/procfs/proc_io_test.go
generated
vendored
@@ -1,46 +0,0 @@
|
||||
// Copyright 2018 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 "testing"
|
||||
|
||||
func TestProcIO(t *testing.T) {
|
||||
p, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
s, err := p.NewIO()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
want int64
|
||||
have int64
|
||||
}{
|
||||
{name: "RChar", want: 750339, have: int64(s.RChar)},
|
||||
{name: "WChar", want: 818609, have: int64(s.WChar)},
|
||||
{name: "SyscR", want: 7405, have: int64(s.SyscR)},
|
||||
{name: "SyscW", want: 5245, have: int64(s.SyscW)},
|
||||
{name: "ReadBytes", want: 1024, have: int64(s.ReadBytes)},
|
||||
{name: "WriteBytes", want: 2048, have: int64(s.WriteBytes)},
|
||||
{name: "CancelledWriteBytes", want: -1024, have: s.CancelledWriteBytes},
|
||||
} {
|
||||
if test.want != test.have {
|
||||
t.Errorf("want %s %d, have %d", test.name, test.want, test.have)
|
||||
}
|
||||
}
|
||||
}
|
44
vendor/github.com/prometheus/procfs/proc_limits_test.go
generated
vendored
44
vendor/github.com/prometheus/procfs/proc_limits_test.go
generated
vendored
@@ -1,44 +0,0 @@
|
||||
// Copyright 2018 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 "testing"
|
||||
|
||||
func TestNewLimits(t *testing.T) {
|
||||
p, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
l, err := p.NewLimits()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
want int64
|
||||
have int64
|
||||
}{
|
||||
{name: "cpu time", want: -1, have: l.CPUTime},
|
||||
{name: "open files", want: 2048, have: l.OpenFiles},
|
||||
{name: "msgqueue size", want: 819200, have: l.MsqqueueSize},
|
||||
{name: "nice priority", want: 0, have: l.NicePriority},
|
||||
{name: "address space", want: 8589934592, have: l.AddressSpace},
|
||||
} {
|
||||
if test.want != test.have {
|
||||
t.Errorf("want %s %d, have %d", test.name, test.want, test.have)
|
||||
}
|
||||
}
|
||||
}
|
44
vendor/github.com/prometheus/procfs/proc_ns_test.go
generated
vendored
44
vendor/github.com/prometheus/procfs/proc_ns_test.go
generated
vendored
@@ -1,44 +0,0 @@
|
||||
// Copyright 2018 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 (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewNamespaces(t *testing.T) {
|
||||
p, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
namespaces, err := p.NewNamespaces()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expectedNamespaces := map[string]Namespace{
|
||||
"mnt": {"mnt", 4026531840},
|
||||
"net": {"net", 4026531993},
|
||||
}
|
||||
|
||||
if want, have := len(expectedNamespaces), len(namespaces); want != have {
|
||||
t.Errorf("want %d parsed namespaces, have %d", want, have)
|
||||
}
|
||||
for _, ns := range namespaces {
|
||||
if want, have := expectedNamespaces[ns.Type], ns; want != have {
|
||||
t.Errorf("%s: want %v, have %v", ns.Type, want, have)
|
||||
}
|
||||
}
|
||||
}
|
123
vendor/github.com/prometheus/procfs/proc_stat_test.go
generated
vendored
123
vendor/github.com/prometheus/procfs/proc_stat_test.go
generated
vendored
@@ -1,123 +0,0 @@
|
||||
// Copyright 2018 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 (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestProcStat(t *testing.T) {
|
||||
p, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
s, err := p.NewStat()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
want int
|
||||
have int
|
||||
}{
|
||||
{name: "pid", want: 26231, have: s.PID},
|
||||
{name: "user time", want: 1677, have: int(s.UTime)},
|
||||
{name: "system time", want: 44, have: int(s.STime)},
|
||||
{name: "start time", want: 82375, have: int(s.Starttime)},
|
||||
{name: "virtual memory size", want: 56274944, have: s.VSize},
|
||||
{name: "resident set size", want: 1981, have: s.RSS},
|
||||
} {
|
||||
if test.want != test.have {
|
||||
t.Errorf("want %s %d, have %d", test.name, test.want, test.have)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcStatComm(t *testing.T) {
|
||||
s1, err := testProcStat(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want, have := "vim", s1.Comm; want != have {
|
||||
t.Errorf("want comm %s, have %s", want, have)
|
||||
}
|
||||
|
||||
s2, err := testProcStat(584)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want, have := "(a b ) ( c d) ", s2.Comm; want != have {
|
||||
t.Errorf("want comm %s, have %s", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcStatVirtualMemory(t *testing.T) {
|
||||
s, err := testProcStat(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, have := 56274944, s.VirtualMemory(); want != have {
|
||||
t.Errorf("want virtual memory %d, have %d", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcStatResidentMemory(t *testing.T) {
|
||||
s, err := testProcStat(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, have := 1981*os.Getpagesize(), s.ResidentMemory(); want != have {
|
||||
t.Errorf("want resident memory %d, have %d", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcStatStartTime(t *testing.T) {
|
||||
s, err := testProcStat(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
time, err := s.StartTime()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want, have := 1418184099.75, time; want != have {
|
||||
t.Errorf("want start time %f, have %f", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcStatCPUTime(t *testing.T) {
|
||||
s, err := testProcStat(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, have := 17.21, s.CPUTime(); want != have {
|
||||
t.Errorf("want cpu time %f, have %f", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
func testProcStat(pid int) (ProcStat, error) {
|
||||
p, err := FS("fixtures").NewProc(pid)
|
||||
if err != nil {
|
||||
return ProcStat{}, err
|
||||
}
|
||||
|
||||
return p.NewStat()
|
||||
}
|
174
vendor/github.com/prometheus/procfs/proc_test.go
generated
vendored
174
vendor/github.com/prometheus/procfs/proc_test.go
generated
vendored
@@ -1,174 +0,0 @@
|
||||
// Copyright 2018 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 (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSelf(t *testing.T) {
|
||||
fs := FS("fixtures")
|
||||
|
||||
p1, err := fs.NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p2, err := fs.Self()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(p1, p2) {
|
||||
t.Errorf("want process %v, have %v", p1, p2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllProcs(t *testing.T) {
|
||||
procs, err := FS("fixtures").AllProcs()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Sort(procs)
|
||||
for i, p := range []*Proc{{PID: 584}, {PID: 26231}} {
|
||||
if want, have := p.PID, procs[i].PID; want != have {
|
||||
t.Errorf("want processes %d, have %d", want, have)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCmdLine(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
process int
|
||||
want []string
|
||||
}{
|
||||
{process: 26231, want: []string{"vim", "test.go", "+10"}},
|
||||
{process: 26232, want: []string{}},
|
||||
{process: 26233, want: []string{"com.github.uiautomator"}},
|
||||
} {
|
||||
p1, err := FS("fixtures").NewProc(tt.process)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c1, err := p1.CmdLine()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(tt.want, c1) {
|
||||
t.Errorf("want cmdline %v, have %v", tt.want, c1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestComm(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
process int
|
||||
want string
|
||||
}{
|
||||
{process: 26231, want: "vim"},
|
||||
{process: 26232, want: "ata_sff"},
|
||||
} {
|
||||
p1, err := FS("fixtures").NewProc(tt.process)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c1, err := p1.Comm()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(tt.want, c1) {
|
||||
t.Errorf("want comm %v, have %v", tt.want, c1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecutable(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
process int
|
||||
want string
|
||||
}{
|
||||
{process: 26231, want: "/usr/bin/vim"},
|
||||
{process: 26232, want: ""},
|
||||
} {
|
||||
p, err := FS("fixtures").NewProc(tt.process)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
exe, err := p.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(tt.want, exe) {
|
||||
t.Errorf("want absolute path to cmdline %v, have %v", tt.want, exe)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileDescriptors(t *testing.T) {
|
||||
p1, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fds, err := p1.FileDescriptors()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Sort(byUintptr(fds))
|
||||
if want := []uintptr{0, 1, 2, 3, 10}; !reflect.DeepEqual(want, fds) {
|
||||
t.Errorf("want fds %v, have %v", want, fds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileDescriptorTargets(t *testing.T) {
|
||||
p1, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fds, err := p1.FileDescriptorTargets()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(fds)
|
||||
var want = []string{
|
||||
"../../symlinktargets/abc",
|
||||
"../../symlinktargets/def",
|
||||
"../../symlinktargets/ghi",
|
||||
"../../symlinktargets/uvw",
|
||||
"../../symlinktargets/xyz",
|
||||
}
|
||||
if !reflect.DeepEqual(want, fds) {
|
||||
t.Errorf("want fds %v, have %v", want, fds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileDescriptorsLen(t *testing.T) {
|
||||
p1, err := FS("fixtures").NewProc(26231)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
l, err := p1.FileDescriptorsLen()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want, have := 5, l; want != have {
|
||||
t.Errorf("want fds %d, have %d", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
type byUintptr []uintptr
|
||||
|
||||
func (a byUintptr) Len() int { return len(a) }
|
||||
func (a byUintptr) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a byUintptr) Less(i, j int) bool { return a[i] < a[j] }
|
29
vendor/github.com/prometheus/procfs/scripts/check_license.sh
generated
vendored
29
vendor/github.com/prometheus/procfs/scripts/check_license.sh
generated
vendored
@@ -1,29 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright 2018 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.
|
||||
|
||||
check_license() {
|
||||
local file=""
|
||||
for file in $(find . -type f -iname '*.go' ! -path './vendor/*'); do
|
||||
head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" || echo " ${file}"
|
||||
done
|
||||
}
|
||||
|
||||
licRes=$(check_license)
|
||||
|
||||
if [ -n "${licRes}" ]; then
|
||||
echo "license header checking failed:"
|
||||
echo "${licRes}"
|
||||
exit 255
|
||||
fi
|
74
vendor/github.com/prometheus/procfs/stat_test.go
generated
vendored
74
vendor/github.com/prometheus/procfs/stat_test.go
generated
vendored
@@ -1,74 +0,0 @@
|
||||
// Copyright 2018 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 "testing"
|
||||
|
||||
func TestStat(t *testing.T) {
|
||||
s, err := FS("fixtures").NewStat()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// cpu
|
||||
if want, have := float64(301854)/userHZ, s.CPUTotal.User; want != have {
|
||||
t.Errorf("want cpu/user %v, have %v", want, have)
|
||||
}
|
||||
if want, have := float64(31)/userHZ, s.CPU[7].SoftIRQ; want != have {
|
||||
t.Errorf("want cpu7/softirq %v, have %v", want, have)
|
||||
}
|
||||
|
||||
// intr
|
||||
if want, have := uint64(8885917), s.IRQTotal; want != have {
|
||||
t.Errorf("want irq/total %d, have %d", want, have)
|
||||
}
|
||||
if want, have := uint64(1), s.IRQ[8]; want != have {
|
||||
t.Errorf("want irq8 %d, have %d", want, have)
|
||||
}
|
||||
|
||||
// ctxt
|
||||
if want, have := uint64(38014093), s.ContextSwitches; want != have {
|
||||
t.Errorf("want context switches (ctxt) %d, have %d", want, have)
|
||||
}
|
||||
|
||||
// btime
|
||||
if want, have := uint64(1418183276), s.BootTime; want != have {
|
||||
t.Errorf("want boot time (btime) %d, have %d", want, have)
|
||||
}
|
||||
|
||||
// processes
|
||||
if want, have := uint64(26442), s.ProcessCreated; want != have {
|
||||
t.Errorf("want process created (processes) %d, have %d", want, have)
|
||||
}
|
||||
|
||||
// procs_running
|
||||
if want, have := uint64(2), s.ProcessesRunning; want != have {
|
||||
t.Errorf("want processes running (procs_running) %d, have %d", want, have)
|
||||
}
|
||||
|
||||
// procs_blocked
|
||||
if want, have := uint64(1), s.ProcessesBlocked; want != have {
|
||||
t.Errorf("want processes blocked (procs_blocked) %d, have %d", want, have)
|
||||
}
|
||||
|
||||
// softirq
|
||||
if want, have := uint64(5057579), s.SoftIRQTotal; want != have {
|
||||
t.Errorf("want softirq total %d, have %d", want, have)
|
||||
}
|
||||
|
||||
if want, have := uint64(508444), s.SoftIRQ.Rcu; want != have {
|
||||
t.Errorf("want softirq RCU %d, have %d", want, have)
|
||||
}
|
||||
|
||||
}
|
1
vendor/github.com/prometheus/procfs/sysfs/.gitignore
generated
vendored
1
vendor/github.com/prometheus/procfs/sysfs/.gitignore
generated
vendored
@@ -1 +0,0 @@
|
||||
fixtures/
|
16
vendor/github.com/prometheus/procfs/sysfs/doc.go
generated
vendored
16
vendor/github.com/prometheus/procfs/sysfs/doc.go
generated
vendored
@@ -1,16 +0,0 @@
|
||||
// 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 sysfs provides functions to retrieve system and kernel metrics
|
||||
// from the pseudo-filesystem sys.
|
||||
package sysfs
|
857
vendor/github.com/prometheus/procfs/sysfs/fixtures.ttar
generated
vendored
857
vendor/github.com/prometheus/procfs/sysfs/fixtures.ttar
generated
vendored
@@ -1,857 +0,0 @@
|
||||
# Archive created by ttar -C sysfs/ -c -f sysfs/fixtures.ttar fixtures/
|
||||
Directory: fixtures
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/class
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/class/net
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/class/net/eth0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/addr_assign_type
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/addr_len
|
||||
Lines: 1
|
||||
6
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/address
|
||||
Lines: 1
|
||||
01:01:01:01:01:01
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/broadcast
|
||||
Lines: 1
|
||||
ff:ff:ff:ff:ff:ff
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_changes
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_down_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_up_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/dev_id
|
||||
Lines: 1
|
||||
0x20
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/dormant
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/duplex
|
||||
Lines: 1
|
||||
full
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/flags
|
||||
Lines: 1
|
||||
0x1303
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/ifalias
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/ifindex
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/iflink
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/link_mode
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/mtu
|
||||
Lines: 1
|
||||
1500
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/name_assign_type
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/netdev_group
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/operstate
|
||||
Lines: 1
|
||||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_port_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_port_name
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_switch_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/speed
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/tx_queue_len
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/type
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/dirty_data
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/cache_hit_ratio
|
||||
Lines: 1
|
||||
100
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/cache_hits
|
||||
Lines: 1
|
||||
289
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_day/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/cache_hit_ratio
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/cache_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_five_minute/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/cache_hit_ratio
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/cache_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_hour/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/cache_hit_ratio
|
||||
Lines: 1
|
||||
100
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/cache_hits
|
||||
Lines: 1
|
||||
546
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/stats_total/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata5
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/bcache
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/bcache/io_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/bcache/metadata_written
|
||||
Lines: 1
|
||||
512
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/bcache/priority_stats
|
||||
Lines: 5
|
||||
Unused: 99%
|
||||
Metadata: 0%
|
||||
Average: 10473
|
||||
Sectors per Q: 64
|
||||
Quantiles: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946]
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/bcache/written
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/average_key_size
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0
|
||||
Mode: 777
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/dirty_data
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/cache_hit_ratio
|
||||
Lines: 1
|
||||
100
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/cache_hits
|
||||
Lines: 1
|
||||
289
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_day/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/cache_hit_ratio
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/cache_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_five_minute/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/cache_hit_ratio
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/cache_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_hour/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/cache_hit_ratio
|
||||
Lines: 1
|
||||
100
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/cache_hits
|
||||
Lines: 1
|
||||
546
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/stats_total/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/btree_cache_size
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/cache0
|
||||
Mode: 777
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/cache0/io_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/cache0/metadata_written
|
||||
Lines: 1
|
||||
512
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/cache0/priority_stats
|
||||
Lines: 5
|
||||
Unused: 99%
|
||||
Metadata: 0%
|
||||
Average: 10473
|
||||
Sectors per Q: 64
|
||||
Quantiles: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946 20946]
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/cache0/written
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/cache_available_percent
|
||||
Lines: 1
|
||||
100
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/congested
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/internal
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/internal/active_journal_entries
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/internal/btree_nodes
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/internal/btree_read_average_duration_us
|
||||
Lines: 1
|
||||
1305
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/internal/cache_read_races
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/root_usage_percent
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/cache_hit_ratio
|
||||
Lines: 1
|
||||
100
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/cache_hits
|
||||
Lines: 1
|
||||
289
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_day/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/cache_hit_ratio
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/cache_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_five_minute/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/cache_hit_ratio
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/cache_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_hour/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/bypassed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/cache_bypass_hits
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/cache_bypass_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/cache_hit_ratio
|
||||
Lines: 1
|
||||
100
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/cache_hits
|
||||
Lines: 1
|
||||
546
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/cache_miss_collisions
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/cache_misses
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/stats_total/cache_readaheads
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/tree_depth
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/xfs
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/xfs/sda1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/xfs/sda1/stats
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/xfs/sda1/stats/stats
|
||||
Lines: 1
|
||||
extent_alloc 1 0 0 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/xfs/sdb1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/fs/xfs/sdb1/stats
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/fs/xfs/sdb1/stats/stats
|
||||
Lines: 1
|
||||
extent_alloc 2 0 0 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
108
vendor/github.com/prometheus/procfs/sysfs/fs.go
generated
vendored
108
vendor/github.com/prometheus/procfs/sysfs/fs.go
generated
vendored
@@ -1,108 +0,0 @@
|
||||
// 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 sysfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/prometheus/procfs/bcache"
|
||||
"github.com/prometheus/procfs/xfs"
|
||||
)
|
||||
|
||||
// FS represents the pseudo-filesystem sys, which provides an interface to
|
||||
// kernel data structures.
|
||||
type FS string
|
||||
|
||||
// DefaultMountPoint is the common mount point of the sys filesystem.
|
||||
const DefaultMountPoint = "/sys"
|
||||
|
||||
// NewFS returns a new FS mounted under the given mountPoint. It will error
|
||||
// if the mount point can't be read.
|
||||
func NewFS(mountPoint string) (FS, error) {
|
||||
info, err := os.Stat(mountPoint)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not read %s: %s", mountPoint, err)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return "", fmt.Errorf("mount point %s is not a directory", mountPoint)
|
||||
}
|
||||
|
||||
return FS(mountPoint), nil
|
||||
}
|
||||
|
||||
// Path returns the path of the given subsystem relative to the sys root.
|
||||
func (fs FS) Path(p ...string) string {
|
||||
return filepath.Join(append([]string{string(fs)}, p...)...)
|
||||
}
|
||||
|
||||
// XFSStats retrieves XFS filesystem runtime statistics for each mounted XFS
|
||||
// filesystem. Only available on kernel 4.4+. On older kernels, an empty
|
||||
// slice of *xfs.Stats will be returned.
|
||||
func (fs FS) XFSStats() ([]*xfs.Stats, error) {
|
||||
matches, err := filepath.Glob(fs.Path("fs/xfs/*/stats/stats"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stats := make([]*xfs.Stats, 0, len(matches))
|
||||
for _, m := range matches {
|
||||
f, err := os.Open(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// "*" used in glob above indicates the name of the filesystem.
|
||||
name := filepath.Base(filepath.Dir(filepath.Dir(m)))
|
||||
|
||||
// File must be closed after parsing, regardless of success or
|
||||
// failure. Defer is not used because of the loop.
|
||||
s, err := xfs.ParseStats(f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.Name = name
|
||||
stats = append(stats, s)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
108
vendor/github.com/prometheus/procfs/sysfs/fs_test.go
generated
vendored
108
vendor/github.com/prometheus/procfs/sysfs/fs_test.go
generated
vendored
@@ -1,108 +0,0 @@
|
||||
// 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 sysfs
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNewFS(t *testing.T) {
|
||||
if _, err := NewFS("foobar"); err == nil {
|
||||
t.Error("want NewFS to fail for non-existing mount point")
|
||||
}
|
||||
|
||||
if _, err := NewFS("doc.go"); err == nil {
|
||||
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)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
allocated uint32
|
||||
}{
|
||||
{
|
||||
name: "sda1",
|
||||
allocated: 1,
|
||||
},
|
||||
{
|
||||
name: "sdb1",
|
||||
allocated: 2,
|
||||
},
|
||||
}
|
||||
|
||||
const expect = 2
|
||||
|
||||
if l := len(stats); l != expect {
|
||||
t.Fatalf("unexpected number of XFS 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.allocated, stats[i].ExtentAllocation.ExtentsAllocated; want != got {
|
||||
t.Errorf("unexpected extents allocated:\nwant: %d\nhave: %d", want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
174
vendor/github.com/prometheus/procfs/sysfs/net_class.go
generated
vendored
174
vendor/github.com/prometheus/procfs/sysfs/net_class.go
generated
vendored
@@ -1,174 +0,0 @@
|
||||
// Copyright 2018 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 sysfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// NetClassIface contains info from files in /sys/class/net/<iface>
|
||||
// for single interface (iface).
|
||||
type NetClassIface struct {
|
||||
Name string // Interface name
|
||||
AddrAssignType *int64 `fileName:"addr_assign_type"` // /sys/class/net/<iface>/addr_assign_type
|
||||
AddrLen *int64 `fileName:"addr_len"` // /sys/class/net/<iface>/addr_len
|
||||
Address string `fileName:"address"` // /sys/class/net/<iface>/address
|
||||
Broadcast string `fileName:"broadcast"` // /sys/class/net/<iface>/broadcast
|
||||
Carrier *int64 `fileName:"carrier"` // /sys/class/net/<iface>/carrier
|
||||
CarrierChanges *int64 `fileName:"carrier_changes"` // /sys/class/net/<iface>/carrier_changes
|
||||
CarrierUpCount *int64 `fileName:"carrier_up_count"` // /sys/class/net/<iface>/carrier_up_count
|
||||
CarrierDownCount *int64 `fileName:"carrier_down_count"` // /sys/class/net/<iface>/carrier_down_count
|
||||
DevID *int64 `fileName:"dev_id"` // /sys/class/net/<iface>/dev_id
|
||||
Dormant *int64 `fileName:"dormant"` // /sys/class/net/<iface>/dormant
|
||||
Duplex string `fileName:"duplex"` // /sys/class/net/<iface>/duplex
|
||||
Flags *int64 `fileName:"flags"` // /sys/class/net/<iface>/flags
|
||||
IfAlias string `fileName:"ifalias"` // /sys/class/net/<iface>/ifalias
|
||||
IfIndex *int64 `fileName:"ifindex"` // /sys/class/net/<iface>/ifindex
|
||||
IfLink *int64 `fileName:"iflink"` // /sys/class/net/<iface>/iflink
|
||||
LinkMode *int64 `fileName:"link_mode"` // /sys/class/net/<iface>/link_mode
|
||||
MTU *int64 `fileName:"mtu"` // /sys/class/net/<iface>/mtu
|
||||
NameAssignType *int64 `fileName:"name_assign_type"` // /sys/class/net/<iface>/name_assign_type
|
||||
NetDevGroup *int64 `fileName:"netdev_group"` // /sys/class/net/<iface>/netdev_group
|
||||
OperState string `fileName:"operstate"` // /sys/class/net/<iface>/operstate
|
||||
PhysPortID string `fileName:"phys_port_id"` // /sys/class/net/<iface>/phys_port_id
|
||||
PhysPortName string `fileName:"phys_port_name"` // /sys/class/net/<iface>/phys_port_name
|
||||
PhysSwitchID string `fileName:"phys_switch_id"` // /sys/class/net/<iface>/phys_switch_id
|
||||
Speed *int64 `fileName:"speed"` // /sys/class/net/<iface>/speed
|
||||
TxQueueLen *int64 `fileName:"tx_queue_len"` // /sys/class/net/<iface>/tx_queue_len
|
||||
Type *int64 `fileName:"type"` // /sys/class/net/<iface>/type
|
||||
}
|
||||
|
||||
// NetClass is collection of info for every interface (iface) in /sys/class/net. The map keys
|
||||
// are interface (iface) names.
|
||||
type NetClass map[string]NetClassIface
|
||||
|
||||
// NewNetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
|
||||
func NewNetClass() (NetClass, error) {
|
||||
fs, err := NewFS(DefaultMountPoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return fs.NewNetClass()
|
||||
}
|
||||
|
||||
// NewNetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
|
||||
func (fs FS) NewNetClass() (NetClass, error) {
|
||||
path := fs.Path("class/net")
|
||||
|
||||
devices, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return NetClass{}, fmt.Errorf("cannot access %s dir %s", path, err)
|
||||
}
|
||||
|
||||
netClass := NetClass{}
|
||||
for _, deviceDir := range devices {
|
||||
if deviceDir.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
interfaceClass, err := netClass.parseNetClassIface(path + "/" + deviceDir.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
interfaceClass.Name = deviceDir.Name()
|
||||
netClass[deviceDir.Name()] = *interfaceClass
|
||||
}
|
||||
return netClass, nil
|
||||
}
|
||||
|
||||
// parseNetClassIface scans predefined files in /sys/class/net/<iface>
|
||||
// directory and gets their contents.
|
||||
func (nc NetClass) parseNetClassIface(devicePath string) (*NetClassIface, error) {
|
||||
interfaceClass := NetClassIface{}
|
||||
interfaceElem := reflect.ValueOf(&interfaceClass).Elem()
|
||||
interfaceType := reflect.TypeOf(interfaceClass)
|
||||
|
||||
//start from 1 - skip the Name field
|
||||
for i := 1; i < interfaceElem.NumField(); i++ {
|
||||
fieldType := interfaceType.Field(i)
|
||||
fieldValue := interfaceElem.Field(i)
|
||||
|
||||
if fieldType.Tag.Get("fileName") == "" {
|
||||
panic(fmt.Errorf("field %s does not have a filename tag", fieldType.Name))
|
||||
}
|
||||
|
||||
fileContents, err := sysReadFile(devicePath + "/" + fieldType.Tag.Get("fileName"))
|
||||
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" {
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("could not access file %s: %s", fieldType.Tag.Get("fileName"), err)
|
||||
}
|
||||
value := strings.TrimSpace(string(fileContents))
|
||||
|
||||
switch fieldValue.Kind() {
|
||||
case reflect.String:
|
||||
fieldValue.SetString(value)
|
||||
case reflect.Ptr:
|
||||
var int64ptr *int64
|
||||
switch fieldValue.Type() {
|
||||
case reflect.TypeOf(int64ptr):
|
||||
var intValue int64
|
||||
if strings.HasPrefix(value, "0x") {
|
||||
intValue, err = strconv.ParseInt(value[2:], 16, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("expected hex value for %s, got: %s", fieldType.Name, value)
|
||||
}
|
||||
} else {
|
||||
intValue, err = strconv.ParseInt(value, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("expected Uint64 value for %s, got: %s", fieldType.Name, value)
|
||||
}
|
||||
}
|
||||
fieldValue.Set(reflect.ValueOf(&intValue))
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled pointer type %q", fieldValue.Type())
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled type %q", fieldValue.Kind())
|
||||
}
|
||||
}
|
||||
|
||||
return &interfaceClass, nil
|
||||
}
|
||||
|
||||
// sysReadFile is a simplified ioutil.ReadFile that invokes syscall.Read directly.
|
||||
// https://github.com/prometheus/node_exporter/pull/728/files
|
||||
func sysReadFile(file string) ([]byte, error) {
|
||||
f, err := os.Open(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
// On some machines, hwmon drivers are broken and return EAGAIN. This causes
|
||||
// Go's ioutil.ReadFile implementation to poll forever.
|
||||
//
|
||||
// Since we either want to read data or bail immediately, do the simplest
|
||||
// possible read using syscall directly.
|
||||
b := make([]byte, 128)
|
||||
n, err := syscall.Read(int(f.Fd()), b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b[:n], nil
|
||||
}
|
88
vendor/github.com/prometheus/procfs/sysfs/net_class_test.go
generated
vendored
88
vendor/github.com/prometheus/procfs/sysfs/net_class_test.go
generated
vendored
@@ -1,88 +0,0 @@
|
||||
// Copyright 2018 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 sysfs
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewNetClass(t *testing.T) {
|
||||
fs, err := NewFS("fixtures")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
nc, err := fs.NewNetClass()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var (
|
||||
addrAssignType int64 = 3
|
||||
addrLen int64 = 6
|
||||
carrier int64 = 1
|
||||
carrierChanges int64 = 2
|
||||
carrierDownCount int64 = 1
|
||||
carrierUpCount int64 = 1
|
||||
devID int64 = 32
|
||||
dormant int64 = 1
|
||||
flags int64 = 4867
|
||||
ifIndex int64 = 2
|
||||
ifLink int64 = 2
|
||||
linkMode int64 = 1
|
||||
mtu int64 = 1500
|
||||
nameAssignType int64 = 2
|
||||
netDevGroup int64 = 0
|
||||
speed int64 = 1000
|
||||
txQueueLen int64 = 1000
|
||||
netType int64 = 1
|
||||
)
|
||||
|
||||
netClass := NetClass{
|
||||
"eth0": {
|
||||
Address: "01:01:01:01:01:01",
|
||||
AddrAssignType: &addrAssignType,
|
||||
AddrLen: &addrLen,
|
||||
Broadcast: "ff:ff:ff:ff:ff:ff",
|
||||
Carrier: &carrier,
|
||||
CarrierChanges: &carrierChanges,
|
||||
CarrierDownCount: &carrierDownCount,
|
||||
CarrierUpCount: &carrierUpCount,
|
||||
DevID: &devID,
|
||||
Dormant: &dormant,
|
||||
Duplex: "full",
|
||||
Flags: &flags,
|
||||
IfAlias: "",
|
||||
IfIndex: &ifIndex,
|
||||
IfLink: &ifLink,
|
||||
LinkMode: &linkMode,
|
||||
MTU: &mtu,
|
||||
Name: "eth0",
|
||||
NameAssignType: &nameAssignType,
|
||||
NetDevGroup: &netDevGroup,
|
||||
OperState: "up",
|
||||
PhysPortID: "",
|
||||
PhysPortName: "",
|
||||
PhysSwitchID: "",
|
||||
Speed: &speed,
|
||||
TxQueueLen: &txQueueLen,
|
||||
Type: &netType,
|
||||
},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(netClass, nc) {
|
||||
t.Errorf("Result not correct: want %v, have %v", netClass, nc)
|
||||
}
|
||||
}
|
66
vendor/github.com/prometheus/procfs/xfrm_test.go
generated
vendored
66
vendor/github.com/prometheus/procfs/xfrm_test.go
generated
vendored
@@ -1,66 +0,0 @@
|
||||
// Copyright 2017 Prometheus Team
|
||||
// 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 (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestXfrmStats(t *testing.T) {
|
||||
xfrmStats, err := FS("fixtures").NewXfrmStat()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
want int
|
||||
got int
|
||||
}{
|
||||
{name: "XfrmInError", want: 1, got: xfrmStats.XfrmInError},
|
||||
{name: "XfrmInBufferError", want: 2, got: xfrmStats.XfrmInBufferError},
|
||||
{name: "XfrmInHdrError", want: 4, got: xfrmStats.XfrmInHdrError},
|
||||
{name: "XfrmInNoStates", want: 3, got: xfrmStats.XfrmInNoStates},
|
||||
{name: "XfrmInStateProtoError", want: 40, got: xfrmStats.XfrmInStateProtoError},
|
||||
{name: "XfrmInStateModeError", want: 100, got: xfrmStats.XfrmInStateModeError},
|
||||
{name: "XfrmInStateSeqError", want: 6000, got: xfrmStats.XfrmInStateSeqError},
|
||||
{name: "XfrmInStateExpired", want: 4, got: xfrmStats.XfrmInStateExpired},
|
||||
{name: "XfrmInStateMismatch", want: 23451, got: xfrmStats.XfrmInStateMismatch},
|
||||
{name: "XfrmInStateInvalid", want: 55555, got: xfrmStats.XfrmInStateInvalid},
|
||||
{name: "XfrmInTmplMismatch", want: 51, got: xfrmStats.XfrmInTmplMismatch},
|
||||
{name: "XfrmInNoPols", want: 65432, got: xfrmStats.XfrmInNoPols},
|
||||
{name: "XfrmInPolBlock", want: 100, got: xfrmStats.XfrmInPolBlock},
|
||||
{name: "XfrmInPolError", want: 10000, got: xfrmStats.XfrmInPolError},
|
||||
{name: "XfrmOutError", want: 1000000, got: xfrmStats.XfrmOutError},
|
||||
{name: "XfrmOutBundleGenError", want: 43321, got: xfrmStats.XfrmOutBundleGenError},
|
||||
{name: "XfrmOutBundleCheckError", want: 555, got: xfrmStats.XfrmOutBundleCheckError},
|
||||
{name: "XfrmOutNoStates", want: 869, got: xfrmStats.XfrmOutNoStates},
|
||||
{name: "XfrmOutStateProtoError", want: 4542, got: xfrmStats.XfrmOutStateProtoError},
|
||||
{name: "XfrmOutStateModeError", want: 4, got: xfrmStats.XfrmOutStateModeError},
|
||||
{name: "XfrmOutStateSeqError", want: 543, got: xfrmStats.XfrmOutStateSeqError},
|
||||
{name: "XfrmOutStateExpired", want: 565, got: xfrmStats.XfrmOutStateExpired},
|
||||
{name: "XfrmOutPolBlock", want: 43456, got: xfrmStats.XfrmOutPolBlock},
|
||||
{name: "XfrmOutPolDead", want: 7656, got: xfrmStats.XfrmOutPolDead},
|
||||
{name: "XfrmOutPolError", want: 1454, got: xfrmStats.XfrmOutPolError},
|
||||
{name: "XfrmFwdHdrError", want: 6654, got: xfrmStats.XfrmFwdHdrError},
|
||||
{name: "XfrmOutStateInvaliad", want: 28765, got: xfrmStats.XfrmOutStateInvalid},
|
||||
{name: "XfrmAcquireError", want: 24532, got: xfrmStats.XfrmAcquireError},
|
||||
{name: "XfrmInStateInvalid", want: 55555, got: xfrmStats.XfrmInStateInvalid},
|
||||
{name: "XfrmOutError", want: 1000000, got: xfrmStats.XfrmOutError},
|
||||
} {
|
||||
if test.want != test.got {
|
||||
t.Errorf("Want %s %d, have %d", test.name, test.want, test.got)
|
||||
}
|
||||
}
|
||||
}
|
442
vendor/github.com/prometheus/procfs/xfs/parse_test.go
generated
vendored
442
vendor/github.com/prometheus/procfs/xfs/parse_test.go
generated
vendored
@@ -1,442 +0,0 @@
|
||||
// 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 (
|
||||
"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 _, tt := range tests {
|
||||
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) {
|
||||
t.Errorf("unexpected XFS stats:\nwant:\n%v\nhave:\n%v", want, have)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user