mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fnlb was moved to its own repo: fnproject/lb (#702)
* Fnlb was moved to its own repo: fnproject/lb * Clean up fnlb leftovers * Newer deps
This commit is contained in:
committed by
Reed Allman
parent
4ffa3d5005
commit
d3be603e54
1
vendor/github.com/prometheus/client_model/Makefile
generated
vendored
1
vendor/github.com/prometheus/client_model/Makefile
generated
vendored
@@ -39,6 +39,7 @@ src/main/java/io/prometheus/client/Metrics.java: metrics.proto
|
||||
python: python/prometheus/client/model/metrics_pb2.py
|
||||
|
||||
python/prometheus/client/model/metrics_pb2.py: metrics.proto
|
||||
mkdir -p python/prometheus/client/model
|
||||
protoc $< --python_out=python/prometheus/client/model
|
||||
|
||||
ruby:
|
||||
|
||||
10
vendor/github.com/prometheus/common/config/http_config.go
generated
vendored
10
vendor/github.com/prometheus/common/config/http_config.go
generated
vendored
@@ -22,7 +22,7 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// BasicAuth contains basic HTTP authentication credentials.
|
||||
@@ -79,7 +79,9 @@ type HTTPClientConfig struct {
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
}
|
||||
|
||||
func (c *HTTPClientConfig) validate() error {
|
||||
// Validate validates the HTTPClientConfig to check only one of BearerToken,
|
||||
// BasicAuth and BearerTokenFile is configured.
|
||||
func (c *HTTPClientConfig) Validate() error {
|
||||
if len(c.BearerToken) > 0 && len(c.BearerTokenFile) > 0 {
|
||||
return fmt.Errorf("at most one of bearer_token & bearer_token_file must be configured")
|
||||
}
|
||||
@@ -96,9 +98,9 @@ func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) erro
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = c.validate()
|
||||
err = c.Validate()
|
||||
if err != nil {
|
||||
return c.validate()
|
||||
return c.Validate()
|
||||
}
|
||||
return checkOverflow(c.XXX, "http_client_config")
|
||||
}
|
||||
|
||||
2
vendor/github.com/prometheus/common/config/http_config_test.go
generated
vendored
2
vendor/github.com/prometheus/common/config/http_config_test.go
generated
vendored
@@ -114,7 +114,7 @@ func TestValidateHTTPConfig(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Error loading HTTP client config: %v", err)
|
||||
}
|
||||
err = cfg.validate()
|
||||
err = cfg.Validate()
|
||||
if err != nil {
|
||||
t.Fatalf("Error validating %s: %s", "testdata/http.conf.good.yml", err)
|
||||
}
|
||||
|
||||
9
vendor/github.com/prometheus/common/log/log.go
generated
vendored
9
vendor/github.com/prometheus/common/log/log.go
generated
vendored
@@ -56,11 +56,11 @@ func (s *loggerSettings) apply(ctx *kingpin.ParseContext) error {
|
||||
// To use the default Kingpin application, call AddFlags(kingpin.CommandLine)
|
||||
func AddFlags(a *kingpin.Application) {
|
||||
s := loggerSettings{}
|
||||
kingpin.Flag("log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]").
|
||||
a.Flag("log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]").
|
||||
Default(origLogger.Level.String()).
|
||||
StringVar(&s.level)
|
||||
defaultFormat := url.URL{Scheme: "logger", Opaque: "stderr"}
|
||||
kingpin.Flag("log.format", `Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true"`).
|
||||
a.Flag("log.format", `Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true"`).
|
||||
Default(defaultFormat.String()).
|
||||
StringVar(&s.format)
|
||||
a.Action(s.apply)
|
||||
@@ -345,6 +345,11 @@ func Fatalf(format string, args ...interface{}) {
|
||||
baseLogger.sourced().Fatalf(format, args...)
|
||||
}
|
||||
|
||||
// AddHook adds hook to Prometheus' original logger.
|
||||
func AddHook(hook logrus.Hook) {
|
||||
origLogger.Hooks.Add(hook)
|
||||
}
|
||||
|
||||
type errorLogWriter struct{}
|
||||
|
||||
func (errorLogWriter) Write(b []byte) (int, error) {
|
||||
|
||||
3
vendor/github.com/prometheus/common/model/time.go
generated
vendored
3
vendor/github.com/prometheus/common/model/time.go
generated
vendored
@@ -214,6 +214,9 @@ func (d Duration) String() string {
|
||||
ms = int64(time.Duration(d) / time.Millisecond)
|
||||
unit = "ms"
|
||||
)
|
||||
if ms == 0 {
|
||||
return "0s"
|
||||
}
|
||||
factors := map[string]int64{
|
||||
"y": 1000 * 60 * 60 * 24 * 365,
|
||||
"w": 1000 * 60 * 60 * 24 * 7,
|
||||
|
||||
3
vendor/github.com/prometheus/common/model/time_test.go
generated
vendored
3
vendor/github.com/prometheus/common/model/time_test.go
generated
vendored
@@ -91,6 +91,9 @@ func TestParseDuration(t *testing.T) {
|
||||
out time.Duration
|
||||
}{
|
||||
{
|
||||
in: "0s",
|
||||
out: 0,
|
||||
}, {
|
||||
in: "324ms",
|
||||
out: 324 * time.Millisecond,
|
||||
}, {
|
||||
|
||||
8
vendor/github.com/prometheus/procfs/.travis.yml
generated
vendored
8
vendor/github.com/prometheus/procfs/.travis.yml
generated
vendored
@@ -1,5 +1,9 @@
|
||||
sudo: false
|
||||
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.6.4
|
||||
- 1.7.4
|
||||
- 1.9.x
|
||||
- 1.x
|
||||
|
||||
go_import_path: github.com/prometheus/procfs
|
||||
|
||||
16
vendor/github.com/prometheus/procfs/Makefile
generated
vendored
16
vendor/github.com/prometheus/procfs/Makefile
generated
vendored
@@ -1,6 +1,18 @@
|
||||
ci:
|
||||
ci: fmt lint test
|
||||
|
||||
fmt:
|
||||
! gofmt -l *.go | read nothing
|
||||
go vet
|
||||
go test -v ./...
|
||||
|
||||
lint:
|
||||
go get github.com/golang/lint/golint
|
||||
golint *.go
|
||||
|
||||
test: sysfs/fixtures/.unpacked
|
||||
go test -v ./...
|
||||
|
||||
sysfs/fixtures/.unpacked: sysfs/fixtures.ttar
|
||||
./ttar -C sysfs -x -f sysfs/fixtures.ttar
|
||||
touch $@
|
||||
|
||||
.PHONY: fmt lint test ci
|
||||
|
||||
84
vendor/github.com/prometheus/procfs/bcache/bcache.go
generated
vendored
Normal file
84
vendor/github.com/prometheus/procfs/bcache/bcache.go
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
// 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
Normal file
330
vendor/github.com/prometheus/procfs/bcache/get.go
generated
vendored
Normal file
@@ -0,0 +1,330 @@
|
||||
// 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
Normal file
114
vendor/github.com/prometheus/procfs/bcache/get_test.go
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
2
vendor/github.com/prometheus/procfs/buddyinfo.go
generated
vendored
2
vendor/github.com/prometheus/procfs/buddyinfo.go
generated
vendored
@@ -62,7 +62,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
|
||||
for scanner.Scan() {
|
||||
var err error
|
||||
line := scanner.Text()
|
||||
parts := strings.Fields(string(line))
|
||||
parts := strings.Fields(line)
|
||||
|
||||
if len(parts) < 4 {
|
||||
return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo")
|
||||
|
||||
2
vendor/github.com/prometheus/procfs/fixtures/26231/limits
generated
vendored
2
vendor/github.com/prometheus/procfs/fixtures/26231/limits
generated
vendored
@@ -8,7 +8,7 @@ Max resident set unlimited unlimited bytes
|
||||
Max processes 62898 62898 processes
|
||||
Max open files 2048 4096 files
|
||||
Max locked memory 65536 65536 bytes
|
||||
Max address space unlimited unlimited bytes
|
||||
Max address space 8589934592 unlimited bytes
|
||||
Max file locks unlimited unlimited locks
|
||||
Max pending signals 62898 62898 signals
|
||||
Max msgqueue size 819200 819200 bytes
|
||||
|
||||
4
vendor/github.com/prometheus/procfs/fixtures/26231/net/dev
generated
vendored
Normal file
4
vendor/github.com/prometheus/procfs/fixtures/26231/net/dev
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Inter-| Receive | Transmit
|
||||
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
|
||||
lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
eth0: 438 5 0 0 0 0 0 0 648 8 0 0 0 0 0 0
|
||||
1
vendor/github.com/prometheus/procfs/fixtures/26231/ns/mnt
generated
vendored
Symbolic link
1
vendor/github.com/prometheus/procfs/fixtures/26231/ns/mnt
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
mnt:[4026531840]
|
||||
1
vendor/github.com/prometheus/procfs/fixtures/26231/ns/net
generated
vendored
Symbolic link
1
vendor/github.com/prometheus/procfs/fixtures/26231/ns/net
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
net:[4026531993]
|
||||
6
vendor/github.com/prometheus/procfs/fixtures/net/dev
generated
vendored
Normal file
6
vendor/github.com/prometheus/procfs/fixtures/net/dev
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Inter-| Receive | Transmit
|
||||
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
|
||||
vethf345468: 648 8 0 0 0 0 0 0 438 5 0 0 0 0 0 0
|
||||
lo: 1664039048 1566805 0 0 0 0 0 0 1664039048 1566805 0 0 0 0 0 0
|
||||
docker0: 2568 38 0 0 0 0 0 0 438 5 0 0 0 0 0 0
|
||||
eth0: 874354587 1036395 0 0 0 0 0 0 563352563 732147 0 0 0 0 0 0
|
||||
29
vendor/github.com/prometheus/procfs/fixtures/net/ip_vs
generated
vendored
29
vendor/github.com/prometheus/procfs/fixtures/net/ip_vs
generated
vendored
@@ -1,14 +1,21 @@
|
||||
IP Virtual Server version 1.2.1 (size=4096)
|
||||
Prot LocalAddress:Port Scheduler Flags
|
||||
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
|
||||
TCP C0A80016:0CEA wlc
|
||||
-> C0A85216:0CEA Tunnel 100 248 2
|
||||
-> C0A85318:0CEA Tunnel 100 248 2
|
||||
-> C0A85315:0CEA Tunnel 100 248 1
|
||||
TCP C0A80039:0CEA wlc
|
||||
-> C0A85416:0CEA Tunnel 0 0 0
|
||||
-> C0A85215:0CEA Tunnel 100 1499 0
|
||||
-> C0A83215:0CEA Tunnel 100 1498 0
|
||||
TCP C0A80037:0CEA wlc
|
||||
-> C0A8321A:0CEA Tunnel 0 0 0
|
||||
-> C0A83120:0CEA Tunnel 100 0 0
|
||||
TCP C0A80016:0CEA wlc
|
||||
-> C0A85216:0CEA Tunnel 100 248 2
|
||||
-> C0A85318:0CEA Tunnel 100 248 2
|
||||
-> C0A85315:0CEA Tunnel 100 248 1
|
||||
TCP C0A80039:0CEA wlc
|
||||
-> C0A85416:0CEA Tunnel 0 0 0
|
||||
-> C0A85215:0CEA Tunnel 100 1499 0
|
||||
-> C0A83215:0CEA Tunnel 100 1498 0
|
||||
TCP C0A80037:0CEA wlc
|
||||
-> C0A8321A:0CEA Tunnel 0 0 0
|
||||
-> C0A83120:0CEA Tunnel 100 0 0
|
||||
TCP [2620:0000:0000:0000:0000:0000:0000:0001]:0050 sh
|
||||
-> [2620:0000:0000:0000:0000:0000:0000:0002]:0050 Route 1 0 0
|
||||
-> [2620:0000:0000:0000:0000:0000:0000:0003]:0050 Route 1 0 0
|
||||
-> [2620:0000:0000:0000:0000:0000:0000:0004]:0050 Route 1 1 1
|
||||
FWM 10001000 wlc
|
||||
-> C0A8321A:0CEA Route 0 0 1
|
||||
-> C0A83215:0CEA Route 0 0 2
|
||||
|
||||
28
vendor/github.com/prometheus/procfs/fixtures/net/xfrm_stat
generated
vendored
Normal file
28
vendor/github.com/prometheus/procfs/fixtures/net/xfrm_stat
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
XfrmInError 1
|
||||
XfrmInBufferError 2
|
||||
XfrmInHdrError 4
|
||||
XfrmInNoStates 3
|
||||
XfrmInStateProtoError 40
|
||||
XfrmInStateModeError 100
|
||||
XfrmInStateSeqError 6000
|
||||
XfrmInStateExpired 4
|
||||
XfrmInStateMismatch 23451
|
||||
XfrmInStateInvalid 55555
|
||||
XfrmInTmplMismatch 51
|
||||
XfrmInNoPols 65432
|
||||
XfrmInPolBlock 100
|
||||
XfrmInPolError 10000
|
||||
XfrmOutError 1000000
|
||||
XfrmOutBundleGenError 43321
|
||||
XfrmOutBundleCheckError 555
|
||||
XfrmOutNoStates 869
|
||||
XfrmOutStateProtoError 4542
|
||||
XfrmOutStateModeError 4
|
||||
XfrmOutStateSeqError 543
|
||||
XfrmOutStateExpired 565
|
||||
XfrmOutPolBlock 43456
|
||||
XfrmOutPolDead 7656
|
||||
XfrmOutPolError 1454
|
||||
XfrmFwdHdrError 6654
|
||||
XfrmOutStateInvalid 28765
|
||||
XfrmAcquireError 24532
|
||||
2
vendor/github.com/prometheus/procfs/fixtures/stat
generated
vendored
2
vendor/github.com/prometheus/procfs/fixtures/stat
generated
vendored
@@ -12,5 +12,5 @@ ctxt 38014093
|
||||
btime 1418183276
|
||||
processes 26442
|
||||
procs_running 2
|
||||
procs_blocked 0
|
||||
procs_blocked 1
|
||||
softirq 5057579 250191 1481983 1647 211099 186066 0 1783454 622196 12499 508444
|
||||
|
||||
56
vendor/github.com/prometheus/procfs/ipvs.go
generated
vendored
56
vendor/github.com/prometheus/procfs/ipvs.go
generated
vendored
@@ -31,14 +31,16 @@ type IPVSStats struct {
|
||||
type IPVSBackendStatus struct {
|
||||
// The local (virtual) IP address.
|
||||
LocalAddress net.IP
|
||||
// The local (virtual) port.
|
||||
LocalPort uint16
|
||||
// The transport protocol (TCP, UDP).
|
||||
Proto string
|
||||
// The remote (real) IP address.
|
||||
RemoteAddress net.IP
|
||||
// The local (virtual) port.
|
||||
LocalPort uint16
|
||||
// The remote (real) port.
|
||||
RemotePort uint16
|
||||
// The local firewall mark
|
||||
LocalMark string
|
||||
// The transport protocol (TCP, UDP).
|
||||
Proto string
|
||||
// The current number of active connections for this virtual/real address pair.
|
||||
ActiveConn uint64
|
||||
// The current number of inactive connections for this virtual/real address pair.
|
||||
@@ -142,13 +144,14 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
||||
status []IPVSBackendStatus
|
||||
scanner = bufio.NewScanner(file)
|
||||
proto string
|
||||
localMark string
|
||||
localAddress net.IP
|
||||
localPort uint16
|
||||
err error
|
||||
)
|
||||
|
||||
for scanner.Scan() {
|
||||
fields := strings.Fields(string(scanner.Text()))
|
||||
fields := strings.Fields(scanner.Text())
|
||||
if len(fields) == 0 {
|
||||
continue
|
||||
}
|
||||
@@ -160,10 +163,19 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
||||
continue
|
||||
}
|
||||
proto = fields[0]
|
||||
localMark = ""
|
||||
localAddress, localPort, err = parseIPPort(fields[1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case fields[0] == "FWM":
|
||||
if len(fields) < 2 {
|
||||
continue
|
||||
}
|
||||
proto = fields[0]
|
||||
localMark = fields[1]
|
||||
localAddress = nil
|
||||
localPort = 0
|
||||
case fields[0] == "->":
|
||||
if len(fields) < 6 {
|
||||
continue
|
||||
@@ -187,6 +199,7 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
||||
status = append(status, IPVSBackendStatus{
|
||||
LocalAddress: localAddress,
|
||||
LocalPort: localPort,
|
||||
LocalMark: localMark,
|
||||
RemoteAddress: remoteAddress,
|
||||
RemotePort: remotePort,
|
||||
Proto: proto,
|
||||
@@ -200,22 +213,31 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
|
||||
}
|
||||
|
||||
func parseIPPort(s string) (net.IP, uint16, error) {
|
||||
tmp := strings.SplitN(s, ":", 2)
|
||||
var (
|
||||
ip net.IP
|
||||
err error
|
||||
)
|
||||
|
||||
if len(tmp) != 2 {
|
||||
return nil, 0, fmt.Errorf("invalid IP:Port: %s", s)
|
||||
switch len(s) {
|
||||
case 13:
|
||||
ip, err = hex.DecodeString(s[0:8])
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
case 46:
|
||||
ip = net.ParseIP(s[1:40])
|
||||
if ip == nil {
|
||||
return nil, 0, fmt.Errorf("invalid IPv6 address: %s", s[1:40])
|
||||
}
|
||||
default:
|
||||
return nil, 0, fmt.Errorf("unexpected IP:Port: %s", s)
|
||||
}
|
||||
|
||||
if len(tmp[0]) != 8 && len(tmp[0]) != 32 {
|
||||
return nil, 0, fmt.Errorf("invalid IP: %s", tmp[0])
|
||||
portString := s[len(s)-4:]
|
||||
if len(portString) != 4 {
|
||||
return nil, 0, fmt.Errorf("unexpected port string format: %s", portString)
|
||||
}
|
||||
|
||||
ip, err := hex.DecodeString(tmp[0])
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
port, err := strconv.ParseUint(tmp[1], 16, 16)
|
||||
port, err := strconv.ParseUint(portString, 16, 16)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
51
vendor/github.com/prometheus/procfs/ipvs_test.go
generated
vendored
51
vendor/github.com/prometheus/procfs/ipvs_test.go
generated
vendored
@@ -94,6 +94,54 @@ var (
|
||||
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,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -142,14 +190,13 @@ func TestParseIPPortIPv6(t *testing.T) {
|
||||
ip := net.ParseIP("dead:beef::1")
|
||||
port := uint16(8080)
|
||||
|
||||
gotIP, gotPort, err := parseIPPort("DEADBEEF000000000000000000000001:1F90")
|
||||
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) {
|
||||
|
||||
12
vendor/github.com/prometheus/procfs/mountstats.go
generated
vendored
12
vendor/github.com/prometheus/procfs/mountstats.go
generated
vendored
@@ -523,15 +523,19 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
|
||||
}
|
||||
|
||||
// Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay
|
||||
// in a v1.0 response
|
||||
ns := make([]uint64, 0, fieldTransport11Len)
|
||||
for _, s := range ss {
|
||||
// in a v1.0 response.
|
||||
//
|
||||
// Note: slice length must be set to length of v1.1 stats to avoid a panic when
|
||||
// only v1.0 stats are present.
|
||||
// See: https://github.com/prometheus/node_exporter/issues/571.
|
||||
ns := make([]uint64, fieldTransport11Len)
|
||||
for i, s := range ss {
|
||||
n, err := strconv.ParseUint(s, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ns = append(ns, n)
|
||||
ns[i] = n
|
||||
}
|
||||
|
||||
return &NFSTransportStats{
|
||||
|
||||
24
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
24
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
@@ -89,6 +89,30 @@ func TestMountStats(t *testing.T) {
|
||||
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 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{
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 3,
|
||||
ConnectIdleTime: 4,
|
||||
IdleTime: 5 * time.Second,
|
||||
Sends: 6,
|
||||
Receives: 7,
|
||||
BadTransactionIDs: 8,
|
||||
CumulativeActiveRequests: 9,
|
||||
CumulativeBacklog: 10,
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "device rootfs OK",
|
||||
s: `device rootfs mounted on / with fstype rootfs`,
|
||||
|
||||
203
vendor/github.com/prometheus/procfs/net_dev.go
generated
vendored
Normal file
203
vendor/github.com/prometheus/procfs/net_dev.go
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
package procfs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NetDevLine is single line parsed from /proc/net/dev or /proc/[pid]/net/dev.
|
||||
type NetDevLine struct {
|
||||
Name string `json:"name"` // The name of the interface.
|
||||
RxBytes uint64 `json:"rx_bytes"` // Cumulative count of bytes received.
|
||||
RxPackets uint64 `json:"rx_packets"` // Cumulative count of packets received.
|
||||
RxErrors uint64 `json:"rx_errors"` // Cumulative count of receive errors encountered.
|
||||
RxDropped uint64 `json:"rx_dropped"` // Cumulative count of packets dropped while receiving.
|
||||
RxFIFO uint64 `json:"rx_fifo"` // Cumulative count of FIFO buffer errors.
|
||||
RxFrame uint64 `json:"rx_frame"` // Cumulative count of packet framing errors.
|
||||
RxCompressed uint64 `json:"rx_compressed"` // Cumulative count of compressed packets received by the device driver.
|
||||
RxMulticast uint64 `json:"rx_multicast"` // Cumulative count of multicast frames received by the device driver.
|
||||
TxBytes uint64 `json:"tx_bytes"` // Cumulative count of bytes transmitted.
|
||||
TxPackets uint64 `json:"tx_packets"` // Cumulative count of packets transmitted.
|
||||
TxErrors uint64 `json:"tx_errors"` // Cumulative count of transmit errors encountered.
|
||||
TxDropped uint64 `json:"tx_dropped"` // Cumulative count of packets dropped while transmitting.
|
||||
TxFIFO uint64 `json:"tx_fifo"` // Cumulative count of FIFO buffer errors.
|
||||
TxCollisions uint64 `json:"tx_collisions"` // Cumulative count of collisions detected on the interface.
|
||||
TxCarrier uint64 `json:"tx_carrier"` // Cumulative count of carrier losses detected by the device driver.
|
||||
TxCompressed uint64 `json:"tx_compressed"` // Cumulative count of compressed packets transmitted by the device driver.
|
||||
}
|
||||
|
||||
// NetDev is parsed from /proc/net/dev or /proc/[pid]/net/dev. The map keys
|
||||
// are interface names.
|
||||
type NetDev map[string]NetDevLine
|
||||
|
||||
// NewNetDev returns kernel/system statistics read from /proc/net/dev.
|
||||
func NewNetDev() (NetDev, error) {
|
||||
fs, err := NewFS(DefaultMountPoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return fs.NewNetDev()
|
||||
}
|
||||
|
||||
// NewNetDev returns kernel/system statistics read from /proc/net/dev.
|
||||
func (fs FS) NewNetDev() (NetDev, error) {
|
||||
return newNetDev(fs.Path("net/dev"))
|
||||
}
|
||||
|
||||
// NewNetDev returns kernel/system statistics read from /proc/[pid]/net/dev.
|
||||
func (p Proc) NewNetDev() (NetDev, error) {
|
||||
return newNetDev(p.path("net/dev"))
|
||||
}
|
||||
|
||||
// newNetDev creates a new NetDev from the contents of the given file.
|
||||
func newNetDev(file string) (NetDev, error) {
|
||||
f, err := os.Open(file)
|
||||
if err != nil {
|
||||
return NetDev{}, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
nd := NetDev{}
|
||||
s := bufio.NewScanner(f)
|
||||
for n := 0; s.Scan(); n++ {
|
||||
// Skip the 2 header lines.
|
||||
if n < 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
line, err := nd.parseLine(s.Text())
|
||||
if err != nil {
|
||||
return nd, err
|
||||
}
|
||||
|
||||
nd[line.Name] = *line
|
||||
}
|
||||
|
||||
return nd, s.Err()
|
||||
}
|
||||
|
||||
// parseLine parses a single line from the /proc/net/dev file. Header lines
|
||||
// must be filtered prior to calling this method.
|
||||
func (nd NetDev) parseLine(rawLine string) (*NetDevLine, error) {
|
||||
parts := strings.SplitN(rawLine, ":", 2)
|
||||
if len(parts) != 2 {
|
||||
return nil, errors.New("invalid net/dev line, missing colon")
|
||||
}
|
||||
fields := strings.Fields(strings.TrimSpace(parts[1]))
|
||||
|
||||
var err error
|
||||
line := &NetDevLine{}
|
||||
|
||||
// Interface Name
|
||||
line.Name = strings.TrimSpace(parts[0])
|
||||
if line.Name == "" {
|
||||
return nil, errors.New("invalid net/dev line, empty interface name")
|
||||
}
|
||||
|
||||
// RX
|
||||
line.RxBytes, err = strconv.ParseUint(fields[0], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.RxPackets, err = strconv.ParseUint(fields[1], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.RxErrors, err = strconv.ParseUint(fields[2], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.RxDropped, err = strconv.ParseUint(fields[3], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.RxFIFO, err = strconv.ParseUint(fields[4], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.RxFrame, err = strconv.ParseUint(fields[5], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.RxCompressed, err = strconv.ParseUint(fields[6], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.RxMulticast, err = strconv.ParseUint(fields[7], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TX
|
||||
line.TxBytes, err = strconv.ParseUint(fields[8], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.TxPackets, err = strconv.ParseUint(fields[9], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.TxErrors, err = strconv.ParseUint(fields[10], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.TxDropped, err = strconv.ParseUint(fields[11], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.TxFIFO, err = strconv.ParseUint(fields[12], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.TxCollisions, err = strconv.ParseUint(fields[13], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.TxCarrier, err = strconv.ParseUint(fields[14], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
line.TxCompressed, err = strconv.ParseUint(fields[15], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return line, nil
|
||||
}
|
||||
|
||||
// Total aggregates the values across interfaces and returns a new NetDevLine.
|
||||
// The Name field will be a sorted comma seperated list of interface names.
|
||||
func (nd NetDev) Total() NetDevLine {
|
||||
total := NetDevLine{}
|
||||
|
||||
names := make([]string, 0, len(nd))
|
||||
for _, ifc := range nd {
|
||||
names = append(names, ifc.Name)
|
||||
total.RxBytes += ifc.RxBytes
|
||||
total.RxPackets += ifc.RxPackets
|
||||
total.RxPackets += ifc.RxPackets
|
||||
total.RxErrors += ifc.RxErrors
|
||||
total.RxDropped += ifc.RxDropped
|
||||
total.RxFIFO += ifc.RxFIFO
|
||||
total.RxFrame += ifc.RxFrame
|
||||
total.RxCompressed += ifc.RxCompressed
|
||||
total.RxMulticast += ifc.RxMulticast
|
||||
total.TxBytes += ifc.TxBytes
|
||||
total.TxPackets += ifc.TxPackets
|
||||
total.TxErrors += ifc.TxErrors
|
||||
total.TxDropped += ifc.TxDropped
|
||||
total.TxFIFO += ifc.TxFIFO
|
||||
total.TxCollisions += ifc.TxCollisions
|
||||
total.TxCarrier += ifc.TxCarrier
|
||||
total.TxCompressed += ifc.TxCompressed
|
||||
}
|
||||
sort.Strings(names)
|
||||
total.Name = strings.Join(names, ", ")
|
||||
|
||||
return total
|
||||
}
|
||||
73
vendor/github.com/prometheus/procfs/net_dev_test.go
generated
vendored
Normal file
73
vendor/github.com/prometheus/procfs/net_dev_test.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
5
vendor/github.com/prometheus/procfs/proc_io.go
generated
vendored
5
vendor/github.com/prometheus/procfs/proc_io.go
generated
vendored
@@ -47,9 +47,6 @@ func (p Proc) NewIO() (ProcIO, error) {
|
||||
|
||||
_, err = fmt.Sscanf(string(data), ioFormat, &pio.RChar, &pio.WChar, &pio.SyscR,
|
||||
&pio.SyscW, &pio.ReadBytes, &pio.WriteBytes, &pio.CancelledWriteBytes)
|
||||
if err != nil {
|
||||
return pio, err
|
||||
}
|
||||
|
||||
return pio, nil
|
||||
return pio, err
|
||||
}
|
||||
|
||||
38
vendor/github.com/prometheus/procfs/proc_limits.go
generated
vendored
38
vendor/github.com/prometheus/procfs/proc_limits.go
generated
vendored
@@ -13,46 +13,46 @@ import (
|
||||
// http://man7.org/linux/man-pages/man2/getrlimit.2.html.
|
||||
type ProcLimits struct {
|
||||
// CPU time limit in seconds.
|
||||
CPUTime int
|
||||
CPUTime int64
|
||||
// Maximum size of files that the process may create.
|
||||
FileSize int
|
||||
FileSize int64
|
||||
// Maximum size of the process's data segment (initialized data,
|
||||
// uninitialized data, and heap).
|
||||
DataSize int
|
||||
DataSize int64
|
||||
// Maximum size of the process stack in bytes.
|
||||
StackSize int
|
||||
StackSize int64
|
||||
// Maximum size of a core file.
|
||||
CoreFileSize int
|
||||
CoreFileSize int64
|
||||
// Limit of the process's resident set in pages.
|
||||
ResidentSet int
|
||||
ResidentSet int64
|
||||
// Maximum number of processes that can be created for the real user ID of
|
||||
// the calling process.
|
||||
Processes int
|
||||
Processes int64
|
||||
// Value one greater than the maximum file descriptor number that can be
|
||||
// opened by this process.
|
||||
OpenFiles int
|
||||
OpenFiles int64
|
||||
// Maximum number of bytes of memory that may be locked into RAM.
|
||||
LockedMemory int
|
||||
LockedMemory int64
|
||||
// Maximum size of the process's virtual memory address space in bytes.
|
||||
AddressSpace int
|
||||
AddressSpace int64
|
||||
// Limit on the combined number of flock(2) locks and fcntl(2) leases that
|
||||
// this process may establish.
|
||||
FileLocks int
|
||||
FileLocks int64
|
||||
// Limit of signals that may be queued for the real user ID of the calling
|
||||
// process.
|
||||
PendingSignals int
|
||||
PendingSignals int64
|
||||
// Limit on the number of bytes that can be allocated for POSIX message
|
||||
// queues for the real user ID of the calling process.
|
||||
MsqqueueSize int
|
||||
MsqqueueSize int64
|
||||
// Limit of the nice priority set using setpriority(2) or nice(2).
|
||||
NicePriority int
|
||||
NicePriority int64
|
||||
// Limit of the real-time priority set using sched_setscheduler(2) or
|
||||
// sched_setparam(2).
|
||||
RealtimePriority int
|
||||
RealtimePriority int64
|
||||
// Limit (in microseconds) on the amount of CPU time that a process
|
||||
// scheduled under a real-time scheduling policy may consume without making
|
||||
// a blocking system call.
|
||||
RealtimeTimeout int
|
||||
RealtimeTimeout int64
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -125,13 +125,13 @@ func (p Proc) NewLimits() (ProcLimits, error) {
|
||||
return l, s.Err()
|
||||
}
|
||||
|
||||
func parseInt(s string) (int, error) {
|
||||
func parseInt(s string) (int64, error) {
|
||||
if s == limitsUnlimited {
|
||||
return -1, nil
|
||||
}
|
||||
i, err := strconv.ParseInt(s, 10, 32)
|
||||
i, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("couldn't parse value %s: %s", s, err)
|
||||
}
|
||||
return int(i), nil
|
||||
return i, nil
|
||||
}
|
||||
|
||||
6
vendor/github.com/prometheus/procfs/proc_limits_test.go
generated
vendored
6
vendor/github.com/prometheus/procfs/proc_limits_test.go
generated
vendored
@@ -15,14 +15,14 @@ func TestNewLimits(t *testing.T) {
|
||||
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
want int
|
||||
have int
|
||||
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: -1, have: l.AddressSpace},
|
||||
{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)
|
||||
|
||||
55
vendor/github.com/prometheus/procfs/proc_ns.go
generated
vendored
Normal file
55
vendor/github.com/prometheus/procfs/proc_ns.go
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
package procfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Namespace represents a single namespace of a process.
|
||||
type Namespace struct {
|
||||
Type string // Namespace type.
|
||||
Inode uint32 // Inode number of the namespace. If two processes are in the same namespace their inodes will match.
|
||||
}
|
||||
|
||||
// Namespaces contains all of the namespaces that the process is contained in.
|
||||
type Namespaces map[string]Namespace
|
||||
|
||||
// NewNamespaces reads from /proc/[pid/ns/* to get the namespaces of which the
|
||||
// process is a member.
|
||||
func (p Proc) NewNamespaces() (Namespaces, error) {
|
||||
d, err := os.Open(p.path("ns"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer d.Close()
|
||||
|
||||
names, err := d.Readdirnames(-1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read contents of ns dir: %v", err)
|
||||
}
|
||||
|
||||
ns := make(Namespaces, len(names))
|
||||
for _, name := range names {
|
||||
target, err := os.Readlink(p.path("ns", name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fields := strings.SplitN(target, ":", 2)
|
||||
if len(fields) != 2 {
|
||||
return nil, fmt.Errorf("failed to parse namespace type and inode from '%v'", target)
|
||||
}
|
||||
|
||||
typ := fields[0]
|
||||
inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse inode from '%v': %v", fields[1], err)
|
||||
}
|
||||
|
||||
ns[name] = Namespace{typ, uint32(inode)}
|
||||
}
|
||||
|
||||
return ns, nil
|
||||
}
|
||||
31
vendor/github.com/prometheus/procfs/proc_ns_test.go
generated
vendored
Normal file
31
vendor/github.com/prometheus/procfs/proc_ns_test.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
193
vendor/github.com/prometheus/procfs/stat.go
generated
vendored
193
vendor/github.com/prometheus/procfs/stat.go
generated
vendored
@@ -3,15 +3,66 @@ package procfs
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CPUStat shows how much time the cpu spend in various stages.
|
||||
type CPUStat struct {
|
||||
User float64
|
||||
Nice float64
|
||||
System float64
|
||||
Idle float64
|
||||
Iowait float64
|
||||
IRQ float64
|
||||
SoftIRQ float64
|
||||
Steal float64
|
||||
Guest float64
|
||||
GuestNice float64
|
||||
}
|
||||
|
||||
// SoftIRQStat represent the softirq statistics as exported in the procfs stat file.
|
||||
// A nice introduction can be found at https://0xax.gitbooks.io/linux-insides/content/interrupts/interrupts-9.html
|
||||
// It is possible to get per-cpu stats by reading /proc/softirqs
|
||||
type SoftIRQStat struct {
|
||||
Hi uint64
|
||||
Timer uint64
|
||||
NetTx uint64
|
||||
NetRx uint64
|
||||
Block uint64
|
||||
BlockIoPoll uint64
|
||||
Tasklet uint64
|
||||
Sched uint64
|
||||
Hrtimer uint64
|
||||
Rcu uint64
|
||||
}
|
||||
|
||||
// Stat represents kernel/system statistics.
|
||||
type Stat struct {
|
||||
// Boot time in seconds since the Epoch.
|
||||
BootTime int64
|
||||
BootTime uint64
|
||||
// Summed up cpu statistics.
|
||||
CPUTotal CPUStat
|
||||
// Per-CPU statistics.
|
||||
CPU []CPUStat
|
||||
// Number of times interrupts were handled, which contains numbered and unnumbered IRQs.
|
||||
IRQTotal uint64
|
||||
// Number of times a numbered IRQ was triggered.
|
||||
IRQ []uint64
|
||||
// Number of times a context switch happened.
|
||||
ContextSwitches uint64
|
||||
// Number of times a process was created.
|
||||
ProcessCreated uint64
|
||||
// Number of processes currently running.
|
||||
ProcessesRunning uint64
|
||||
// Number of processes currently blocked (waiting for IO).
|
||||
ProcessesBlocked uint64
|
||||
// Number of times a softirq was scheduled.
|
||||
SoftIRQTotal uint64
|
||||
// Detailed softirq statistics.
|
||||
SoftIRQ SoftIRQStat
|
||||
}
|
||||
|
||||
// NewStat returns kernel/system statistics read from /proc/stat.
|
||||
@@ -24,33 +75,145 @@ func NewStat() (Stat, error) {
|
||||
return fs.NewStat()
|
||||
}
|
||||
|
||||
// Parse a cpu statistics line and returns the CPUStat struct plus the cpu id (or -1 for the overall sum).
|
||||
func parseCPUStat(line string) (CPUStat, int64, error) {
|
||||
cpuStat := CPUStat{}
|
||||
var cpu string
|
||||
|
||||
count, err := fmt.Sscanf(line, "%s %f %f %f %f %f %f %f %f %f %f",
|
||||
&cpu,
|
||||
&cpuStat.User, &cpuStat.Nice, &cpuStat.System, &cpuStat.Idle,
|
||||
&cpuStat.Iowait, &cpuStat.IRQ, &cpuStat.SoftIRQ, &cpuStat.Steal,
|
||||
&cpuStat.Guest, &cpuStat.GuestNice)
|
||||
|
||||
if err != nil && err != io.EOF {
|
||||
return CPUStat{}, -1, fmt.Errorf("couldn't parse %s (cpu): %s", line, err)
|
||||
}
|
||||
if count == 0 {
|
||||
return CPUStat{}, -1, fmt.Errorf("couldn't parse %s (cpu): 0 elements parsed", line)
|
||||
}
|
||||
|
||||
cpuStat.User /= userHZ
|
||||
cpuStat.Nice /= userHZ
|
||||
cpuStat.System /= userHZ
|
||||
cpuStat.Idle /= userHZ
|
||||
cpuStat.Iowait /= userHZ
|
||||
cpuStat.IRQ /= userHZ
|
||||
cpuStat.SoftIRQ /= userHZ
|
||||
cpuStat.Steal /= userHZ
|
||||
cpuStat.Guest /= userHZ
|
||||
cpuStat.GuestNice /= userHZ
|
||||
|
||||
if cpu == "cpu" {
|
||||
return cpuStat, -1, nil
|
||||
}
|
||||
|
||||
cpuID, err := strconv.ParseInt(cpu[3:], 10, 64)
|
||||
if err != nil {
|
||||
return CPUStat{}, -1, fmt.Errorf("couldn't parse %s (cpu/cpuid): %s", line, err)
|
||||
}
|
||||
|
||||
return cpuStat, cpuID, nil
|
||||
}
|
||||
|
||||
// Parse a softirq line.
|
||||
func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) {
|
||||
softIRQStat := SoftIRQStat{}
|
||||
var total uint64
|
||||
var prefix string
|
||||
|
||||
_, err := fmt.Sscanf(line, "%s %d %d %d %d %d %d %d %d %d %d %d",
|
||||
&prefix, &total,
|
||||
&softIRQStat.Hi, &softIRQStat.Timer, &softIRQStat.NetTx, &softIRQStat.NetRx,
|
||||
&softIRQStat.Block, &softIRQStat.BlockIoPoll,
|
||||
&softIRQStat.Tasklet, &softIRQStat.Sched,
|
||||
&softIRQStat.Hrtimer, &softIRQStat.Rcu)
|
||||
|
||||
if err != nil {
|
||||
return SoftIRQStat{}, 0, fmt.Errorf("couldn't parse %s (softirq): %s", line, err)
|
||||
}
|
||||
|
||||
return softIRQStat, total, nil
|
||||
}
|
||||
|
||||
// NewStat returns an information about current kernel/system statistics.
|
||||
func (fs FS) NewStat() (Stat, error) {
|
||||
// See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
||||
|
||||
f, err := os.Open(fs.Path("stat"))
|
||||
if err != nil {
|
||||
return Stat{}, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
s := bufio.NewScanner(f)
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
if !strings.HasPrefix(line, "btime") {
|
||||
stat := Stat{}
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
parts := strings.Fields(scanner.Text())
|
||||
// require at least <key> <value>
|
||||
if len(parts) < 2 {
|
||||
continue
|
||||
}
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) != 2 {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s line %s", f.Name(), line)
|
||||
switch {
|
||||
case parts[0] == "btime":
|
||||
if stat.BootTime, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s (btime): %s", parts[1], err)
|
||||
}
|
||||
case parts[0] == "intr":
|
||||
if stat.IRQTotal, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s (intr): %s", parts[1], err)
|
||||
}
|
||||
numberedIRQs := parts[2:]
|
||||
stat.IRQ = make([]uint64, len(numberedIRQs))
|
||||
for i, count := range numberedIRQs {
|
||||
if stat.IRQ[i], err = strconv.ParseUint(count, 10, 64); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s (intr%d): %s", count, i, err)
|
||||
}
|
||||
}
|
||||
case parts[0] == "ctxt":
|
||||
if stat.ContextSwitches, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s (ctxt): %s", parts[1], err)
|
||||
}
|
||||
case parts[0] == "processes":
|
||||
if stat.ProcessCreated, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s (processes): %s", parts[1], err)
|
||||
}
|
||||
case parts[0] == "procs_running":
|
||||
if stat.ProcessesRunning, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s (procs_running): %s", parts[1], err)
|
||||
}
|
||||
case parts[0] == "procs_blocked":
|
||||
if stat.ProcessesBlocked, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s (procs_blocked): %s", parts[1], err)
|
||||
}
|
||||
case parts[0] == "softirq":
|
||||
softIRQStats, total, err := parseSoftIRQStat(line)
|
||||
if err != nil {
|
||||
return Stat{}, err
|
||||
}
|
||||
stat.SoftIRQTotal = total
|
||||
stat.SoftIRQ = softIRQStats
|
||||
case strings.HasPrefix(parts[0], "cpu"):
|
||||
cpuStat, cpuID, err := parseCPUStat(line)
|
||||
if err != nil {
|
||||
return Stat{}, err
|
||||
}
|
||||
if cpuID == -1 {
|
||||
stat.CPUTotal = cpuStat
|
||||
} else {
|
||||
for int64(len(stat.CPU)) <= cpuID {
|
||||
stat.CPU = append(stat.CPU, CPUStat{})
|
||||
}
|
||||
stat.CPU[cpuID] = cpuStat
|
||||
}
|
||||
}
|
||||
i, err := strconv.ParseInt(fields[1], 10, 32)
|
||||
if err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s: %s", fields[1], err)
|
||||
}
|
||||
return Stat{BootTime: i}, nil
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s: %s", f.Name(), err)
|
||||
}
|
||||
|
||||
return Stat{}, fmt.Errorf("couldn't parse %s, missing btime", f.Name())
|
||||
return stat, nil
|
||||
}
|
||||
|
||||
51
vendor/github.com/prometheus/procfs/stat_test.go
generated
vendored
51
vendor/github.com/prometheus/procfs/stat_test.go
generated
vendored
@@ -8,7 +8,54 @@ func TestStat(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, have := int64(1418183276), s.BootTime; want != have {
|
||||
t.Errorf("want boot time %d, have %d", want, have)
|
||||
// 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
Normal file
1
vendor/github.com/prometheus/procfs/sysfs/.gitignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
fixtures/
|
||||
16
vendor/github.com/prometheus/procfs/sysfs/doc.go
generated
vendored
Normal file
16
vendor/github.com/prometheus/procfs/sysfs/doc.go
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// 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
|
||||
721
vendor/github.com/prometheus/procfs/sysfs/fixtures.ttar
generated
vendored
Normal file
721
vendor/github.com/prometheus/procfs/sysfs/fixtures.ttar
generated
vendored
Normal file
@@ -0,0 +1,721 @@
|
||||
Directory: fixtures
|
||||
Mode: 755
|
||||
# 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
Normal file
108
vendor/github.com/prometheus/procfs/sysfs/fs.go
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
// 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
Normal file
108
vendor/github.com/prometheus/procfs/sysfs/fs_test.go
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
264
vendor/github.com/prometheus/procfs/ttar
generated
vendored
Executable file
264
vendor/github.com/prometheus/procfs/ttar
generated
vendored
Executable file
@@ -0,0 +1,264 @@
|
||||
#!/usr/bin/env bash
|
||||
# Purpose: plain text tar format
|
||||
# Limitations: - only suitable for text files, directories, and symlinks
|
||||
# - stores only filename, content, and mode
|
||||
# - not designed for untrusted input
|
||||
|
||||
# Note: must work with bash version 3.2 (macOS)
|
||||
|
||||
set -o errexit -o nounset
|
||||
|
||||
# Sanitize environment (for instance, standard sorting of glob matches)
|
||||
export LC_ALL=C
|
||||
|
||||
path=""
|
||||
CMD=""
|
||||
|
||||
function usage {
|
||||
bname=$(basename "$0")
|
||||
cat << USAGE
|
||||
Usage: $bname [-C <DIR>] -c -f <ARCHIVE> <FILE...> (create archive)
|
||||
$bname -t -f <ARCHIVE> (list archive contents)
|
||||
$bname [-C <DIR>] -x -f <ARCHIVE> (extract archive)
|
||||
|
||||
Options:
|
||||
-C <DIR> (change directory)
|
||||
|
||||
Example: Change to sysfs directory, create ttar file from fixtures directory
|
||||
$bname -C sysfs -c -f sysfs/fixtures.ttar fixtures/
|
||||
USAGE
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
function vecho {
|
||||
if [ "${VERBOSE:-}" == "yes" ]; then
|
||||
echo >&7 "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function set_cmd {
|
||||
if [ -n "$CMD" ]; then
|
||||
echo "ERROR: more than one command given"
|
||||
echo
|
||||
usage 2
|
||||
fi
|
||||
CMD=$1
|
||||
}
|
||||
|
||||
while getopts :cf:htxvC: opt; do
|
||||
case $opt in
|
||||
c)
|
||||
set_cmd "create"
|
||||
;;
|
||||
f)
|
||||
ARCHIVE=$OPTARG
|
||||
;;
|
||||
h)
|
||||
usage 0
|
||||
;;
|
||||
t)
|
||||
set_cmd "list"
|
||||
;;
|
||||
x)
|
||||
set_cmd "extract"
|
||||
;;
|
||||
v)
|
||||
VERBOSE=yes
|
||||
exec 7>&1
|
||||
;;
|
||||
C)
|
||||
CDIR=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo >&2 "ERROR: invalid option -$OPTARG"
|
||||
echo
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Remove processed options from arguments
|
||||
shift $(( OPTIND - 1 ));
|
||||
|
||||
if [ "${CMD:-}" == "" ]; then
|
||||
echo >&2 "ERROR: no command given"
|
||||
echo
|
||||
usage 1
|
||||
elif [ "${ARCHIVE:-}" == "" ]; then
|
||||
echo >&2 "ERROR: no archive name given"
|
||||
echo
|
||||
usage 1
|
||||
fi
|
||||
|
||||
function list {
|
||||
local path=""
|
||||
local size=0
|
||||
local line_no=0
|
||||
local ttar_file=$1
|
||||
if [ -n "${2:-}" ]; then
|
||||
echo >&2 "ERROR: too many arguments."
|
||||
echo
|
||||
usage 1
|
||||
fi
|
||||
if [ ! -e "$ttar_file" ]; then
|
||||
echo >&2 "ERROR: file not found ($ttar_file)"
|
||||
echo
|
||||
usage 1
|
||||
fi
|
||||
while read -r line; do
|
||||
line_no=$(( line_no + 1 ))
|
||||
if [ $size -gt 0 ]; then
|
||||
size=$(( size - 1 ))
|
||||
continue
|
||||
fi
|
||||
if [[ $line =~ ^Path:\ (.*)$ ]]; then
|
||||
path=${BASH_REMATCH[1]}
|
||||
elif [[ $line =~ ^Lines:\ (.*)$ ]]; then
|
||||
size=${BASH_REMATCH[1]}
|
||||
echo "$path"
|
||||
elif [[ $line =~ ^Directory:\ (.*)$ ]]; then
|
||||
path=${BASH_REMATCH[1]}
|
||||
echo "$path/"
|
||||
elif [[ $line =~ ^SymlinkTo:\ (.*)$ ]]; then
|
||||
echo "$path -> ${BASH_REMATCH[1]}"
|
||||
fi
|
||||
done < "$ttar_file"
|
||||
}
|
||||
|
||||
function extract {
|
||||
local path=""
|
||||
local size=0
|
||||
local line_no=0
|
||||
local ttar_file=$1
|
||||
if [ -n "${2:-}" ]; then
|
||||
echo >&2 "ERROR: too many arguments."
|
||||
echo
|
||||
usage 1
|
||||
fi
|
||||
if [ ! -e "$ttar_file" ]; then
|
||||
echo >&2 "ERROR: file not found ($ttar_file)"
|
||||
echo
|
||||
usage 1
|
||||
fi
|
||||
while IFS= read -r line; do
|
||||
line_no=$(( line_no + 1 ))
|
||||
if [ "$size" -gt 0 ]; then
|
||||
echo "$line" >> "$path"
|
||||
size=$(( size - 1 ))
|
||||
continue
|
||||
fi
|
||||
if [[ $line =~ ^Path:\ (.*)$ ]]; then
|
||||
path=${BASH_REMATCH[1]}
|
||||
if [ -e "$path" ] || [ -L "$path" ]; then
|
||||
rm "$path"
|
||||
fi
|
||||
elif [[ $line =~ ^Lines:\ (.*)$ ]]; then
|
||||
size=${BASH_REMATCH[1]}
|
||||
# Create file even if it is zero-length.
|
||||
touch "$path"
|
||||
vecho " $path"
|
||||
elif [[ $line =~ ^Mode:\ (.*)$ ]]; then
|
||||
mode=${BASH_REMATCH[1]}
|
||||
chmod "$mode" "$path"
|
||||
vecho "$mode"
|
||||
elif [[ $line =~ ^Directory:\ (.*)$ ]]; then
|
||||
path=${BASH_REMATCH[1]}
|
||||
mkdir -p "$path"
|
||||
vecho " $path/"
|
||||
elif [[ $line =~ ^SymlinkTo:\ (.*)$ ]]; then
|
||||
ln -s "${BASH_REMATCH[1]}" "$path"
|
||||
vecho " $path -> ${BASH_REMATCH[1]}"
|
||||
elif [[ $line =~ ^# ]]; then
|
||||
# Ignore comments between files
|
||||
continue
|
||||
else
|
||||
echo >&2 "ERROR: Unknown keyword on line $line_no: $line"
|
||||
exit 1
|
||||
fi
|
||||
done < "$ttar_file"
|
||||
}
|
||||
|
||||
function div {
|
||||
echo "# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" \
|
||||
"- - - - - -"
|
||||
}
|
||||
|
||||
function get_mode {
|
||||
local mfile=$1
|
||||
if [ -z "${STAT_OPTION:-}" ]; then
|
||||
if stat -c '%a' "$mfile" >/dev/null 2>&1; then
|
||||
STAT_OPTION='-c'
|
||||
STAT_FORMAT='%a'
|
||||
else
|
||||
STAT_OPTION='-f'
|
||||
STAT_FORMAT='%A'
|
||||
fi
|
||||
fi
|
||||
stat "${STAT_OPTION}" "${STAT_FORMAT}" "$mfile"
|
||||
}
|
||||
|
||||
function _create {
|
||||
shopt -s nullglob
|
||||
local mode
|
||||
while (( "$#" )); do
|
||||
file=$1
|
||||
if [ -L "$file" ]; then
|
||||
echo "Path: $file"
|
||||
symlinkTo=$(readlink "$file")
|
||||
echo "SymlinkTo: $symlinkTo"
|
||||
vecho " $file -> $symlinkTo"
|
||||
div
|
||||
elif [ -d "$file" ]; then
|
||||
# Strip trailing slash (if there is one)
|
||||
file=${file%/}
|
||||
echo "Directory: $file"
|
||||
mode=$(get_mode "$file")
|
||||
echo "Mode: $mode"
|
||||
vecho "$mode $file/"
|
||||
div
|
||||
# Find all files and dirs, including hidden/dot files
|
||||
for x in "$file/"{*,.[^.]*}; do
|
||||
_create "$x"
|
||||
done
|
||||
elif [ -f "$file" ]; then
|
||||
echo "Path: $file"
|
||||
lines=$(wc -l "$file"|awk '{print $1}')
|
||||
echo "Lines: $lines"
|
||||
cat "$file"
|
||||
mode=$(get_mode "$file")
|
||||
echo "Mode: $mode"
|
||||
vecho "$mode $file"
|
||||
div
|
||||
else
|
||||
echo >&2 "ERROR: file not found ($file in $(pwd))"
|
||||
exit 2
|
||||
fi
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
function create {
|
||||
ttar_file=$1
|
||||
shift
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo >&2 "ERROR: missing arguments."
|
||||
echo
|
||||
usage 1
|
||||
fi
|
||||
if [ -e "$ttar_file" ]; then
|
||||
rm "$ttar_file"
|
||||
fi
|
||||
exec > "$ttar_file"
|
||||
_create "$@"
|
||||
}
|
||||
|
||||
if [ -n "${CDIR:-}" ]; then
|
||||
if [[ "$ARCHIVE" != /* ]]; then
|
||||
# Relative path: preserve the archive's location before changing
|
||||
# directory
|
||||
ARCHIVE="$(pwd)/$ARCHIVE"
|
||||
fi
|
||||
cd "$CDIR"
|
||||
fi
|
||||
|
||||
"$CMD" "$ARCHIVE" "$@"
|
||||
187
vendor/github.com/prometheus/procfs/xfrm.go
generated
vendored
Normal file
187
vendor/github.com/prometheus/procfs/xfrm.go
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
// 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 (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// XfrmStat models the contents of /proc/net/xfrm_stat.
|
||||
type XfrmStat struct {
|
||||
// All errors which are not matched by other
|
||||
XfrmInError int
|
||||
// No buffer is left
|
||||
XfrmInBufferError int
|
||||
// Header Error
|
||||
XfrmInHdrError int
|
||||
// No state found
|
||||
// i.e. either inbound SPI, address, or IPSEC protocol at SA is wrong
|
||||
XfrmInNoStates int
|
||||
// Transformation protocol specific error
|
||||
// e.g. SA Key is wrong
|
||||
XfrmInStateProtoError int
|
||||
// Transformation mode specific error
|
||||
XfrmInStateModeError int
|
||||
// Sequence error
|
||||
// e.g. sequence number is out of window
|
||||
XfrmInStateSeqError int
|
||||
// State is expired
|
||||
XfrmInStateExpired int
|
||||
// State has mismatch option
|
||||
// e.g. UDP encapsulation type is mismatched
|
||||
XfrmInStateMismatch int
|
||||
// State is invalid
|
||||
XfrmInStateInvalid int
|
||||
// No matching template for states
|
||||
// e.g. Inbound SAs are correct but SP rule is wrong
|
||||
XfrmInTmplMismatch int
|
||||
// No policy is found for states
|
||||
// e.g. Inbound SAs are correct but no SP is found
|
||||
XfrmInNoPols int
|
||||
// Policy discards
|
||||
XfrmInPolBlock int
|
||||
// Policy error
|
||||
XfrmInPolError int
|
||||
// All errors which are not matched by others
|
||||
XfrmOutError int
|
||||
// Bundle generation error
|
||||
XfrmOutBundleGenError int
|
||||
// Bundle check error
|
||||
XfrmOutBundleCheckError int
|
||||
// No state was found
|
||||
XfrmOutNoStates int
|
||||
// Transformation protocol specific error
|
||||
XfrmOutStateProtoError int
|
||||
// Transportation mode specific error
|
||||
XfrmOutStateModeError int
|
||||
// Sequence error
|
||||
// i.e sequence number overflow
|
||||
XfrmOutStateSeqError int
|
||||
// State is expired
|
||||
XfrmOutStateExpired int
|
||||
// Policy discads
|
||||
XfrmOutPolBlock int
|
||||
// Policy is dead
|
||||
XfrmOutPolDead int
|
||||
// Policy Error
|
||||
XfrmOutPolError int
|
||||
XfrmFwdHdrError int
|
||||
XfrmOutStateInvalid int
|
||||
XfrmAcquireError int
|
||||
}
|
||||
|
||||
// NewXfrmStat reads the xfrm_stat statistics.
|
||||
func NewXfrmStat() (XfrmStat, error) {
|
||||
fs, err := NewFS(DefaultMountPoint)
|
||||
if err != nil {
|
||||
return XfrmStat{}, err
|
||||
}
|
||||
|
||||
return fs.NewXfrmStat()
|
||||
}
|
||||
|
||||
// NewXfrmStat reads the xfrm_stat statistics from the 'proc' filesystem.
|
||||
func (fs FS) NewXfrmStat() (XfrmStat, error) {
|
||||
file, err := os.Open(fs.Path("net/xfrm_stat"))
|
||||
if err != nil {
|
||||
return XfrmStat{}, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
var (
|
||||
x = XfrmStat{}
|
||||
s = bufio.NewScanner(file)
|
||||
)
|
||||
|
||||
for s.Scan() {
|
||||
fields := strings.Fields(s.Text())
|
||||
|
||||
if len(fields) != 2 {
|
||||
return XfrmStat{}, fmt.Errorf(
|
||||
"couldnt parse %s line %s", file.Name(), s.Text())
|
||||
}
|
||||
|
||||
name := fields[0]
|
||||
value, err := strconv.Atoi(fields[1])
|
||||
if err != nil {
|
||||
return XfrmStat{}, err
|
||||
}
|
||||
|
||||
switch name {
|
||||
case "XfrmInError":
|
||||
x.XfrmInError = value
|
||||
case "XfrmInBufferError":
|
||||
x.XfrmInBufferError = value
|
||||
case "XfrmInHdrError":
|
||||
x.XfrmInHdrError = value
|
||||
case "XfrmInNoStates":
|
||||
x.XfrmInNoStates = value
|
||||
case "XfrmInStateProtoError":
|
||||
x.XfrmInStateProtoError = value
|
||||
case "XfrmInStateModeError":
|
||||
x.XfrmInStateModeError = value
|
||||
case "XfrmInStateSeqError":
|
||||
x.XfrmInStateSeqError = value
|
||||
case "XfrmInStateExpired":
|
||||
x.XfrmInStateExpired = value
|
||||
case "XfrmInStateInvalid":
|
||||
x.XfrmInStateInvalid = value
|
||||
case "XfrmInTmplMismatch":
|
||||
x.XfrmInTmplMismatch = value
|
||||
case "XfrmInNoPols":
|
||||
x.XfrmInNoPols = value
|
||||
case "XfrmInPolBlock":
|
||||
x.XfrmInPolBlock = value
|
||||
case "XfrmInPolError":
|
||||
x.XfrmInPolError = value
|
||||
case "XfrmOutError":
|
||||
x.XfrmOutError = value
|
||||
case "XfrmInStateMismatch":
|
||||
x.XfrmInStateMismatch = value
|
||||
case "XfrmOutBundleGenError":
|
||||
x.XfrmOutBundleGenError = value
|
||||
case "XfrmOutBundleCheckError":
|
||||
x.XfrmOutBundleCheckError = value
|
||||
case "XfrmOutNoStates":
|
||||
x.XfrmOutNoStates = value
|
||||
case "XfrmOutStateProtoError":
|
||||
x.XfrmOutStateProtoError = value
|
||||
case "XfrmOutStateModeError":
|
||||
x.XfrmOutStateModeError = value
|
||||
case "XfrmOutStateSeqError":
|
||||
x.XfrmOutStateSeqError = value
|
||||
case "XfrmOutStateExpired":
|
||||
x.XfrmOutStateExpired = value
|
||||
case "XfrmOutPolBlock":
|
||||
x.XfrmOutPolBlock = value
|
||||
case "XfrmOutPolDead":
|
||||
x.XfrmOutPolDead = value
|
||||
case "XfrmOutPolError":
|
||||
x.XfrmOutPolError = value
|
||||
case "XfrmFwdHdrError":
|
||||
x.XfrmFwdHdrError = value
|
||||
case "XfrmOutStateInvalid":
|
||||
x.XfrmOutStateInvalid = value
|
||||
case "XfrmAcquireError":
|
||||
x.XfrmAcquireError = value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return x, s.Err()
|
||||
}
|
||||
66
vendor/github.com/prometheus/procfs/xfrm_test.go
generated
vendored
Normal file
66
vendor/github.com/prometheus/procfs/xfrm_test.go
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
2
vendor/github.com/prometheus/procfs/xfs/parse.go
generated
vendored
2
vendor/github.com/prometheus/procfs/xfs/parse.go
generated
vendored
@@ -17,7 +17,6 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -273,7 +272,6 @@ func vnodeStats(us []uint32) (VnodeStats, error) {
|
||||
// stats versions. Therefore, 7 or 8 elements may appear in
|
||||
// this slice.
|
||||
l := len(us)
|
||||
log.Println(l)
|
||||
if l != 7 && l != 8 {
|
||||
return VnodeStats{}, fmt.Errorf("incorrect number of values for XFS vnode stats: %d", l)
|
||||
}
|
||||
|
||||
6
vendor/github.com/prometheus/procfs/xfs/parse_test.go
generated
vendored
6
vendor/github.com/prometheus/procfs/xfs/parse_test.go
generated
vendored
@@ -14,7 +14,6 @@
|
||||
package xfs_test
|
||||
|
||||
import (
|
||||
"log"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -416,9 +415,7 @@ func TestParseStats(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
t.Logf("[%02d] test %q", i, tt.name)
|
||||
|
||||
for _, tt := range tests {
|
||||
var (
|
||||
stats *xfs.Stats
|
||||
err error
|
||||
@@ -439,7 +436,6 @@ func TestParseStats(t *testing.T) {
|
||||
}
|
||||
|
||||
if want, have := tt.stats, stats; !reflect.DeepEqual(want, have) {
|
||||
log.Printf("stats: %#v", have)
|
||||
t.Errorf("unexpected XFS stats:\nwant:\n%v\nhave:\n%v", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
5
vendor/github.com/prometheus/procfs/xfs/xfs.go
generated
vendored
5
vendor/github.com/prometheus/procfs/xfs/xfs.go
generated
vendored
@@ -22,6 +22,11 @@ package xfs
|
||||
// kernel source. Most counters are uint32s (same data types used in
|
||||
// xfs_stats.h), but some of the "extended precision stats" are uint64s.
|
||||
type Stats struct {
|
||||
// The name of the filesystem used to source these statistics.
|
||||
// If empty, this indicates aggregated statistics for all XFS
|
||||
// filesystems on the host.
|
||||
Name string
|
||||
|
||||
ExtentAllocation ExtentAllocationStats
|
||||
AllocationBTree BTreeStats
|
||||
BlockMapping BlockMappingStats
|
||||
|
||||
Reference in New Issue
Block a user