mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
opentracing -> opencensus (#802)
* update vendor directory, add go.opencensus.io * update imports * oops * s/opentracing/opencensus/ & remove prometheus / zipkin stuff & remove old stats * the dep train rides again * fix gin build * deps from last guy * start in on the agent metrics * she builds * remove tags for now, cardinality error is fussing. subscribe instead of register * update to patched version of opencensus to proceed for now TODO switch to a release * meh fix imports * println debug the bad boys * lace it with the tags * update deps again * fix all inconsistent cardinality errors * add our own logger * fix init * fix oom measure * remove bugged removal code * fix s3 measures * fix prom handler nil
This commit is contained in:
5
vendor/github.com/prometheus/procfs/.travis.yml
generated
vendored
5
vendor/github.com/prometheus/procfs/.travis.yml
generated
vendored
@@ -3,7 +3,10 @@ sudo: false
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.x
|
||||
|
||||
go_import_path: github.com/prometheus/procfs
|
||||
|
||||
script:
|
||||
- make style check_license vet test staticcheck
|
||||
|
||||
71
vendor/github.com/prometheus/procfs/Makefile
generated
vendored
71
vendor/github.com/prometheus/procfs/Makefile
generated
vendored
@@ -1,18 +1,71 @@
|
||||
ci: fmt lint test
|
||||
# Copyright 2018 The Prometheus Authors
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
fmt:
|
||||
! gofmt -l *.go | read nothing
|
||||
go vet
|
||||
# Ensure GOBIN is not set during build so that promu is installed to the correct path
|
||||
unexport GOBIN
|
||||
|
||||
lint:
|
||||
go get github.com/golang/lint/golint
|
||||
golint *.go
|
||||
GO ?= go
|
||||
GOFMT ?= $(GO)fmt
|
||||
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
|
||||
STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
|
||||
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
|
||||
|
||||
PREFIX ?= $(shell pwd)
|
||||
BIN_DIR ?= $(shell pwd)
|
||||
|
||||
ifdef DEBUG
|
||||
bindata_flags = -debug
|
||||
endif
|
||||
|
||||
STATICCHECK_IGNORE =
|
||||
|
||||
all: format staticcheck build test
|
||||
|
||||
style:
|
||||
@echo ">> checking code style"
|
||||
@! $(GOFMT) -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
|
||||
|
||||
check_license:
|
||||
@echo ">> checking license header"
|
||||
@./scripts/check_license.sh
|
||||
|
||||
test: sysfs/fixtures/.unpacked
|
||||
go test -v ./...
|
||||
@echo ">> running all tests"
|
||||
@$(GO) test -race $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
|
||||
|
||||
format:
|
||||
@echo ">> formatting code"
|
||||
@$(GO) fmt $(pkgs)
|
||||
|
||||
vet:
|
||||
@echo ">> vetting code"
|
||||
@$(GO) vet $(pkgs)
|
||||
|
||||
staticcheck: $(STATICCHECK)
|
||||
@echo ">> running staticcheck"
|
||||
@$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
|
||||
|
||||
sysfs/fixtures/.unpacked: sysfs/fixtures.ttar
|
||||
./ttar -C sysfs -x -f sysfs/fixtures.ttar
|
||||
touch $@
|
||||
|
||||
.PHONY: fmt lint test ci
|
||||
$(FIRST_GOPATH)/bin/staticcheck:
|
||||
@GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
|
||||
|
||||
.PHONY: all style check_license format test vet staticcheck
|
||||
|
||||
# Declaring the binaries at their default locations as PHONY targets is a hack
|
||||
# to ensure the latest version is downloaded on every make execution.
|
||||
# If this is not desired, copy/symlink these binaries to a different path and
|
||||
# set the respective environment variables.
|
||||
.PHONY: $(GOPATH)/bin/staticcheck
|
||||
|
||||
BIN
vendor/github.com/prometheus/procfs/fixtures/26233/cmdline
generated
vendored
Normal file
BIN
vendor/github.com/prometheus/procfs/fixtures/26233/cmdline
generated
vendored
Normal file
Binary file not shown.
5
vendor/github.com/prometheus/procfs/fixtures/net/rpc/nfs
generated
vendored
Normal file
5
vendor/github.com/prometheus/procfs/fixtures/net/rpc/nfs
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
net 18628 0 18628 6
|
||||
rpc 4329785 0 4338291
|
||||
proc2 18 2 69 0 0 4410 0 0 0 0 0 0 0 0 0 0 0 99 2
|
||||
proc3 22 1 4084749 29200 94754 32580 186 47747 7981 8639 0 6356 0 6962 0 7958 0 0 241 4 4 2 39
|
||||
proc4 61 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
32
vendor/github.com/prometheus/procfs/fs.go
generated
vendored
32
vendor/github.com/prometheus/procfs/fs.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
@@ -5,7 +18,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/prometheus/procfs/nfsd"
|
||||
"github.com/prometheus/procfs/nfs"
|
||||
"github.com/prometheus/procfs/xfs"
|
||||
)
|
||||
|
||||
@@ -46,13 +59,24 @@ func (fs FS) XFSStats() (*xfs.Stats, error) {
|
||||
return xfs.ParseStats(f)
|
||||
}
|
||||
|
||||
// NFSdRPCStats retrieves NFS daemon RPC statistics.
|
||||
func (fs FS) NFSdRPCStats() (*nfsd.RPCStats, error) {
|
||||
// NFSClientRPCStats retrieves NFS client RPC statistics.
|
||||
func (fs FS) NFSClientRPCStats() (*nfs.ClientRPCStats, error) {
|
||||
f, err := os.Open(fs.Path("net/rpc/nfs"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return nfs.ParseClientRPCStats(f)
|
||||
}
|
||||
|
||||
// NFSdServerRPCStats retrieves NFS daemon RPC statistics.
|
||||
func (fs FS) NFSdServerRPCStats() (*nfs.ServerRPCStats, error) {
|
||||
f, err := os.Open(fs.Path("net/rpc/nfsd"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return nfsd.ParseRPCStats(f)
|
||||
return nfs.ParseServerRPCStats(f)
|
||||
}
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/fs_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/fs_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import "testing"
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/ipvs.go
generated
vendored
13
vendor/github.com/prometheus/procfs/ipvs.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/ipvs_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/ipvs_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/mdstat.go
generated
vendored
13
vendor/github.com/prometheus/procfs/mdstat.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/mdstat_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/mdstat_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/mountstats.go
generated
vendored
13
vendor/github.com/prometheus/procfs/mountstats.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
// While implementing parsing of /proc/[pid]/mountstats, this blog was used
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/net_dev.go
generated
vendored
13
vendor/github.com/prometheus/procfs/net_dev.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/net_dev_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/net_dev_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
// Package nfsd implements parsing of /proc/net/rpc/nfsd.
|
||||
// Fields are documented in https://www.svennd.be/nfsd-stats-explained-procnetrpcnfsd/
|
||||
package nfsd
|
||||
package nfs
|
||||
|
||||
// ReplyCache models the "rc" line.
|
||||
type ReplyCache struct {
|
||||
@@ -58,8 +58,15 @@ type Network struct {
|
||||
TCPConnect uint64
|
||||
}
|
||||
|
||||
// RPC models the "rpc" line.
|
||||
type RPC struct {
|
||||
// ClientRPC models the nfs "rpc" line.
|
||||
type ClientRPC struct {
|
||||
RPCCount uint64
|
||||
Retransmissions uint64
|
||||
AuthRefreshes uint64
|
||||
}
|
||||
|
||||
// ServerRPC models the nfsd "rpc" line.
|
||||
type ServerRPC struct {
|
||||
RPCCount uint64
|
||||
BadCnt uint64
|
||||
BadFmt uint64
|
||||
@@ -115,8 +122,71 @@ type V3Stats struct {
|
||||
Commit uint64
|
||||
}
|
||||
|
||||
// V4Stats models the "proc4" line.
|
||||
type V4Stats struct {
|
||||
// ClientV4Stats models the nfs "proc4" line.
|
||||
type ClientV4Stats struct {
|
||||
Null uint64
|
||||
Read uint64
|
||||
Write uint64
|
||||
Commit uint64
|
||||
Open uint64
|
||||
OpenConfirm uint64
|
||||
OpenNoattr uint64
|
||||
OpenDowngrade uint64
|
||||
Close uint64
|
||||
Setattr uint64
|
||||
FsInfo uint64
|
||||
Renew uint64
|
||||
SetClientId uint64
|
||||
SetClientIdConfirm uint64
|
||||
Lock uint64
|
||||
Lockt uint64
|
||||
Locku uint64
|
||||
Access uint64
|
||||
Getattr uint64
|
||||
Lookup uint64
|
||||
LookupRoot uint64
|
||||
Remove uint64
|
||||
Rename uint64
|
||||
Link uint64
|
||||
Symlink uint64
|
||||
Create uint64
|
||||
Pathconf uint64
|
||||
StatFs uint64
|
||||
ReadLink uint64
|
||||
ReadDir uint64
|
||||
ServerCaps uint64
|
||||
DelegReturn uint64
|
||||
GetAcl uint64
|
||||
SetAcl uint64
|
||||
FsLocations uint64
|
||||
ReleaseLockowner uint64
|
||||
Secinfo uint64
|
||||
FsidPresent uint64
|
||||
ExchangeId uint64
|
||||
CreateSession uint64
|
||||
DestroySession uint64
|
||||
Sequence uint64
|
||||
GetLeaseTime uint64
|
||||
ReclaimComplete uint64
|
||||
LayoutGet uint64
|
||||
GetDeviceInfo uint64
|
||||
LayoutCommit uint64
|
||||
LayoutReturn uint64
|
||||
SecinfoNoName uint64
|
||||
TestStateId uint64
|
||||
FreeStateId uint64
|
||||
GetDeviceList uint64
|
||||
BindConnToSession uint64
|
||||
DestroyClientId uint64
|
||||
Seek uint64
|
||||
Allocate uint64
|
||||
DeAllocate uint64
|
||||
LayoutStats uint64
|
||||
Clone uint64
|
||||
}
|
||||
|
||||
// ServerV4Stats models the nfsd "proc4" line.
|
||||
type ServerV4Stats struct {
|
||||
Null uint64
|
||||
Compound uint64
|
||||
}
|
||||
@@ -168,17 +238,26 @@ type V4Ops struct {
|
||||
RelLockOwner uint64
|
||||
}
|
||||
|
||||
// RPCStats models all stats from /proc/net/rpc/nfsd.
|
||||
type RPCStats struct {
|
||||
// RPCStats models all stats from /proc/net/rpc/nfs.
|
||||
type ClientRPCStats struct {
|
||||
Network Network
|
||||
ClientRPC ClientRPC
|
||||
V2Stats V2Stats
|
||||
V3Stats V3Stats
|
||||
ClientV4Stats ClientV4Stats
|
||||
}
|
||||
|
||||
// ServerRPCStats models all stats from /proc/net/rpc/nfsd.
|
||||
type ServerRPCStats struct {
|
||||
ReplyCache ReplyCache
|
||||
FileHandles FileHandles
|
||||
InputOutput InputOutput
|
||||
Threads Threads
|
||||
ReadAheadCache ReadAheadCache
|
||||
Network Network
|
||||
RPC RPC
|
||||
ServerRPC ServerRPC
|
||||
V2Stats V2Stats
|
||||
V3Stats V3Stats
|
||||
V4Stats V4Stats
|
||||
ServerV4Stats ServerV4Stats
|
||||
V4Ops V4Ops
|
||||
}
|
||||
@@ -11,83 +11,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nfsd
|
||||
package nfs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
// ParseRPCStats returns stats read from /proc/net/rpc/nfsd
|
||||
func ParseRPCStats(r io.Reader) (*RPCStats, error) {
|
||||
stats := &RPCStats{}
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
parts := strings.Fields(scanner.Text())
|
||||
// require at least <key> <value>
|
||||
if len(parts) < 2 {
|
||||
return nil, fmt.Errorf("invalid NFSd metric line %q", line)
|
||||
}
|
||||
label := parts[0]
|
||||
|
||||
var values []uint64
|
||||
var err error
|
||||
if label == "th" {
|
||||
if len(parts) < 3 {
|
||||
return nil, fmt.Errorf("invalid NFSd th metric line %q", line)
|
||||
}
|
||||
values, err = util.ParseUint64s(parts[1:3])
|
||||
} else {
|
||||
values, err = util.ParseUint64s(parts[1:])
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing NFSd metric line: %s", err)
|
||||
}
|
||||
|
||||
switch metricLine := parts[0]; metricLine {
|
||||
case "rc":
|
||||
stats.ReplyCache, err = parseReplyCache(values)
|
||||
case "fh":
|
||||
stats.FileHandles, err = parseFileHandles(values)
|
||||
case "io":
|
||||
stats.InputOutput, err = parseInputOutput(values)
|
||||
case "th":
|
||||
stats.Threads, err = parseThreads(values)
|
||||
case "ra":
|
||||
stats.ReadAheadCache, err = parseReadAheadCache(values)
|
||||
case "net":
|
||||
stats.Network, err = parseNetwork(values)
|
||||
case "rpc":
|
||||
stats.RPC, err = parseRPC(values)
|
||||
case "proc2":
|
||||
stats.V2Stats, err = parseV2Stats(values)
|
||||
case "proc3":
|
||||
stats.V3Stats, err = parseV3Stats(values)
|
||||
case "proc4":
|
||||
stats.V4Stats, err = parseV4Stats(values)
|
||||
case "proc4ops":
|
||||
stats.V4Ops, err = parseV4Ops(values)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown NFSd metric line %q", metricLine)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("errors parsing NFSd metric line: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, fmt.Errorf("error scanning NFSd file: %s", err)
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func parseReplyCache(v []uint64) (ReplyCache, error) {
|
||||
if len(v) != 3 {
|
||||
return ReplyCache{}, fmt.Errorf("invalid ReplyCache line %q", v)
|
||||
@@ -161,12 +90,12 @@ func parseNetwork(v []uint64) (Network, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseRPC(v []uint64) (RPC, error) {
|
||||
func parseServerRPC(v []uint64) (ServerRPC, error) {
|
||||
if len(v) != 5 {
|
||||
return RPC{}, fmt.Errorf("invalid RPC line %q", v)
|
||||
return ServerRPC{}, fmt.Errorf("invalid RPC line %q", v)
|
||||
}
|
||||
|
||||
return RPC{
|
||||
return ServerRPC{
|
||||
RPCCount: v[0],
|
||||
BadCnt: v[1],
|
||||
BadFmt: v[2],
|
||||
@@ -175,6 +104,18 @@ func parseRPC(v []uint64) (RPC, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseClientRPC(v []uint64) (ClientRPC, error) {
|
||||
if len(v) != 3 {
|
||||
return ClientRPC{}, fmt.Errorf("invalid RPC line %q", v)
|
||||
}
|
||||
|
||||
return ClientRPC{
|
||||
RPCCount: v[0],
|
||||
Retransmissions: v[1],
|
||||
AuthRefreshes: v[2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseV2Stats(v []uint64) (V2Stats, error) {
|
||||
values := int(v[0])
|
||||
if len(v[1:]) != values || values != 18 {
|
||||
@@ -235,13 +176,91 @@ func parseV3Stats(v []uint64) (V3Stats, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseV4Stats(v []uint64) (V4Stats, error) {
|
||||
func parseClientV4Stats(v []uint64) (ClientV4Stats, error) {
|
||||
values := int(v[0])
|
||||
if len(v[1:]) != values || values != 2 {
|
||||
return V4Stats{}, fmt.Errorf("invalid V4Stats line %q", v)
|
||||
if len(v[1:]) != values {
|
||||
return ClientV4Stats{}, fmt.Errorf("invalid ClientV4Stats line %q", v)
|
||||
}
|
||||
|
||||
return V4Stats{
|
||||
// This function currently supports mapping 59 NFS v4 client stats. Older
|
||||
// kernels may emit fewer stats, so we must detect this and pad out the
|
||||
// values to match the expected slice size.
|
||||
if values < 59 {
|
||||
newValues := make([]uint64, 60)
|
||||
copy(newValues, v)
|
||||
v = newValues
|
||||
}
|
||||
|
||||
return ClientV4Stats{
|
||||
Null: v[1],
|
||||
Read: v[2],
|
||||
Write: v[3],
|
||||
Commit: v[4],
|
||||
Open: v[5],
|
||||
OpenConfirm: v[6],
|
||||
OpenNoattr: v[7],
|
||||
OpenDowngrade: v[8],
|
||||
Close: v[9],
|
||||
Setattr: v[10],
|
||||
FsInfo: v[11],
|
||||
Renew: v[12],
|
||||
SetClientId: v[13],
|
||||
SetClientIdConfirm: v[14],
|
||||
Lock: v[15],
|
||||
Lockt: v[16],
|
||||
Locku: v[17],
|
||||
Access: v[18],
|
||||
Getattr: v[19],
|
||||
Lookup: v[20],
|
||||
LookupRoot: v[21],
|
||||
Remove: v[22],
|
||||
Rename: v[23],
|
||||
Link: v[24],
|
||||
Symlink: v[25],
|
||||
Create: v[26],
|
||||
Pathconf: v[27],
|
||||
StatFs: v[28],
|
||||
ReadLink: v[29],
|
||||
ReadDir: v[30],
|
||||
ServerCaps: v[31],
|
||||
DelegReturn: v[32],
|
||||
GetAcl: v[33],
|
||||
SetAcl: v[34],
|
||||
FsLocations: v[35],
|
||||
ReleaseLockowner: v[36],
|
||||
Secinfo: v[37],
|
||||
FsidPresent: v[38],
|
||||
ExchangeId: v[39],
|
||||
CreateSession: v[40],
|
||||
DestroySession: v[41],
|
||||
Sequence: v[42],
|
||||
GetLeaseTime: v[43],
|
||||
ReclaimComplete: v[44],
|
||||
LayoutGet: v[45],
|
||||
GetDeviceInfo: v[46],
|
||||
LayoutCommit: v[47],
|
||||
LayoutReturn: v[48],
|
||||
SecinfoNoName: v[49],
|
||||
TestStateId: v[50],
|
||||
FreeStateId: v[51],
|
||||
GetDeviceList: v[52],
|
||||
BindConnToSession: v[53],
|
||||
DestroyClientId: v[54],
|
||||
Seek: v[55],
|
||||
Allocate: v[56],
|
||||
DeAllocate: v[57],
|
||||
LayoutStats: v[58],
|
||||
Clone: v[59],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseServerV4Stats(v []uint64) (ServerV4Stats, error) {
|
||||
values := int(v[0])
|
||||
if len(v[1:]) != values || values != 2 {
|
||||
return ServerV4Stats{}, fmt.Errorf("invalid V4Stats line %q", v)
|
||||
}
|
||||
|
||||
return ServerV4Stats{
|
||||
Null: v[1],
|
||||
Compound: v[2],
|
||||
}, nil
|
||||
67
vendor/github.com/prometheus/procfs/nfs/parse_nfs.go
generated
vendored
Normal file
67
vendor/github.com/prometheus/procfs/nfs/parse_nfs.go
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nfs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
// ParseClientRPCStats returns stats read from /proc/net/rpc/nfs
|
||||
func ParseClientRPCStats(r io.Reader) (*ClientRPCStats, error) {
|
||||
stats := &ClientRPCStats{}
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
parts := strings.Fields(scanner.Text())
|
||||
// require at least <key> <value>
|
||||
if len(parts) < 2 {
|
||||
return nil, fmt.Errorf("invalid NFS metric line %q", line)
|
||||
}
|
||||
|
||||
values, err := util.ParseUint64s(parts[1:])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing NFS metric line: %s", err)
|
||||
}
|
||||
|
||||
switch metricLine := parts[0]; metricLine {
|
||||
case "net":
|
||||
stats.Network, err = parseNetwork(values)
|
||||
case "rpc":
|
||||
stats.ClientRPC, err = parseClientRPC(values)
|
||||
case "proc2":
|
||||
stats.V2Stats, err = parseV2Stats(values)
|
||||
case "proc3":
|
||||
stats.V3Stats, err = parseV3Stats(values)
|
||||
case "proc4":
|
||||
stats.ClientV4Stats, err = parseClientV4Stats(values)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown NFS metric line %q", metricLine)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("errors parsing NFS metric line: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, fmt.Errorf("error scanning NFS file: %s", err)
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
305
vendor/github.com/prometheus/procfs/nfs/parse_nfs_test.go
generated
vendored
Normal file
305
vendor/github.com/prometheus/procfs/nfs/parse_nfs_test.go
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nfs_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/procfs/nfs"
|
||||
)
|
||||
|
||||
func TestNewNFSClientRPCStats(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
content string
|
||||
stats *nfs.ClientRPCStats
|
||||
invalid bool
|
||||
}{
|
||||
{
|
||||
name: "invalid file",
|
||||
content: "invalid",
|
||||
invalid: true,
|
||||
}, {
|
||||
name: "good old kernel version file",
|
||||
content: `net 70 70 69 45
|
||||
rpc 1218785755 374636 1218815394
|
||||
proc2 18 16 57 74 52 71 73 45 86 0 52 83 61 17 53 50 23 70 82
|
||||
proc3 22 0 1061909262 48906 4077635 117661341 5 29391916 2570425 2993289 590 0 0 7815 15 1130 0 3983 92385 13332 2 1 23729
|
||||
proc4 48 98 51 54 83 85 23 24 1 28 73 68 83 12 84 39 68 59 58 88 29 74 69 96 21 84 15 53 86 54 66 56 97 36 49 32 85 81 11 58 32 67 13 28 35 90 1 26 1337
|
||||
`,
|
||||
stats: &nfs.ClientRPCStats{
|
||||
Network: nfs.Network{
|
||||
NetCount: 70,
|
||||
UDPCount: 70,
|
||||
TCPCount: 69,
|
||||
TCPConnect: 45,
|
||||
},
|
||||
ClientRPC: nfs.ClientRPC{
|
||||
RPCCount: 1218785755,
|
||||
Retransmissions: 374636,
|
||||
AuthRefreshes: 1218815394,
|
||||
},
|
||||
V2Stats: nfs.V2Stats{
|
||||
Null: 16,
|
||||
GetAttr: 57,
|
||||
SetAttr: 74,
|
||||
Root: 52,
|
||||
Lookup: 71,
|
||||
ReadLink: 73,
|
||||
Read: 45,
|
||||
WrCache: 86,
|
||||
Write: 0,
|
||||
Create: 52,
|
||||
Remove: 83,
|
||||
Rename: 61,
|
||||
Link: 17,
|
||||
SymLink: 53,
|
||||
MkDir: 50,
|
||||
RmDir: 23,
|
||||
ReadDir: 70,
|
||||
FsStat: 82,
|
||||
},
|
||||
V3Stats: nfs.V3Stats{
|
||||
Null: 0,
|
||||
GetAttr: 1061909262,
|
||||
SetAttr: 48906,
|
||||
Lookup: 4077635,
|
||||
Access: 117661341,
|
||||
ReadLink: 5,
|
||||
Read: 29391916,
|
||||
Write: 2570425,
|
||||
Create: 2993289,
|
||||
MkDir: 590,
|
||||
SymLink: 0,
|
||||
MkNod: 0,
|
||||
Remove: 7815,
|
||||
RmDir: 15,
|
||||
Rename: 1130,
|
||||
Link: 0,
|
||||
ReadDir: 3983,
|
||||
ReadDirPlus: 92385,
|
||||
FsStat: 13332,
|
||||
FsInfo: 2,
|
||||
PathConf: 1,
|
||||
Commit: 23729},
|
||||
ClientV4Stats: nfs.ClientV4Stats{
|
||||
Null: 98,
|
||||
Read: 51,
|
||||
Write: 54,
|
||||
Commit: 83,
|
||||
Open: 85,
|
||||
OpenConfirm: 23,
|
||||
OpenNoattr: 24,
|
||||
OpenDowngrade: 1,
|
||||
Close: 28,
|
||||
Setattr: 73,
|
||||
FsInfo: 68,
|
||||
Renew: 83,
|
||||
SetClientId: 12,
|
||||
SetClientIdConfirm: 84,
|
||||
Lock: 39,
|
||||
Lockt: 68,
|
||||
Locku: 59,
|
||||
Access: 58,
|
||||
Getattr: 88,
|
||||
Lookup: 29,
|
||||
LookupRoot: 74,
|
||||
Remove: 69,
|
||||
Rename: 96,
|
||||
Link: 21,
|
||||
Symlink: 84,
|
||||
Create: 15,
|
||||
Pathconf: 53,
|
||||
StatFs: 86,
|
||||
ReadLink: 54,
|
||||
ReadDir: 66,
|
||||
ServerCaps: 56,
|
||||
DelegReturn: 97,
|
||||
GetAcl: 36,
|
||||
SetAcl: 49,
|
||||
FsLocations: 32,
|
||||
ReleaseLockowner: 85,
|
||||
Secinfo: 81,
|
||||
FsidPresent: 11,
|
||||
ExchangeId: 58,
|
||||
CreateSession: 32,
|
||||
DestroySession: 67,
|
||||
Sequence: 13,
|
||||
GetLeaseTime: 28,
|
||||
ReclaimComplete: 35,
|
||||
LayoutGet: 90,
|
||||
GetDeviceInfo: 1,
|
||||
LayoutCommit: 26,
|
||||
LayoutReturn: 1337,
|
||||
SecinfoNoName: 0,
|
||||
TestStateId: 0,
|
||||
FreeStateId: 0,
|
||||
GetDeviceList: 0,
|
||||
BindConnToSession: 0,
|
||||
DestroyClientId: 0,
|
||||
Seek: 0,
|
||||
Allocate: 0,
|
||||
DeAllocate: 0,
|
||||
LayoutStats: 0,
|
||||
Clone: 0,
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "good file",
|
||||
content: `net 18628 0 18628 6
|
||||
rpc 4329785 0 4338291
|
||||
proc2 18 2 69 0 0 4410 0 0 0 0 0 0 0 0 0 0 0 99 2
|
||||
proc3 22 1 4084749 29200 94754 32580 186 47747 7981 8639 0 6356 0 6962 0 7958 0 0 241 4 4 2 39
|
||||
proc4 61 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
`,
|
||||
stats: &nfs.ClientRPCStats{
|
||||
Network: nfs.Network{
|
||||
NetCount: 18628,
|
||||
UDPCount: 0,
|
||||
TCPCount: 18628,
|
||||
TCPConnect: 6,
|
||||
},
|
||||
ClientRPC: nfs.ClientRPC{
|
||||
RPCCount: 4329785,
|
||||
Retransmissions: 0,
|
||||
AuthRefreshes: 4338291,
|
||||
},
|
||||
V2Stats: nfs.V2Stats{
|
||||
Null: 2,
|
||||
GetAttr: 69,
|
||||
SetAttr: 0,
|
||||
Root: 0,
|
||||
Lookup: 4410,
|
||||
ReadLink: 0,
|
||||
Read: 0,
|
||||
WrCache: 0,
|
||||
Write: 0,
|
||||
Create: 0,
|
||||
Remove: 0,
|
||||
Rename: 0,
|
||||
Link: 0,
|
||||
SymLink: 0,
|
||||
MkDir: 0,
|
||||
RmDir: 0,
|
||||
ReadDir: 99,
|
||||
FsStat: 2,
|
||||
},
|
||||
V3Stats: nfs.V3Stats{
|
||||
Null: 1,
|
||||
GetAttr: 4084749,
|
||||
SetAttr: 29200,
|
||||
Lookup: 94754,
|
||||
Access: 32580,
|
||||
ReadLink: 186,
|
||||
Read: 47747,
|
||||
Write: 7981,
|
||||
Create: 8639,
|
||||
MkDir: 0,
|
||||
SymLink: 6356,
|
||||
MkNod: 0,
|
||||
Remove: 6962,
|
||||
RmDir: 0,
|
||||
Rename: 7958,
|
||||
Link: 0,
|
||||
ReadDir: 0,
|
||||
ReadDirPlus: 241,
|
||||
FsStat: 4,
|
||||
FsInfo: 4,
|
||||
PathConf: 2,
|
||||
Commit: 39,
|
||||
},
|
||||
ClientV4Stats: nfs.ClientV4Stats{
|
||||
Null: 1,
|
||||
Read: 0,
|
||||
Write: 0,
|
||||
Commit: 0,
|
||||
Open: 0,
|
||||
OpenConfirm: 0,
|
||||
OpenNoattr: 0,
|
||||
OpenDowngrade: 0,
|
||||
Close: 0,
|
||||
Setattr: 0,
|
||||
FsInfo: 0,
|
||||
Renew: 0,
|
||||
SetClientId: 1,
|
||||
SetClientIdConfirm: 1,
|
||||
Lock: 0,
|
||||
Lockt: 0,
|
||||
Locku: 0,
|
||||
Access: 0,
|
||||
Getattr: 0,
|
||||
Lookup: 0,
|
||||
LookupRoot: 0,
|
||||
Remove: 2,
|
||||
Rename: 0,
|
||||
Link: 0,
|
||||
Symlink: 0,
|
||||
Create: 0,
|
||||
Pathconf: 0,
|
||||
StatFs: 0,
|
||||
ReadLink: 0,
|
||||
ReadDir: 0,
|
||||
ServerCaps: 0,
|
||||
DelegReturn: 0,
|
||||
GetAcl: 0,
|
||||
SetAcl: 0,
|
||||
FsLocations: 0,
|
||||
ReleaseLockowner: 0,
|
||||
Secinfo: 0,
|
||||
FsidPresent: 0,
|
||||
ExchangeId: 0,
|
||||
CreateSession: 0,
|
||||
DestroySession: 0,
|
||||
Sequence: 0,
|
||||
GetLeaseTime: 0,
|
||||
ReclaimComplete: 0,
|
||||
LayoutGet: 0,
|
||||
GetDeviceInfo: 0,
|
||||
LayoutCommit: 0,
|
||||
LayoutReturn: 0,
|
||||
SecinfoNoName: 0,
|
||||
TestStateId: 0,
|
||||
FreeStateId: 0,
|
||||
GetDeviceList: 0,
|
||||
BindConnToSession: 0,
|
||||
DestroyClientId: 0,
|
||||
Seek: 0,
|
||||
Allocate: 0,
|
||||
DeAllocate: 0,
|
||||
LayoutStats: 0,
|
||||
Clone: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
stats, err := nfs.ParseClientRPCStats(strings.NewReader(tt.content))
|
||||
|
||||
if tt.invalid && err == nil {
|
||||
t.Fatal("expected an error, but none occurred")
|
||||
}
|
||||
if !tt.invalid && err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
if want, have := tt.stats, stats; !reflect.DeepEqual(want, have) {
|
||||
t.Fatalf("unexpected NFS stats:\nwant:\n%v\nhave:\n%v", want, have)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
89
vendor/github.com/prometheus/procfs/nfs/parse_nfsd.go
generated
vendored
Normal file
89
vendor/github.com/prometheus/procfs/nfs/parse_nfsd.go
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nfs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
// ParseServerRPCStats returns stats read from /proc/net/rpc/nfsd
|
||||
func ParseServerRPCStats(r io.Reader) (*ServerRPCStats, error) {
|
||||
stats := &ServerRPCStats{}
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
parts := strings.Fields(scanner.Text())
|
||||
// require at least <key> <value>
|
||||
if len(parts) < 2 {
|
||||
return nil, fmt.Errorf("invalid NFSd metric line %q", line)
|
||||
}
|
||||
label := parts[0]
|
||||
|
||||
var values []uint64
|
||||
var err error
|
||||
if label == "th" {
|
||||
if len(parts) < 3 {
|
||||
return nil, fmt.Errorf("invalid NFSd th metric line %q", line)
|
||||
}
|
||||
values, err = util.ParseUint64s(parts[1:3])
|
||||
} else {
|
||||
values, err = util.ParseUint64s(parts[1:])
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing NFSd metric line: %s", err)
|
||||
}
|
||||
|
||||
switch metricLine := parts[0]; metricLine {
|
||||
case "rc":
|
||||
stats.ReplyCache, err = parseReplyCache(values)
|
||||
case "fh":
|
||||
stats.FileHandles, err = parseFileHandles(values)
|
||||
case "io":
|
||||
stats.InputOutput, err = parseInputOutput(values)
|
||||
case "th":
|
||||
stats.Threads, err = parseThreads(values)
|
||||
case "ra":
|
||||
stats.ReadAheadCache, err = parseReadAheadCache(values)
|
||||
case "net":
|
||||
stats.Network, err = parseNetwork(values)
|
||||
case "rpc":
|
||||
stats.ServerRPC, err = parseServerRPC(values)
|
||||
case "proc2":
|
||||
stats.V2Stats, err = parseV2Stats(values)
|
||||
case "proc3":
|
||||
stats.V3Stats, err = parseV3Stats(values)
|
||||
case "proc4":
|
||||
stats.ServerV4Stats, err = parseServerV4Stats(values)
|
||||
case "proc4ops":
|
||||
stats.V4Ops, err = parseV4Ops(values)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown NFSd metric line %q", metricLine)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("errors parsing NFSd metric line: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, fmt.Errorf("error scanning NFSd file: %s", err)
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
@@ -11,21 +11,21 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nfsd_test
|
||||
package nfs_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/procfs/nfsd"
|
||||
"github.com/prometheus/procfs/nfs"
|
||||
)
|
||||
|
||||
func TestNewNFSdRPCStats(t *testing.T) {
|
||||
func TestNewNFSdServerRPCStats(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
content string
|
||||
stats *nfsd.RPCStats
|
||||
stats *nfs.ServerRPCStats
|
||||
invalid bool
|
||||
}{
|
||||
{
|
||||
@@ -46,46 +46,46 @@ proc3 22 2 112 0 2719 111 0 0 0 0 0 0 0 0 0 0 0 27 216 0 2 1 0
|
||||
proc4 2 2 10853
|
||||
proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150 1272 0 0 0 1236 0 0 0 0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
`,
|
||||
stats: &nfsd.RPCStats{
|
||||
ReplyCache: nfsd.ReplyCache{
|
||||
stats: &nfs.ServerRPCStats{
|
||||
ReplyCache: nfs.ReplyCache{
|
||||
Hits: 0,
|
||||
Misses: 6,
|
||||
NoCache: 18622,
|
||||
},
|
||||
FileHandles: nfsd.FileHandles{
|
||||
FileHandles: nfs.FileHandles{
|
||||
Stale: 0,
|
||||
TotalLookups: 0,
|
||||
AnonLookups: 0,
|
||||
DirNoCache: 0,
|
||||
NoDirNoCache: 0,
|
||||
},
|
||||
InputOutput: nfsd.InputOutput{
|
||||
InputOutput: nfs.InputOutput{
|
||||
Read: 157286400,
|
||||
Write: 0,
|
||||
},
|
||||
Threads: nfsd.Threads{
|
||||
Threads: nfs.Threads{
|
||||
Threads: 8,
|
||||
FullCnt: 0,
|
||||
},
|
||||
ReadAheadCache: nfsd.ReadAheadCache{
|
||||
ReadAheadCache: nfs.ReadAheadCache{
|
||||
CacheSize: 32,
|
||||
CacheHistogram: []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
NotFound: 0,
|
||||
},
|
||||
Network: nfsd.Network{
|
||||
Network: nfs.Network{
|
||||
NetCount: 18628,
|
||||
UDPCount: 0,
|
||||
TCPCount: 18628,
|
||||
TCPConnect: 6,
|
||||
},
|
||||
RPC: nfsd.RPC{
|
||||
ServerRPC: nfs.ServerRPC{
|
||||
RPCCount: 18628,
|
||||
BadCnt: 0,
|
||||
BadFmt: 0,
|
||||
BadAuth: 0,
|
||||
BadcInt: 0,
|
||||
},
|
||||
V2Stats: nfsd.V2Stats{
|
||||
V2Stats: nfs.V2Stats{
|
||||
Null: 2,
|
||||
GetAttr: 69,
|
||||
SetAttr: 0,
|
||||
@@ -105,7 +105,7 @@ proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150
|
||||
ReadDir: 99,
|
||||
FsStat: 2,
|
||||
},
|
||||
V3Stats: nfsd.V3Stats{
|
||||
V3Stats: nfs.V3Stats{
|
||||
Null: 2,
|
||||
GetAttr: 112,
|
||||
SetAttr: 0,
|
||||
@@ -129,11 +129,11 @@ proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150
|
||||
PathConf: 1,
|
||||
Commit: 0,
|
||||
},
|
||||
V4Stats: nfsd.V4Stats{
|
||||
ServerV4Stats: nfs.ServerV4Stats{
|
||||
Null: 2,
|
||||
Compound: 10853,
|
||||
},
|
||||
V4Ops: nfsd.V4Ops{
|
||||
V4Ops: nfs.V4Ops{
|
||||
Op0Unused: 0,
|
||||
Op1Unused: 0,
|
||||
Op2Future: 0,
|
||||
@@ -179,7 +179,7 @@ proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
stats, err := nfsd.ParseRPCStats(strings.NewReader(tt.content))
|
||||
stats, err := nfs.ParseServerRPCStats(strings.NewReader(tt.content))
|
||||
|
||||
if tt.invalid && err == nil {
|
||||
t.Fatal("expected an error, but none occurred")
|
||||
16
vendor/github.com/prometheus/procfs/proc.go
generated
vendored
16
vendor/github.com/prometheus/procfs/proc.go
generated
vendored
@@ -1,6 +1,20 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -113,7 +127,7 @@ func (p Proc) CmdLine() ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
return strings.Split(string(data[:len(data)-1]), string(byte(0))), nil
|
||||
return strings.Split(string(bytes.TrimRight(data, string("\x00"))), string(byte(0))), nil
|
||||
}
|
||||
|
||||
// Comm returns the command name of a process.
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_io.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_io.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_io_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_io_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import "testing"
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_limits.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_limits.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_limits_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_limits_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import "testing"
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_ns.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_ns.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_ns_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_ns_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_stat.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_stat.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/proc_stat_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/proc_stat_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
14
vendor/github.com/prometheus/procfs/proc_test.go
generated
vendored
14
vendor/github.com/prometheus/procfs/proc_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
@@ -43,6 +56,7 @@ func TestCmdLine(t *testing.T) {
|
||||
}{
|
||||
{process: 26231, want: []string{"vim", "test.go", "+10"}},
|
||||
{process: 26232, want: []string{}},
|
||||
{process: 26233, want: []string{"com.github.uiautomator"}},
|
||||
} {
|
||||
p1, err := FS("fixtures").NewProc(tt.process)
|
||||
if err != nil {
|
||||
|
||||
29
vendor/github.com/prometheus/procfs/scripts/check_license.sh
generated
vendored
Executable file
29
vendor/github.com/prometheus/procfs/scripts/check_license.sh
generated
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright 2018 The Prometheus Authors
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
check_license() {
|
||||
local file=""
|
||||
for file in $(find . -type f -iname '*.go' ! -path './vendor/*'); do
|
||||
head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" || echo " ${file}"
|
||||
done
|
||||
}
|
||||
|
||||
licRes=$(check_license)
|
||||
|
||||
if [ -n "${licRes}" ]; then
|
||||
echo "license header checking failed:"
|
||||
echo "${licRes}"
|
||||
exit 255
|
||||
fi
|
||||
13
vendor/github.com/prometheus/procfs/stat.go
generated
vendored
13
vendor/github.com/prometheus/procfs/stat.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
|
||||
13
vendor/github.com/prometheus/procfs/stat_test.go
generated
vendored
13
vendor/github.com/prometheus/procfs/stat_test.go
generated
vendored
@@ -1,3 +1,16 @@
|
||||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import "testing"
|
||||
|
||||
Reference in New Issue
Block a user