Update procfs to v0.0.3 (#1395)
procfs v0.0.3 is a requirement for https://github.com/prometheus/node_exporter/pull/1357 Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>pull/1399/head
parent
e972e38b42
commit
4f074dfbc7
3
go.mod
3
go.mod
|
@ -5,7 +5,6 @@ require (
|
|||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
|
||||
github.com/ema/qdisc v0.0.0-20180104102928-b307c22d3ce7
|
||||
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968
|
||||
github.com/google/go-cmp v0.3.0 // indirect
|
||||
github.com/hodgesds/perf-utils v0.0.7
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||
github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3
|
||||
|
@ -16,7 +15,7 @@ require (
|
|||
github.com/prometheus/client_golang v1.0.0
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
|
||||
github.com/prometheus/common v0.4.1
|
||||
github.com/prometheus/procfs v0.0.2
|
||||
github.com/prometheus/procfs v0.0.3
|
||||
github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745
|
||||
github.com/sirupsen/logrus v1.4.2 // indirect
|
||||
github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a
|
||||
|
|
2
go.sum
2
go.sum
|
@ -68,6 +68,8 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
|
|||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE=
|
||||
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
||||
github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 h1:IuH7WumZNax0D+rEqmy2TyhKCzrtMGqbZO0b8rO00JA=
|
||||
github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745/go.mod h1:G81aIFAMS9ECrwBYR9YxhlPjWgrItd+Kje78O6+uqm8=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
|
|
|
@ -86,6 +86,7 @@ endif
|
|||
PREFIX ?= $(shell pwd)
|
||||
BIN_DIR ?= $(shell pwd)
|
||||
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
|
||||
DOCKERFILE_PATH ?= ./
|
||||
DOCKER_REPO ?= prom
|
||||
|
||||
DOCKER_ARCHS ?= amd64
|
||||
|
@ -212,7 +213,7 @@ $(BUILD_DOCKER_ARCHS): common-docker-%:
|
|||
docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \
|
||||
--build-arg ARCH="$*" \
|
||||
--build-arg OS="linux" \
|
||||
.
|
||||
$(DOCKERFILE_PATH)
|
||||
|
||||
.PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS)
|
||||
common-docker-publish: $(PUBLISH_DOCKER_ARCHS)
|
||||
|
@ -247,7 +248,9 @@ proto:
|
|||
ifdef GOLANGCI_LINT
|
||||
$(GOLANGCI_LINT):
|
||||
mkdir -p $(FIRST_GOPATH)/bin
|
||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_LINT_VERSION)/install.sh \
|
||||
| sed -e '/install -d/d' \
|
||||
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
|
||||
endif
|
||||
|
||||
ifdef GOVENDOR
|
||||
|
|
|
@ -3,7 +3,7 @@ Directory: fixtures
|
|||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/proc
|
||||
Mode: 755
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/proc/26231
|
||||
Mode: 755
|
||||
|
@ -21,6 +21,11 @@ Mode: 644
|
|||
Path: fixtures/proc/26231/cwd
|
||||
SymlinkTo: /usr/bin
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/proc/26231/environ
|
||||
Lines: 1
|
||||
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binNULLBYTEHOSTNAME=cd24e11f73a5NULLBYTETERM=xtermNULLBYTEGOLANG_VERSION=1.12.5NULLBYTEGOPATH=/goNULLBYTEHOME=/rootNULLBYTEEOF
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/proc/26231/exe
|
||||
SymlinkTo: /usr/bin/vim
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -356,32 +361,62 @@ debug 0
|
|||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/proc/mdstat
|
||||
Lines: 26
|
||||
Lines: 56
|
||||
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
|
||||
md3 : active raid6 sda1[8] sdh1[7] sdg1[6] sdf1[5] sde1[11] sdd1[3] sdc1[10] sdb1[9]
|
||||
|
||||
md3 : active raid6 sda1[8] sdh1[7] sdg1[6] sdf1[5] sde1[11] sdd1[3] sdc1[10] sdb1[9] sdd1[10](S) sdd2[11](S)
|
||||
5853468288 blocks super 1.2 level 6, 64k chunk, algorithm 2 [8/8] [UUUUUUUU]
|
||||
|
||||
md127 : active raid1 sdi2[0] sdj2[1]
|
||||
312319552 blocks [2/2] [UU]
|
||||
|
||||
md0 : active raid1 sdk[2](S) sdi1[0] sdj1[1]
|
||||
md0 : active raid1 sdi1[0] sdj1[1]
|
||||
248896 blocks [2/2] [UU]
|
||||
|
||||
md4 : inactive raid1 sda3[0] sdb3[1]
|
||||
md4 : inactive raid1 sda3[0](F) sdb3[1](S)
|
||||
4883648 blocks [2/2] [UU]
|
||||
|
||||
md6 : active raid1 sdb2[2] sda2[0]
|
||||
md6 : active raid1 sdb2[2](F) sdc[1](S) sda2[0]
|
||||
195310144 blocks [2/1] [U_]
|
||||
[=>...................] recovery = 8.5% (16775552/195310144) finish=17.0min speed=259783K/sec
|
||||
|
||||
md8 : active raid1 sdb1[1] sda1[0]
|
||||
md8 : active raid1 sdb1[1] sda1[0] sdc[2](S) sde[3](S)
|
||||
195310144 blocks [2/2] [UU]
|
||||
[=>...................] resync = 8.5% (16775552/195310144) finish=17.0min speed=259783K/sec
|
||||
|
||||
md7 : active raid6 sdb1[0] sde1[3] sdd1[2] sdc1[1]
|
||||
md7 : active raid6 sdb1[0] sde1[3] sdd1[2] sdc1[1](F)
|
||||
7813735424 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/3] [U_UU]
|
||||
bitmap: 0/30 pages [0KB], 65536KB chunk
|
||||
|
||||
md9 : active raid1 sdc2[2] sdd2[3] sdb2[1] sda2[0] sde[4](F) sdf[5](F) sdg[6](S)
|
||||
523968 blocks super 1.2 [4/4] [UUUU]
|
||||
resync=DELAYED
|
||||
|
||||
md10 : active raid0 sda1[0] sdb1[1]
|
||||
314159265 blocks 64k chunks
|
||||
|
||||
md11 : active (auto-read-only) raid1 sdb2[0] sdc2[1] sdc3[2](F) hda[4](S) ssdc2[3](S)
|
||||
4190208 blocks super 1.2 [2/2] [UU]
|
||||
resync=PENDING
|
||||
|
||||
md12 : active raid0 sdc2[0] sdd2[1]
|
||||
3886394368 blocks super 1.2 512k chunks
|
||||
|
||||
md126 : active raid0 sdb[1] sdc[0]
|
||||
1855870976 blocks super external:/md127/0 128k chunks
|
||||
|
||||
md219 : inactive sdb[2](S) sdc[1](S) sda[0](S)
|
||||
7932 blocks super external:imsm
|
||||
|
||||
md00 : active raid0 xvdb[0]
|
||||
4186624 blocks super 1.2 256k chunks
|
||||
|
||||
md120 : active linear sda1[1] sdb1[0]
|
||||
2095104 blocks super 1.2 0k rounding
|
||||
|
||||
md101 : active (read-only) raid0 sdb[2] sdd[1] sdc[0]
|
||||
322560 blocks super 1.2 512k chunks
|
||||
|
||||
unused devices: <none>
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -609,6 +644,232 @@ Mode: 664
|
|||
Directory: fixtures/sys/class
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/infiniband
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/infiniband/mlx4_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/board_id
|
||||
Lines: 1
|
||||
SM_1141000001000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/fw_ver
|
||||
Lines: 1
|
||||
2.31.5050
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/hca_type
|
||||
Lines: 1
|
||||
MT4099
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/infiniband/mlx4_0/ports
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/infiniband/mlx4_0/ports/1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/excessive_buffer_overrun_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/link_downed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/link_error_recovery
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/local_link_integrity_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_constraint_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_data
|
||||
Lines: 1
|
||||
2221223609
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_packets
|
||||
Lines: 1
|
||||
87169372
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_remote_physical_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_rcv_switch_relay_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_xmit_constraint_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_xmit_data
|
||||
Lines: 1
|
||||
26509113295
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_xmit_discards
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_xmit_packets
|
||||
Lines: 1
|
||||
85734114
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/port_xmit_wait
|
||||
Lines: 1
|
||||
3599
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/symbol_error
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/phys_state
|
||||
Lines: 1
|
||||
5: LinkUp
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/rate
|
||||
Lines: 1
|
||||
40 Gb/sec (4X QDR)
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/state
|
||||
Lines: 1
|
||||
4: ACTIVE
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/infiniband/mlx4_0/ports/2
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/excessive_buffer_overrun_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/link_downed
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/link_error_recovery
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/local_link_integrity_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_rcv_constraint_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_rcv_data
|
||||
Lines: 1
|
||||
2460436784
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_rcv_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_rcv_packets
|
||||
Lines: 1
|
||||
89332064
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_rcv_remote_physical_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_rcv_switch_relay_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_xmit_constraint_errors
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_xmit_data
|
||||
Lines: 1
|
||||
26540356890
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_xmit_discards
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_xmit_packets
|
||||
Lines: 1
|
||||
88622850
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/port_xmit_wait
|
||||
Lines: 1
|
||||
3846
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/symbol_error
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/phys_state
|
||||
Lines: 1
|
||||
5: LinkUp
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/rate
|
||||
Lines: 1
|
||||
40 Gb/sec (4X QDR)
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/state
|
||||
Lines: 1
|
||||
4: ACTIVE
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/class/net
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -1182,6 +1443,35 @@ Lines: 1
|
|||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/devices/rbd
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/devices/rbd/0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/devices/rbd/0/name
|
||||
Lines: 1
|
||||
demo
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/devices/rbd/0/pool
|
||||
Lines: 1
|
||||
iscsi-images
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/devices/rbd/1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/devices/rbd/1/name
|
||||
Lines: 1
|
||||
wrong
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/devices/rbd/1/pool
|
||||
Lines: 1
|
||||
wrong-images
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/devices/system
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -1806,3 +2096,248 @@ Lines: 1
|
|||
extent_alloc 2 0 0 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/fileio_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/fileio_1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/fileio_1/file_lio_1G
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/fileio_1/file_lio_1G/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/fileio_1/file_lio_1G/udev_path
|
||||
Lines: 1
|
||||
/home/iscsi/file_back_1G
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/iblock_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/iblock_0/block_lio_rbd1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/iblock_0/block_lio_rbd1/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/iblock_0/block_lio_rbd1/udev_path
|
||||
Lines: 1
|
||||
/dev/rbd1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/rbd_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/rbd_0/iscsi-images-demo
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/rbd_0/iscsi-images-demo/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/rbd_0/iscsi-images-demo/udev_path
|
||||
Lines: 1
|
||||
/dev/rbd/iscsi-images/demo
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/rd_mcp_119
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/core/rd_mcp_119/ramdisk_lio_1G
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/rd_mcp_119/ramdisk_lio_1G/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/core/rd_mcp_119/ramdisk_lio_1G/udev_path
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0/7f4a4eb56d
|
||||
SymlinkTo: ../../../../../../target/core/rd_mcp_119/ramdisk_lio_1G
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0/statistics
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/in_cmds
|
||||
Lines: 1
|
||||
204950
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/read_mbytes
|
||||
Lines: 1
|
||||
10325
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.8888bbbbddd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/write_mbytes
|
||||
Lines: 1
|
||||
40325
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0/795b7c7026
|
||||
SymlinkTo: ../../../../../../target/core/iblock_0/block_lio_rbd1
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0/statistics
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0/statistics/scsi_tgt_port
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/in_cmds
|
||||
Lines: 1
|
||||
104950
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/read_mbytes
|
||||
Lines: 1
|
||||
20095
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.osd1.x8664:sn.abcd1abcd2ab/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/write_mbytes
|
||||
Lines: 1
|
||||
71235
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0/fff5e16686
|
||||
SymlinkTo: ../../../../../../target/core/fileio_1/file_lio_1G
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0/statistics
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/in_cmds
|
||||
Lines: 1
|
||||
301950
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/read_mbytes
|
||||
Lines: 1
|
||||
10195
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:dev.rbd0/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/write_mbytes
|
||||
Lines: 1
|
||||
30195
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/enable
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0/eba1edf893
|
||||
SymlinkTo: ../../../../../../target/core/rbd_0/iscsi-images-demo
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0/statistics
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0/statistics/scsi_tgt_port
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/in_cmds
|
||||
Lines: 1
|
||||
1234
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/read_mbytes
|
||||
Lines: 1
|
||||
1504
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/sys/kernel/config/target/iscsi/iqn.2016-11.org.linux-iscsi.igw.x86:sn.ramdemo/tpgt_1/lun/lun_0/statistics/scsi_tgt_port/write_mbytes
|
||||
Lines: 1
|
||||
4733
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
module github.com/prometheus/procfs
|
||||
|
||||
require golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
|
||||
require (
|
||||
github.com/google/go-cmp v0.3.0
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
|
||||
)
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
|
|
@ -25,6 +25,9 @@ const (
|
|||
|
||||
// DefaultSysMountPoint is the common mount point of the sys filesystem.
|
||||
DefaultSysMountPoint = "/sys"
|
||||
|
||||
// DefaultConfigfsMountPoint is the commont mount point of the configfs
|
||||
DefaultConfigfsMountPoint = "/sys/kernel/config"
|
||||
)
|
||||
|
||||
// FS represents a pseudo-filesystem, normally /proc or /sys, which provides an
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
// Copyright 2019 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 util
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// TODO(mdlayher): util packages are an anti-pattern and this should be moved
|
||||
// somewhere else that is more focused in the future.
|
||||
|
||||
// A ValueParser enables parsing a single string into a variety of data types
|
||||
// in a concise and safe way. The Err method must be invoked after invoking
|
||||
// any other methods to ensure a value was successfully parsed.
|
||||
type ValueParser struct {
|
||||
v string
|
||||
err error
|
||||
}
|
||||
|
||||
// NewValueParser creates a ValueParser using the input string.
|
||||
func NewValueParser(v string) *ValueParser {
|
||||
return &ValueParser{v: v}
|
||||
}
|
||||
|
||||
// PInt64 interprets the underlying value as an int64 and returns a pointer to
|
||||
// that value.
|
||||
func (vp *ValueParser) PInt64() *int64 {
|
||||
if vp.err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A base value of zero makes ParseInt infer the correct base using the
|
||||
// string's prefix, if any.
|
||||
const base = 0
|
||||
v, err := strconv.ParseInt(vp.v, base, 64)
|
||||
if err != nil {
|
||||
vp.err = err
|
||||
return nil
|
||||
}
|
||||
|
||||
return &v
|
||||
}
|
||||
|
||||
// PUInt64 interprets the underlying value as an uint64 and returns a pointer to
|
||||
// that value.
|
||||
func (vp *ValueParser) PUInt64() *uint64 {
|
||||
if vp.err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A base value of zero makes ParseInt infer the correct base using the
|
||||
// string's prefix, if any.
|
||||
const base = 0
|
||||
v, err := strconv.ParseUint(vp.v, base, 64)
|
||||
if err != nil {
|
||||
vp.err = err
|
||||
return nil
|
||||
}
|
||||
|
||||
return &v
|
||||
}
|
||||
|
||||
// Err returns the last error, if any, encountered by the ValueParser.
|
||||
func (vp *ValueParser) Err() error {
|
||||
return vp.err
|
||||
}
|
|
@ -22,8 +22,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
statuslineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`)
|
||||
buildlineRE = regexp.MustCompile(`\((\d+)/\d+\)`)
|
||||
statusLineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[[U_]+\]`)
|
||||
recoveryLineRE = regexp.MustCompile(`\((\d+)/\d+\)`)
|
||||
)
|
||||
|
||||
// MDStat holds info parsed from /proc/mdstat.
|
||||
|
@ -34,8 +34,12 @@ type MDStat struct {
|
|||
ActivityState string
|
||||
// Number of active disks.
|
||||
DisksActive int64
|
||||
// Total number of disks the device consists of.
|
||||
// Total number of disks the device requires.
|
||||
DisksTotal int64
|
||||
// Number of failed disks.
|
||||
DisksFailed int64
|
||||
// Spare disks in the device.
|
||||
DisksSpare int64
|
||||
// Number of blocks the device holds.
|
||||
BlocksTotal int64
|
||||
// Number of blocks on the device that are in sync.
|
||||
|
@ -59,29 +63,38 @@ func (fs FS) MDStat() ([]MDStat, error) {
|
|||
|
||||
// parseMDStat parses data from mdstat file (/proc/mdstat) and returns a slice of
|
||||
// structs containing the relevant info.
|
||||
func parseMDStat(mdstatData []byte) ([]MDStat, error) {
|
||||
func parseMDStat(mdStatData []byte) ([]MDStat, error) {
|
||||
mdStats := []MDStat{}
|
||||
lines := strings.Split(string(mdstatData), "\n")
|
||||
for i, l := range lines {
|
||||
if strings.TrimSpace(l) == "" || l[0] == ' ' ||
|
||||
strings.HasPrefix(l, "Personalities") || strings.HasPrefix(l, "unused") {
|
||||
lines := strings.Split(string(mdStatData), "\n")
|
||||
|
||||
for i, line := range lines {
|
||||
if strings.TrimSpace(line) == "" || line[0] == ' ' ||
|
||||
strings.HasPrefix(line, "Personalities") ||
|
||||
strings.HasPrefix(line, "unused") {
|
||||
continue
|
||||
}
|
||||
|
||||
deviceFields := strings.Fields(l)
|
||||
deviceFields := strings.Fields(line)
|
||||
if len(deviceFields) < 3 {
|
||||
return nil, fmt.Errorf("not enough fields in mdline (expected at least 3): %s", l)
|
||||
return nil, fmt.Errorf("not enough fields in mdline (expected at least 3): %s", line)
|
||||
}
|
||||
mdName := deviceFields[0]
|
||||
activityState := deviceFields[2]
|
||||
mdName := deviceFields[0] // mdx
|
||||
state := deviceFields[2] // active or inactive
|
||||
|
||||
if len(lines) <= i+3 {
|
||||
return mdStats, fmt.Errorf("missing lines for md device %s", mdName)
|
||||
return nil, fmt.Errorf(
|
||||
"error parsing %s: too few lines for md device",
|
||||
mdName,
|
||||
)
|
||||
}
|
||||
|
||||
active, total, size, err := evalStatusLine(lines[i+1])
|
||||
// Failed disks have the suffix (F) & Spare disks have the suffix (S).
|
||||
fail := int64(strings.Count(line, "(F)"))
|
||||
spare := int64(strings.Count(line, "(S)"))
|
||||
active, total, size, err := evalStatusLine(lines[i], lines[i+1])
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error parsing md device lines: %s", err)
|
||||
}
|
||||
|
||||
syncLineIdx := i + 2
|
||||
|
@ -89,20 +102,38 @@ func parseMDStat(mdstatData []byte) ([]MDStat, error) {
|
|||
syncLineIdx++
|
||||
}
|
||||
|
||||
// If device is recovering/syncing at the moment, get the number of currently
|
||||
// If device is syncing at the moment, get the number of currently
|
||||
// synced bytes, otherwise that number equals the size of the device.
|
||||
syncedBlocks := size
|
||||
if strings.Contains(lines[syncLineIdx], "recovery") || strings.Contains(lines[syncLineIdx], "resync") {
|
||||
syncedBlocks, err = evalRecoveryLine(lines[syncLineIdx])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
recovering := strings.Contains(lines[syncLineIdx], "recovery")
|
||||
resyncing := strings.Contains(lines[syncLineIdx], "resync")
|
||||
|
||||
// Append recovery and resyncing state info.
|
||||
if recovering || resyncing {
|
||||
if recovering {
|
||||
state = "recovering"
|
||||
} else {
|
||||
state = "resyncing"
|
||||
}
|
||||
|
||||
// Handle case when resync=PENDING or resync=DELAYED.
|
||||
if strings.Contains(lines[syncLineIdx], "PENDING") ||
|
||||
strings.Contains(lines[syncLineIdx], "DELAYED") {
|
||||
syncedBlocks = 0
|
||||
} else {
|
||||
syncedBlocks, err = evalRecoveryLine(lines[syncLineIdx])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing sync line in md device %s: %s", mdName, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mdStats = append(mdStats, MDStat{
|
||||
Name: mdName,
|
||||
ActivityState: activityState,
|
||||
ActivityState: state,
|
||||
DisksActive: active,
|
||||
DisksFailed: fail,
|
||||
DisksSpare: spare,
|
||||
DisksTotal: total,
|
||||
BlocksTotal: size,
|
||||
BlocksSynced: syncedBlocks,
|
||||
|
@ -112,39 +143,51 @@ func parseMDStat(mdstatData []byte) ([]MDStat, error) {
|
|||
return mdStats, nil
|
||||
}
|
||||
|
||||
func evalStatusLine(statusline string) (active, total, size int64, err error) {
|
||||
matches := statuslineRE.FindStringSubmatch(statusline)
|
||||
if len(matches) != 4 {
|
||||
return 0, 0, 0, fmt.Errorf("unexpected statusline: %s", statusline)
|
||||
func evalStatusLine(deviceLine, statusLine string) (active, total, size int64, err error) {
|
||||
|
||||
sizeStr := strings.Fields(statusLine)[0]
|
||||
size, err = strconv.ParseInt(sizeStr, 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("unexpected statusLine %s: %s", statusLine, err)
|
||||
}
|
||||
|
||||
size, err = strconv.ParseInt(matches[1], 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("unexpected statusline %s: %s", statusline, err)
|
||||
if strings.Contains(deviceLine, "raid0") || strings.Contains(deviceLine, "linear") {
|
||||
// In the device deviceLine, only disks have a number associated with them in [].
|
||||
total = int64(strings.Count(deviceLine, "["))
|
||||
return total, total, size, nil
|
||||
}
|
||||
|
||||
if strings.Contains(deviceLine, "inactive") {
|
||||
return 0, 0, size, nil
|
||||
}
|
||||
|
||||
matches := statusLineRE.FindStringSubmatch(statusLine)
|
||||
if len(matches) != 4 {
|
||||
return 0, 0, 0, fmt.Errorf("couldn't find all the substring matches: %s", statusLine)
|
||||
}
|
||||
|
||||
total, err = strconv.ParseInt(matches[2], 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("unexpected statusline %s: %s", statusline, err)
|
||||
return 0, 0, 0, fmt.Errorf("unexpected statusLine %s: %s", statusLine, err)
|
||||
}
|
||||
|
||||
active, err = strconv.ParseInt(matches[3], 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("unexpected statusline %s: %s", statusline, err)
|
||||
return 0, 0, 0, fmt.Errorf("unexpected statusLine %s: %s", statusLine, err)
|
||||
}
|
||||
|
||||
return active, total, size, nil
|
||||
}
|
||||
|
||||
func evalRecoveryLine(buildline string) (syncedBlocks int64, err error) {
|
||||
matches := buildlineRE.FindStringSubmatch(buildline)
|
||||
func evalRecoveryLine(recoveryLine string) (syncedBlocks int64, err error) {
|
||||
matches := recoveryLineRE.FindStringSubmatch(recoveryLine)
|
||||
if len(matches) != 2 {
|
||||
return 0, fmt.Errorf("unexpected buildline: %s", buildline)
|
||||
return 0, fmt.Errorf("unexpected recoveryLine: %s", recoveryLine)
|
||||
}
|
||||
|
||||
syncedBlocks, err = strconv.ParseInt(matches[1], 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("%s in buildline: %s", err, buildline)
|
||||
return 0, fmt.Errorf("%s in recoveryLine: %s", err, recoveryLine)
|
||||
}
|
||||
|
||||
return syncedBlocks, nil
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
// Copyright 2019 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var validOptionalFields = map[string]bool{
|
||||
"shared": true,
|
||||
"master": true,
|
||||
"propagate_from": true,
|
||||
"unbindable": true,
|
||||
}
|
||||
|
||||
// A MountInfo is a type that describes the details, options
|
||||
// for each mount, parsed from /proc/self/mountinfo.
|
||||
// The fields described in each entry of /proc/self/mountinfo
|
||||
// is described in the following man page.
|
||||
// http://man7.org/linux/man-pages/man5/proc.5.html
|
||||
type MountInfo struct {
|
||||
// Unique Id for the mount
|
||||
MountId int
|
||||
// The Id of the parent mount
|
||||
ParentId int
|
||||
// The value of `st_dev` for the files on this FS
|
||||
MajorMinorVer string
|
||||
// The pathname of the directory in the FS that forms
|
||||
// the root for this mount
|
||||
Root string
|
||||
// The pathname of the mount point relative to the root
|
||||
MountPoint string
|
||||
// Mount options
|
||||
Options map[string]string
|
||||
// Zero or more optional fields
|
||||
OptionalFields map[string]string
|
||||
// The Filesystem type
|
||||
FSType string
|
||||
// FS specific information or "none"
|
||||
Source string
|
||||
// Superblock options
|
||||
SuperOptions map[string]string
|
||||
}
|
||||
|
||||
// Returns part of the mountinfo line, if it exists, else an empty string.
|
||||
func getStringSliceElement(parts []string, idx int, defaultValue string) string {
|
||||
if idx >= len(parts) {
|
||||
return defaultValue
|
||||
}
|
||||
return parts[idx]
|
||||
}
|
||||
|
||||
// Reads each line of the mountinfo file, and returns a list of formatted MountInfo structs.
|
||||
func parseMountInfo(r io.Reader) ([]*MountInfo, error) {
|
||||
mounts := []*MountInfo{}
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
mountString := scanner.Text()
|
||||
parsedMounts, err := parseMountInfoString(mountString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mounts = append(mounts, parsedMounts)
|
||||
}
|
||||
|
||||
err := scanner.Err()
|
||||
return mounts, err
|
||||
}
|
||||
|
||||
// Parses a mountinfo file line, and converts it to a MountInfo struct.
|
||||
// An important check here is to see if the hyphen separator, as if it does not exist,
|
||||
// it means that the line is malformed.
|
||||
func parseMountInfoString(mountString string) (*MountInfo, error) {
|
||||
var err error
|
||||
|
||||
// OptionalFields can be zero, hence these checks to ensure we do not populate the wrong values in the wrong spots
|
||||
separatorIndex := strings.Index(mountString, "-")
|
||||
if separatorIndex == -1 {
|
||||
return nil, fmt.Errorf("no separator found in mountinfo string: %s", mountString)
|
||||
}
|
||||
beforeFields := strings.Fields(mountString[:separatorIndex])
|
||||
afterFields := strings.Fields(mountString[separatorIndex+1:])
|
||||
if (len(beforeFields) + len(afterFields)) < 7 {
|
||||
return nil, fmt.Errorf("too few fields")
|
||||
}
|
||||
|
||||
mount := &MountInfo{
|
||||
MajorMinorVer: getStringSliceElement(beforeFields, 2, ""),
|
||||
Root: getStringSliceElement(beforeFields, 3, ""),
|
||||
MountPoint: getStringSliceElement(beforeFields, 4, ""),
|
||||
Options: mountOptionsParser(getStringSliceElement(beforeFields, 5, "")),
|
||||
OptionalFields: nil,
|
||||
FSType: getStringSliceElement(afterFields, 0, ""),
|
||||
Source: getStringSliceElement(afterFields, 1, ""),
|
||||
SuperOptions: mountOptionsParser(getStringSliceElement(afterFields, 2, "")),
|
||||
}
|
||||
|
||||
mount.MountId, err = strconv.Atoi(getStringSliceElement(beforeFields, 0, ""))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse mount ID")
|
||||
}
|
||||
mount.ParentId, err = strconv.Atoi(getStringSliceElement(beforeFields, 1, ""))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse parent ID")
|
||||
}
|
||||
// Has optional fields, which is a space separated list of values.
|
||||
// Example: shared:2 master:7
|
||||
if len(beforeFields) > 6 {
|
||||
mount.OptionalFields = make(map[string]string)
|
||||
optionalFields := beforeFields[6:]
|
||||
for _, field := range optionalFields {
|
||||
optionSplit := strings.Split(field, ":")
|
||||
target, value := optionSplit[0], ""
|
||||
if len(optionSplit) == 2 {
|
||||
value = optionSplit[1]
|
||||
}
|
||||
// Checks if the 'keys' in the optional fields in the mountinfo line are acceptable.
|
||||
// Allowed 'keys' are shared, master, propagate_from, unbindable.
|
||||
if _, ok := validOptionalFields[target]; ok {
|
||||
mount.OptionalFields[target] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
return mount, nil
|
||||
}
|
||||
|
||||
// Parses the mount options, superblock options.
|
||||
func mountOptionsParser(mountOptions string) map[string]string {
|
||||
opts := make(map[string]string)
|
||||
options := strings.Split(mountOptions, ",")
|
||||
for _, opt := range options {
|
||||
splitOption := strings.Split(opt, "=")
|
||||
if len(splitOption) < 2 {
|
||||
key := splitOption[0]
|
||||
opts[key] = ""
|
||||
} else {
|
||||
key, value := splitOption[0], splitOption[1]
|
||||
opts[key] = value
|
||||
}
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
// Retrieves mountinfo information from `/proc/self/mountinfo`.
|
||||
func GetMounts() ([]*MountInfo, error) {
|
||||
f, err := os.Open("/proc/self/mountinfo")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
return parseMountInfo(f)
|
||||
}
|
||||
|
||||
// Retrieves mountinfo information from a processes' `/proc/<pid>/mountinfo`.
|
||||
func GetProcMounts(pid int) ([]*MountInfo, error) {
|
||||
f, err := os.Open(fmt.Sprintf("/proc/%d/mountinfo", pid))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
return parseMountInfo(f)
|
||||
}
|
|
@ -247,6 +247,20 @@ func (p Proc) MountStats() ([]*Mount, error) {
|
|||
return parseMountStats(f)
|
||||
}
|
||||
|
||||
// MountInfo retrieves mount information for mount points in a
|
||||
// process's namespace.
|
||||
// It supplies information missing in `/proc/self/mounts` and
|
||||
// fixes various other problems with that file too.
|
||||
func (p Proc) MountInfo() ([]*MountInfo, error) {
|
||||
f, err := os.Open(p.path("mountinfo"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return parseMountInfo(f)
|
||||
}
|
||||
|
||||
func (p Proc) fileDescriptors() ([]string, error) {
|
||||
d, err := os.Open(p.path("fd"))
|
||||
if err != nil {
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2019 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 (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Environ reads process environments from /proc/<pid>/environ
|
||||
func (p Proc) Environ() ([]string, error) {
|
||||
environments := make([]string, 0)
|
||||
|
||||
f, err := os.Open(p.path("environ"))
|
||||
if err != nil {
|
||||
return environments, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
data, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
return environments, err
|
||||
}
|
||||
|
||||
environments = strings.Split(string(data), "\000")
|
||||
if len(environments) > 0 {
|
||||
environments = environments[:len(environments)-1]
|
||||
}
|
||||
|
||||
return environments, nil
|
||||
}
|
|
@ -106,7 +106,7 @@ type ProcStat struct {
|
|||
|
||||
// NewStat returns the current status information of the process.
|
||||
//
|
||||
// Deprecated: use NewStat() instead
|
||||
// Deprecated: use p.Stat() instead
|
||||
func (p Proc) NewStat() (ProcStat, error) {
|
||||
return p.Stat()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,370 @@
|
|||
// Copyright 2019 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.
|
||||
|
||||
// +build !windows
|
||||
|
||||
package sysfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
const infinibandClassPath = "class/infiniband"
|
||||
|
||||
// InfiniBandCounters contains counter values from files in
|
||||
// /sys/class/infiniband/<Name>/ports/<Port>/counters or
|
||||
// /sys/class/infiniband/<Name>/ports/<Port>/counters_ext
|
||||
// for a single port of one InfiniBand device.
|
||||
type InfiniBandCounters struct {
|
||||
LegacyPortMulticastRcvPackets *uint64 // counters_ext/port_multicast_rcv_packets
|
||||
LegacyPortMulticastXmitPackets *uint64 // counters_ext/port_multicast_xmit_packets
|
||||
LegacyPortRcvData64 *uint64 // counters_ext/port_rcv_data_64
|
||||
LegacyPortRcvPackets64 *uint64 // counters_ext/port_rcv_packets_64
|
||||
LegacyPortUnicastRcvPackets *uint64 // counters_ext/port_unicast_rcv_packets
|
||||
LegacyPortUnicastXmitPackets *uint64 // counters_ext/port_unicast_xmit_packets
|
||||
LegacyPortXmitData64 *uint64 // counters_ext/port_xmit_data_64
|
||||
LegacyPortXmitPackets64 *uint64 // counters_ext/port_xmit_packets_64
|
||||
|
||||
LinkDowned *uint64 // counters/link_downed
|
||||
LinkErrorRecovery *uint64 // counters/link_error_recovery
|
||||
MulticastRcvPackets *uint64 // counters/multicast_rcv_packets
|
||||
MulticastXmitPackets *uint64 // counters/multicast_xmit_packets
|
||||
PortRcvConstraintErrors *uint64 // counters/port_rcv_constraint_errors
|
||||
PortRcvData *uint64 // counters/port_rcv_data
|
||||
PortRcvDiscards *uint64 // counters/port_rcv_discards
|
||||
PortRcvErrors *uint64 // counters/port_rcv_errors
|
||||
PortRcvPackets *uint64 // counters/port_rcv_packets
|
||||
PortXmitConstraintErrors *uint64 // counters/port_xmit_constraint_errors
|
||||
PortXmitData *uint64 // counters/port_xmit_data
|
||||
PortXmitDiscards *uint64 // counters/port_xmit_discards
|
||||
PortXmitPackets *uint64 // counters/port_xmit_packets
|
||||
PortXmitWait *uint64 // counters/port_xmit_wait
|
||||
UnicastRcvPackets *uint64 // counters/unicast_rcv_packets
|
||||
UnicastXmitPackets *uint64 // counters/unicast_xmit_packets
|
||||
}
|
||||
|
||||
// InfiniBandPort contains info from files in
|
||||
// /sys/class/infiniband/<Name>/ports/<Port>
|
||||
// for a single port of one InfiniBand device.
|
||||
type InfiniBandPort struct {
|
||||
Name string
|
||||
Port uint
|
||||
State string // String representation from /sys/class/infiniband/<Name>/ports/<Port>/state
|
||||
StateID uint // ID from /sys/class/infiniband/<Name>/ports/<Port>/state
|
||||
PhysState string // String representation from /sys/class/infiniband/<Name>/ports/<Port>/phys_state
|
||||
PhysStateID uint // String representation from /sys/class/infiniband/<Name>/ports/<Port>/phys_state
|
||||
Rate uint64 // in bytes/second from /sys/class/infiniband/<Name>/ports/<Port>/rate
|
||||
Counters InfiniBandCounters
|
||||
}
|
||||
|
||||
// InfiniBandDevice contains info from files in /sys/class/infiniband for a
|
||||
// single InfiniBand device.
|
||||
type InfiniBandDevice struct {
|
||||
Name string
|
||||
BoardID string // /sys/class/infiniband/<Name>/board_id
|
||||
FirmwareVersion string // /sys/class/infiniband/<Name>/fw_ver
|
||||
HCAType string // /sys/class/infiniband/<Name>/hca_type
|
||||
Ports map[uint]InfiniBandPort
|
||||
}
|
||||
|
||||
// InfiniBandClass is a collection of every InfiniBand device in
|
||||
// /sys/class/infiniband.
|
||||
//
|
||||
// The map keys are the names of the InfiniBand devices.
|
||||
type InfiniBandClass map[string]InfiniBandDevice
|
||||
|
||||
// InfiniBandClass returns info for all InfiniBand devices read from
|
||||
// /sys/class/infiniband.
|
||||
func (fs FS) InfiniBandClass() (InfiniBandClass, error) {
|
||||
path := fs.sys.Path(infinibandClassPath)
|
||||
|
||||
dirs, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to list InfiniBand devices at %q: %v", path, err)
|
||||
}
|
||||
|
||||
ibc := make(InfiniBandClass, len(dirs))
|
||||
for _, d := range dirs {
|
||||
device, err := fs.parseInfiniBandDevice(d.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ibc[device.Name] = *device
|
||||
}
|
||||
|
||||
return ibc, nil
|
||||
}
|
||||
|
||||
// Parse one InfiniBand device.
|
||||
func (fs FS) parseInfiniBandDevice(name string) (*InfiniBandDevice, error) {
|
||||
path := fs.sys.Path(infinibandClassPath, name)
|
||||
device := InfiniBandDevice{Name: name}
|
||||
|
||||
for _, f := range [...]string{"board_id", "fw_ver", "hca_type"} {
|
||||
name := filepath.Join(path, f)
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
|
||||
switch f {
|
||||
case "board_id":
|
||||
device.BoardID = value
|
||||
case "fw_ver":
|
||||
device.FirmwareVersion = value
|
||||
case "hca_type":
|
||||
device.HCAType = value
|
||||
}
|
||||
}
|
||||
|
||||
portsPath := filepath.Join(path, "ports")
|
||||
ports, err := ioutil.ReadDir(portsPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to list InfiniBand ports at %q: %v", portsPath, err)
|
||||
}
|
||||
|
||||
device.Ports = make(map[uint]InfiniBandPort, len(ports))
|
||||
for _, d := range ports {
|
||||
port, err := fs.parseInfiniBandPort(name, d.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
device.Ports[port.Port] = *port
|
||||
}
|
||||
|
||||
return &device, nil
|
||||
}
|
||||
|
||||
// Parse InfiniBand state. Expected format: "<id>: <string-representation>"
|
||||
func parseState(s string) (uint, string, error) {
|
||||
parts := strings.Split(s, ":")
|
||||
if len(parts) != 2 {
|
||||
return 0, "", fmt.Errorf("failed to split %s into 'ID: NAME'", s)
|
||||
}
|
||||
name := strings.TrimSpace(parts[1])
|
||||
value, err := strconv.ParseUint(strings.TrimSpace(parts[0]), 10, 32)
|
||||
if err != nil {
|
||||
return 0, name, fmt.Errorf("failed to convert %s into uint", strings.TrimSpace(parts[0]))
|
||||
}
|
||||
id := uint(value)
|
||||
return id, name, nil
|
||||
}
|
||||
|
||||
// Parse rate (example: "100 Gb/sec (4X EDR)") and return it as bytes/second
|
||||
func parseRate(s string) (uint64, error) {
|
||||
parts := strings.Split(s, "Gb/sec")
|
||||
if len(parts) != 2 {
|
||||
return 0, fmt.Errorf("failed to split '%s' by 'Gb/sec'", s)
|
||||
}
|
||||
value, err := strconv.ParseFloat(strings.TrimSpace(parts[0]), 32)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to convert %s into uint", strings.TrimSpace(parts[0]))
|
||||
}
|
||||
// Convert Gb/s into bytes/s
|
||||
rate := uint64(value * 125000000)
|
||||
return rate, nil
|
||||
}
|
||||
|
||||
// parseInfiniBandPort scans predefined files in /sys/class/infiniband/<device>/ports/<port>
|
||||
// directory and gets their contents.
|
||||
func (fs FS) parseInfiniBandPort(name string, port string) (*InfiniBandPort, error) {
|
||||
portNumber, err := strconv.ParseUint(port, 10, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to convert %s into uint", port)
|
||||
}
|
||||
ibp := InfiniBandPort{Name: name, Port: uint(portNumber)}
|
||||
|
||||
portPath := fs.sys.Path(infinibandClassPath, name, "ports", port)
|
||||
content, err := ioutil.ReadFile(filepath.Join(portPath, "state"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id, name, err := parseState(string(content))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not parse state file in %s: %s", portPath, err)
|
||||
}
|
||||
ibp.State = name
|
||||
ibp.StateID = id
|
||||
|
||||
content, err = ioutil.ReadFile(filepath.Join(portPath, "phys_state"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id, name, err = parseState(string(content))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not parse phys_state file in %s: %s", portPath, err)
|
||||
}
|
||||
ibp.PhysState = name
|
||||
ibp.PhysStateID = id
|
||||
|
||||
content, err = ioutil.ReadFile(filepath.Join(portPath, "rate"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ibp.Rate, err = parseRate(string(content))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not parse rate file in %s: %s", portPath, err)
|
||||
}
|
||||
|
||||
counters, err := parseInfiniBandCounters(portPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ibp.Counters = *counters
|
||||
|
||||
return &ibp, nil
|
||||
}
|
||||
|
||||
func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) {
|
||||
var counters InfiniBandCounters
|
||||
|
||||
path := filepath.Join(portPath, "counters")
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := filepath.Join(path, f.Name())
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
|
||||
// According to Mellanox, the metrics port_rcv_data, port_xmit_data,
|
||||
// port_rcv_data_64, and port_xmit_data_64 "are divided by 4 unconditionally"
|
||||
// as they represent the amount of data being transmitted and received per lane.
|
||||
// Mellanox cards have 4 lanes per port, so all values must be multiplied by 4
|
||||
// to get the expected value.
|
||||
|
||||
vp := util.NewValueParser(value)
|
||||
|
||||
switch f.Name() {
|
||||
case "link_downed":
|
||||
counters.LinkDowned = vp.PUInt64()
|
||||
case "link_error_recovery":
|
||||
counters.LinkErrorRecovery = vp.PUInt64()
|
||||
case "multicast_rcv_packets":
|
||||
counters.MulticastRcvPackets = vp.PUInt64()
|
||||
case "multicast_xmit_packets":
|
||||
counters.MulticastXmitPackets = vp.PUInt64()
|
||||
case "port_rcv_constraint_errors":
|
||||
counters.PortRcvConstraintErrors = vp.PUInt64()
|
||||
case "port_rcv_data":
|
||||
counters.PortRcvData = vp.PUInt64()
|
||||
*counters.PortRcvData *= 4
|
||||
case "port_rcv_discards":
|
||||
counters.PortRcvDiscards = vp.PUInt64()
|
||||
case "port_rcv_errors":
|
||||
counters.PortRcvErrors = vp.PUInt64()
|
||||
case "port_rcv_packets":
|
||||
counters.PortRcvPackets = vp.PUInt64()
|
||||
case "port_xmit_constraint_errors":
|
||||
counters.PortXmitConstraintErrors = vp.PUInt64()
|
||||
case "port_xmit_data":
|
||||
counters.PortXmitData = vp.PUInt64()
|
||||
*counters.PortXmitData *= 4
|
||||
case "port_xmit_discards":
|
||||
counters.PortXmitDiscards = vp.PUInt64()
|
||||
case "port_xmit_packets":
|
||||
counters.PortXmitPackets = vp.PUInt64()
|
||||
case "port_xmit_wait":
|
||||
counters.PortXmitWait = vp.PUInt64()
|
||||
case "unicast_rcv_packets":
|
||||
counters.UnicastRcvPackets = vp.PUInt64()
|
||||
case "unicast_xmit_packets":
|
||||
counters.UnicastXmitPackets = vp.PUInt64()
|
||||
}
|
||||
|
||||
if err := vp.Err(); err != nil {
|
||||
// Ugly workaround for handling https://github.com/prometheus/node_exporter/issues/966
|
||||
// when counters are `N/A (not available)`.
|
||||
// This was already patched and submitted, see
|
||||
// https://www.spinics.net/lists/linux-rdma/msg68596.html
|
||||
// Remove this as soon as the fix lands in the enterprise distros.
|
||||
if strings.Contains(value, "N/A (no PMA)") {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Parse legacy counters
|
||||
path = filepath.Join(portPath, "counters_ext")
|
||||
files, err = ioutil.ReadDir(path)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := filepath.Join(path, f.Name())
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
|
||||
vp := util.NewValueParser(value)
|
||||
|
||||
switch f.Name() {
|
||||
case "port_multicast_rcv_packets":
|
||||
counters.LegacyPortMulticastRcvPackets = vp.PUInt64()
|
||||
case "port_multicast_xmit_packets":
|
||||
counters.LegacyPortMulticastXmitPackets = vp.PUInt64()
|
||||
case "port_rcv_data_64":
|
||||
counters.LegacyPortRcvData64 = vp.PUInt64()
|
||||
*counters.LegacyPortRcvData64 *= 4
|
||||
case "port_rcv_packets_64":
|
||||
counters.LegacyPortRcvPackets64 = vp.PUInt64()
|
||||
case "port_unicast_rcv_packets":
|
||||
counters.LegacyPortUnicastRcvPackets = vp.PUInt64()
|
||||
case "port_unicast_xmit_packets":
|
||||
counters.LegacyPortUnicastXmitPackets = vp.PUInt64()
|
||||
case "port_xmit_data_64":
|
||||
counters.LegacyPortXmitData64 = vp.PUInt64()
|
||||
*counters.LegacyPortXmitData64 *= 4
|
||||
case "port_xmit_packets_64":
|
||||
counters.LegacyPortXmitPackets64 = vp.PUInt64()
|
||||
}
|
||||
|
||||
if err := vp.Err(); err != nil {
|
||||
// Ugly workaround for handling https://github.com/prometheus/node_exporter/issues/966
|
||||
// when counters are `N/A (not available)`.
|
||||
// This was already patched and submitted, see
|
||||
// https://www.spinics.net/lists/linux-rdma/msg68596.html
|
||||
// Remove this as soon as the fix lands in the enterprise distros.
|
||||
if strings.Contains(value, "N/A (no PMA)") {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return &counters, nil
|
||||
}
|
|
@ -18,161 +18,275 @@ package sysfs
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
// PowerSupply contains info from files in /sys/class/power_supply for a single power supply.
|
||||
// PowerSupply contains info from files in /sys/class/power_supply for a
|
||||
// single power supply.
|
||||
type PowerSupply struct {
|
||||
Name string // Power Supply Name
|
||||
Authentic *int64 `fileName:"authentic"` // /sys/class/power_suppy/<Name>/authentic
|
||||
Calibrate *int64 `fileName:"calibrate"` // /sys/class/power_suppy/<Name>/calibrate
|
||||
Capacity *int64 `fileName:"capacity"` // /sys/class/power_suppy/<Name>/capacity
|
||||
CapacityAlertMax *int64 `fileName:"capacity_alert_max"` // /sys/class/power_suppy/<Name>/capacity_alert_max
|
||||
CapacityAlertMin *int64 `fileName:"capacity_alert_min"` // /sys/class/power_suppy/<Name>/capacity_alert_min
|
||||
CapacityLevel string `fileName:"capacity_level"` // /sys/class/power_suppy/<Name>/capacity_level
|
||||
ChargeAvg *int64 `fileName:"charge_avg"` // /sys/class/power_suppy/<Name>/charge_avg
|
||||
ChargeControlLimit *int64 `fileName:"charge_control_limit"` // /sys/class/power_suppy/<Name>/charge_control_limit
|
||||
ChargeControlLimitMax *int64 `fileName:"charge_control_limit_max"` // /sys/class/power_suppy/<Name>/charge_control_limit_max
|
||||
ChargeCounter *int64 `fileName:"charge_counter"` // /sys/class/power_suppy/<Name>/charge_counter
|
||||
ChargeEmpty *int64 `fileName:"charge_empty"` // /sys/class/power_suppy/<Name>/charge_empty
|
||||
ChargeEmptyDesign *int64 `fileName:"charge_empty_design"` // /sys/class/power_suppy/<Name>/charge_empty_design
|
||||
ChargeFull *int64 `fileName:"charge_full"` // /sys/class/power_suppy/<Name>/charge_full
|
||||
ChargeFullDesign *int64 `fileName:"charge_full_design"` // /sys/class/power_suppy/<Name>/charge_full_design
|
||||
ChargeNow *int64 `fileName:"charge_now"` // /sys/class/power_suppy/<Name>/charge_now
|
||||
ChargeTermCurrent *int64 `fileName:"charge_term_current"` // /sys/class/power_suppy/<Name>/charge_term_current
|
||||
ChargeType string `fileName:"charge_type"` // /sys/class/power_supply/<Name>/charge_type
|
||||
ConstantChargeCurrent *int64 `fileName:"constant_charge_current"` // /sys/class/power_suppy/<Name>/constant_charge_current
|
||||
ConstantChargeCurrentMax *int64 `fileName:"constant_charge_current_max"` // /sys/class/power_suppy/<Name>/constant_charge_current_max
|
||||
ConstantChargeVoltage *int64 `fileName:"constant_charge_voltage"` // /sys/class/power_suppy/<Name>/constant_charge_voltage
|
||||
ConstantChargeVoltageMax *int64 `fileName:"constant_charge_voltage_max"` // /sys/class/power_suppy/<Name>/constant_charge_voltage_max
|
||||
CurrentAvg *int64 `fileName:"current_avg"` // /sys/class/power_suppy/<Name>/current_avg
|
||||
CurrentBoot *int64 `fileName:"current_boot"` // /sys/class/power_suppy/<Name>/current_boot
|
||||
CurrentMax *int64 `fileName:"current_max"` // /sys/class/power_suppy/<Name>/current_max
|
||||
CurrentNow *int64 `fileName:"current_now"` // /sys/class/power_suppy/<Name>/current_now
|
||||
CycleCount *int64 `fileName:"cycle_count"` // /sys/class/power_suppy/<Name>/cycle_count
|
||||
EnergyAvg *int64 `fileName:"energy_avg"` // /sys/class/power_supply/<Name>/energy_avg
|
||||
EnergyEmpty *int64 `fileName:"energy_empty"` // /sys/class/power_suppy/<Name>/energy_empty
|
||||
EnergyEmptyDesign *int64 `fileName:"energy_empty_design"` // /sys/class/power_suppy/<Name>/energy_empty_design
|
||||
EnergyFull *int64 `fileName:"energy_full"` // /sys/class/power_suppy/<Name>/energy_full
|
||||
EnergyFullDesign *int64 `fileName:"energy_full_design"` // /sys/class/power_suppy/<Name>/energy_full_design
|
||||
EnergyNow *int64 `fileName:"energy_now"` // /sys/class/power_supply/<Name>/energy_now
|
||||
Health string `fileName:"health"` // /sys/class/power_suppy/<Name>/health
|
||||
InputCurrentLimit *int64 `fileName:"input_current_limit"` // /sys/class/power_suppy/<Name>/input_current_limit
|
||||
Manufacturer string `fileName:"manufacturer"` // /sys/class/power_suppy/<Name>/manufacturer
|
||||
ModelName string `fileName:"model_name"` // /sys/class/power_suppy/<Name>/model_name
|
||||
Online *int64 `fileName:"online"` // /sys/class/power_suppy/<Name>/online
|
||||
PowerAvg *int64 `fileName:"power_avg"` // /sys/class/power_suppy/<Name>/power_avg
|
||||
PowerNow *int64 `fileName:"power_now"` // /sys/class/power_suppy/<Name>/power_now
|
||||
PrechargeCurrent *int64 `fileName:"precharge_current"` // /sys/class/power_suppy/<Name>/precharge_current
|
||||
Present *int64 `fileName:"present"` // /sys/class/power_suppy/<Name>/present
|
||||
Scope string `fileName:"scope"` // /sys/class/power_suppy/<Name>/scope
|
||||
SerialNumber string `fileName:"serial_number"` // /sys/class/power_suppy/<Name>/serial_number
|
||||
Status string `fileName:"status"` // /sys/class/power_supply/<Name>/status
|
||||
Technology string `fileName:"technology"` // /sys/class/power_suppy/<Name>/technology
|
||||
Temp *int64 `fileName:"temp"` // /sys/class/power_suppy/<Name>/temp
|
||||
TempAlertMax *int64 `fileName:"temp_alert_max"` // /sys/class/power_suppy/<Name>/temp_alert_max
|
||||
TempAlertMin *int64 `fileName:"temp_alert_min"` // /sys/class/power_suppy/<Name>/temp_alert_min
|
||||
TempAmbient *int64 `fileName:"temp_ambient"` // /sys/class/power_suppy/<Name>/temp_ambient
|
||||
TempAmbientMax *int64 `fileName:"temp_ambient_max"` // /sys/class/power_suppy/<Name>/temp_ambient_max
|
||||
TempAmbientMin *int64 `fileName:"temp_ambient_min"` // /sys/class/power_suppy/<Name>/temp_ambient_min
|
||||
TempMax *int64 `fileName:"temp_max"` // /sys/class/power_suppy/<Name>/temp_max
|
||||
TempMin *int64 `fileName:"temp_min"` // /sys/class/power_suppy/<Name>/temp_min
|
||||
TimeToEmptyAvg *int64 `fileName:"time_to_empty_avg"` // /sys/class/power_suppy/<Name>/time_to_empty_avg
|
||||
TimeToEmptyNow *int64 `fileName:"time_to_empty_now"` // /sys/class/power_suppy/<Name>/time_to_empty_now
|
||||
TimeToFullAvg *int64 `fileName:"time_to_full_avg"` // /sys/class/power_suppy/<Name>/time_to_full_avg
|
||||
TimeToFullNow *int64 `fileName:"time_to_full_now"` // /sys/class/power_suppy/<Name>/time_to_full_now
|
||||
Type string `fileName:"type"` // /sys/class/power_supply/<Name>/type
|
||||
UsbType string `fileName:"usb_type"` // /sys/class/power_supply/<Name>/usb_type
|
||||
VoltageAvg *int64 `fileName:"voltage_avg"` // /sys/class/power_supply/<Name>/voltage_avg
|
||||
VoltageBoot *int64 `fileName:"voltage_boot"` // /sys/class/power_suppy/<Name>/voltage_boot
|
||||
VoltageMax *int64 `fileName:"voltage_max"` // /sys/class/power_suppy/<Name>/voltage_max
|
||||
VoltageMaxDesign *int64 `fileName:"voltage_max_design"` // /sys/class/power_suppy/<Name>/voltage_max_design
|
||||
VoltageMin *int64 `fileName:"voltage_min"` // /sys/class/power_suppy/<Name>/voltage_min
|
||||
VoltageMinDesign *int64 `fileName:"voltage_min_design"` // /sys/class/power_suppy/<Name>/voltage_min_design
|
||||
VoltageNow *int64 `fileName:"voltage_now"` // /sys/class/power_supply/<Name>/voltage_now
|
||||
VoltageOCV *int64 `fileName:"voltage_ocv"` // /sys/class/power_suppy/<Name>/voltage_ocv
|
||||
Authentic *int64 // /sys/class/power_supply/<Name>/authentic
|
||||
Calibrate *int64 // /sys/class/power_supply/<Name>/calibrate
|
||||
Capacity *int64 // /sys/class/power_supply/<Name>/capacity
|
||||
CapacityAlertMax *int64 // /sys/class/power_supply/<Name>/capacity_alert_max
|
||||
CapacityAlertMin *int64 // /sys/class/power_supply/<Name>/capacity_alert_min
|
||||
CapacityLevel string // /sys/class/power_supply/<Name>/capacity_level
|
||||
ChargeAvg *int64 // /sys/class/power_supply/<Name>/charge_avg
|
||||
ChargeControlLimit *int64 // /sys/class/power_supply/<Name>/charge_control_limit
|
||||
ChargeControlLimitMax *int64 // /sys/class/power_supply/<Name>/charge_control_limit_max
|
||||
ChargeCounter *int64 // /sys/class/power_supply/<Name>/charge_counter
|
||||
ChargeEmpty *int64 // /sys/class/power_supply/<Name>/charge_empty
|
||||
ChargeEmptyDesign *int64 // /sys/class/power_supply/<Name>/charge_empty_design
|
||||
ChargeFull *int64 // /sys/class/power_supply/<Name>/charge_full
|
||||
ChargeFullDesign *int64 // /sys/class/power_supply/<Name>/charge_full_design
|
||||
ChargeNow *int64 // /sys/class/power_supply/<Name>/charge_now
|
||||
ChargeTermCurrent *int64 // /sys/class/power_supply/<Name>/charge_term_current
|
||||
ChargeType string // /sys/class/power_supply/<Name>/charge_type
|
||||
ConstantChargeCurrent *int64 // /sys/class/power_supply/<Name>/constant_charge_current
|
||||
ConstantChargeCurrentMax *int64 // /sys/class/power_supply/<Name>/constant_charge_current_max
|
||||
ConstantChargeVoltage *int64 // /sys/class/power_supply/<Name>/constant_charge_voltage
|
||||
ConstantChargeVoltageMax *int64 // /sys/class/power_supply/<Name>/constant_charge_voltage_max
|
||||
CurrentAvg *int64 // /sys/class/power_supply/<Name>/current_avg
|
||||
CurrentBoot *int64 // /sys/class/power_supply/<Name>/current_boot
|
||||
CurrentMax *int64 // /sys/class/power_supply/<Name>/current_max
|
||||
CurrentNow *int64 // /sys/class/power_supply/<Name>/current_now
|
||||
CycleCount *int64 // /sys/class/power_supply/<Name>/cycle_count
|
||||
EnergyAvg *int64 // /sys/class/power_supply/<Name>/energy_avg
|
||||
EnergyEmpty *int64 // /sys/class/power_supply/<Name>/energy_empty
|
||||
EnergyEmptyDesign *int64 // /sys/class/power_supply/<Name>/energy_empty_design
|
||||
EnergyFull *int64 // /sys/class/power_supply/<Name>/energy_full
|
||||
EnergyFullDesign *int64 // /sys/class/power_supply/<Name>/energy_full_design
|
||||
EnergyNow *int64 // /sys/class/power_supply/<Name>/energy_now
|
||||
Health string // /sys/class/power_supply/<Name>/health
|
||||
InputCurrentLimit *int64 // /sys/class/power_supply/<Name>/input_current_limit
|
||||
Manufacturer string // /sys/class/power_supply/<Name>/manufacturer
|
||||
ModelName string // /sys/class/power_supply/<Name>/model_name
|
||||
Online *int64 // /sys/class/power_supply/<Name>/online
|
||||
PowerAvg *int64 // /sys/class/power_supply/<Name>/power_avg
|
||||
PowerNow *int64 // /sys/class/power_supply/<Name>/power_now
|
||||
PrechargeCurrent *int64 // /sys/class/power_supply/<Name>/precharge_current
|
||||
Present *int64 // /sys/class/power_supply/<Name>/present
|
||||
Scope string // /sys/class/power_supply/<Name>/scope
|
||||
SerialNumber string // /sys/class/power_supply/<Name>/serial_number
|
||||
Status string // /sys/class/power_supply/<Name>/status
|
||||
Technology string // /sys/class/power_supply/<Name>/technology
|
||||
Temp *int64 // /sys/class/power_supply/<Name>/temp
|
||||
TempAlertMax *int64 // /sys/class/power_supply/<Name>/temp_alert_max
|
||||
TempAlertMin *int64 // /sys/class/power_supply/<Name>/temp_alert_min
|
||||
TempAmbient *int64 // /sys/class/power_supply/<Name>/temp_ambient
|
||||
TempAmbientMax *int64 // /sys/class/power_supply/<Name>/temp_ambient_max
|
||||
TempAmbientMin *int64 // /sys/class/power_supply/<Name>/temp_ambient_min
|
||||
TempMax *int64 // /sys/class/power_supply/<Name>/temp_max
|
||||
TempMin *int64 // /sys/class/power_supply/<Name>/temp_min
|
||||
TimeToEmptyAvg *int64 // /sys/class/power_supply/<Name>/time_to_empty_avg
|
||||
TimeToEmptyNow *int64 // /sys/class/power_supply/<Name>/time_to_empty_now
|
||||
TimeToFullAvg *int64 // /sys/class/power_supply/<Name>/time_to_full_avg
|
||||
TimeToFullNow *int64 // /sys/class/power_supply/<Name>/time_to_full_now
|
||||
Type string // /sys/class/power_supply/<Name>/type
|
||||
UsbType string // /sys/class/power_supply/<Name>/usb_type
|
||||
VoltageAvg *int64 // /sys/class/power_supply/<Name>/voltage_avg
|
||||
VoltageBoot *int64 // /sys/class/power_supply/<Name>/voltage_boot
|
||||
VoltageMax *int64 // /sys/class/power_supply/<Name>/voltage_max
|
||||
VoltageMaxDesign *int64 // /sys/class/power_supply/<Name>/voltage_max_design
|
||||
VoltageMin *int64 // /sys/class/power_supply/<Name>/voltage_min
|
||||
VoltageMinDesign *int64 // /sys/class/power_supply/<Name>/voltage_min_design
|
||||
VoltageNow *int64 // /sys/class/power_supply/<Name>/voltage_now
|
||||
VoltageOCV *int64 // /sys/class/power_supply/<Name>/voltage_ocv
|
||||
}
|
||||
|
||||
// PowerSupplyClass is a collection of every power supply in /sys/class/power_supply/.
|
||||
// PowerSupplyClass is a collection of every power supply in
|
||||
// /sys/class/power_supply.
|
||||
//
|
||||
// The map keys are the names of the power supplies.
|
||||
type PowerSupplyClass map[string]PowerSupply
|
||||
|
||||
// PowerSupplyClass returns info for all power supplies read from /sys/class/power_supply/.
|
||||
// PowerSupplyClass returns info for all power supplies read from
|
||||
// /sys/class/power_supply.
|
||||
func (fs FS) PowerSupplyClass() (PowerSupplyClass, error) {
|
||||
path := fs.sys.Path("class/power_supply")
|
||||
|
||||
powerSupplyDirs, err := ioutil.ReadDir(path)
|
||||
dirs, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return PowerSupplyClass{}, fmt.Errorf("cannot access %s dir %s", path, err)
|
||||
return nil, fmt.Errorf("failed to list power supplies at %q: %v", path, err)
|
||||
}
|
||||
|
||||
powerSupplyClass := PowerSupplyClass{}
|
||||
for _, powerSupplyDir := range powerSupplyDirs {
|
||||
powerSupply, err := powerSupplyClass.parsePowerSupply(path + "/" + powerSupplyDir.Name())
|
||||
psc := make(PowerSupplyClass, len(dirs))
|
||||
for _, d := range dirs {
|
||||
ps, err := parsePowerSupply(filepath.Join(path, d.Name()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
powerSupply.Name = powerSupplyDir.Name()
|
||||
powerSupplyClass[powerSupplyDir.Name()] = *powerSupply
|
||||
|
||||
ps.Name = d.Name()
|
||||
psc[d.Name()] = *ps
|
||||
}
|
||||
return powerSupplyClass, nil
|
||||
|
||||
return psc, nil
|
||||
}
|
||||
|
||||
func (psc PowerSupplyClass) parsePowerSupply(powerSupplyPath string) (*PowerSupply, error) {
|
||||
powerSupply := PowerSupply{}
|
||||
powerSupplyElem := reflect.ValueOf(&powerSupply).Elem()
|
||||
powerSupplyType := reflect.TypeOf(powerSupply)
|
||||
func parsePowerSupply(path string) (*PowerSupply, error) {
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//start from 1 - skip the Name field
|
||||
for i := 1; i < powerSupplyElem.NumField(); i++ {
|
||||
fieldType := powerSupplyType.Field(i)
|
||||
fieldValue := powerSupplyElem.Field(i)
|
||||
|
||||
if fieldType.Tag.Get("fileName") == "" {
|
||||
panic(fmt.Errorf("field %s does not have a filename tag", fieldType.Name))
|
||||
var ps PowerSupply
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
value, err := util.SysReadFile(powerSupplyPath + "/" + fieldType.Tag.Get("fileName"))
|
||||
|
||||
name := filepath.Join(path, f.Name())
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" {
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("could not access file %s: %s", fieldType.Tag.Get("fileName"), err)
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
|
||||
switch fieldValue.Kind() {
|
||||
case reflect.String:
|
||||
fieldValue.SetString(value)
|
||||
case reflect.Ptr:
|
||||
var int64ptr *int64
|
||||
switch fieldValue.Type() {
|
||||
case reflect.TypeOf(int64ptr):
|
||||
var intValue int64
|
||||
if strings.HasPrefix(value, "0x") {
|
||||
intValue, err = strconv.ParseInt(value[2:], 16, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("expected hex value for %s, got: %s", fieldType.Name, value)
|
||||
}
|
||||
} else {
|
||||
intValue, err = strconv.ParseInt(value, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("expected Uint64 value for %s, got: %s", fieldType.Name, value)
|
||||
}
|
||||
}
|
||||
fieldValue.Set(reflect.ValueOf(&intValue))
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled pointer type %q", fieldValue.Type())
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled type %q", fieldValue.Kind())
|
||||
vp := util.NewValueParser(value)
|
||||
|
||||
switch f.Name() {
|
||||
case "authentic":
|
||||
ps.Authentic = vp.PInt64()
|
||||
case "calibrate":
|
||||
ps.Calibrate = vp.PInt64()
|
||||
case "capacity":
|
||||
ps.Capacity = vp.PInt64()
|
||||
case "capacity_alert_max":
|
||||
ps.CapacityAlertMax = vp.PInt64()
|
||||
case "capacity_alert_min":
|
||||
ps.CapacityAlertMin = vp.PInt64()
|
||||
case "capacity_level":
|
||||
ps.CapacityLevel = value
|
||||
case "charge_avg":
|
||||
ps.ChargeAvg = vp.PInt64()
|
||||
case "charge_control_limit":
|
||||
ps.ChargeControlLimit = vp.PInt64()
|
||||
case "charge_control_limit_max":
|
||||
ps.ChargeControlLimitMax = vp.PInt64()
|
||||
case "charge_counter":
|
||||
ps.ChargeCounter = vp.PInt64()
|
||||
case "charge_empty":
|
||||
ps.ChargeEmpty = vp.PInt64()
|
||||
case "charge_empty_design":
|
||||
ps.ChargeEmptyDesign = vp.PInt64()
|
||||
case "charge_full":
|
||||
ps.ChargeFull = vp.PInt64()
|
||||
case "charge_full_design":
|
||||
ps.ChargeFullDesign = vp.PInt64()
|
||||
case "charge_now":
|
||||
ps.ChargeNow = vp.PInt64()
|
||||
case "charge_term_current":
|
||||
ps.ChargeTermCurrent = vp.PInt64()
|
||||
case "charge_type":
|
||||
ps.ChargeType = value
|
||||
case "constant_charge_current":
|
||||
ps.ConstantChargeCurrent = vp.PInt64()
|
||||
case "constant_charge_current_max":
|
||||
ps.ConstantChargeCurrentMax = vp.PInt64()
|
||||
case "constant_charge_voltage":
|
||||
ps.ConstantChargeVoltage = vp.PInt64()
|
||||
case "constant_charge_voltage_max":
|
||||
ps.ConstantChargeVoltageMax = vp.PInt64()
|
||||
case "current_avg":
|
||||
ps.CurrentAvg = vp.PInt64()
|
||||
case "current_boot":
|
||||
ps.CurrentBoot = vp.PInt64()
|
||||
case "current_max":
|
||||
ps.CurrentMax = vp.PInt64()
|
||||
case "current_now":
|
||||
ps.CurrentNow = vp.PInt64()
|
||||
case "cycle_count":
|
||||
ps.CycleCount = vp.PInt64()
|
||||
case "energy_avg":
|
||||
ps.EnergyAvg = vp.PInt64()
|
||||
case "energy_empty":
|
||||
ps.EnergyEmpty = vp.PInt64()
|
||||
case "energy_empty_design":
|
||||
ps.EnergyEmptyDesign = vp.PInt64()
|
||||
case "energy_full":
|
||||
ps.EnergyFull = vp.PInt64()
|
||||
case "energy_full_design":
|
||||
ps.EnergyFullDesign = vp.PInt64()
|
||||
case "energy_now":
|
||||
ps.EnergyNow = vp.PInt64()
|
||||
case "health":
|
||||
ps.Health = value
|
||||
case "input_current_limit":
|
||||
ps.InputCurrentLimit = vp.PInt64()
|
||||
case "manufacturer":
|
||||
ps.Manufacturer = value
|
||||
case "model_name":
|
||||
ps.ModelName = value
|
||||
case "online":
|
||||
ps.Online = vp.PInt64()
|
||||
case "power_avg":
|
||||
ps.PowerAvg = vp.PInt64()
|
||||
case "power_now":
|
||||
ps.PowerNow = vp.PInt64()
|
||||
case "precharge_current":
|
||||
ps.PrechargeCurrent = vp.PInt64()
|
||||
case "present":
|
||||
ps.Present = vp.PInt64()
|
||||
case "scope":
|
||||
ps.Scope = value
|
||||
case "serial_number":
|
||||
ps.SerialNumber = value
|
||||
case "status":
|
||||
ps.Status = value
|
||||
case "technology":
|
||||
ps.Technology = value
|
||||
case "temp":
|
||||
ps.Temp = vp.PInt64()
|
||||
case "temp_alert_max":
|
||||
ps.TempAlertMax = vp.PInt64()
|
||||
case "temp_alert_min":
|
||||
ps.TempAlertMin = vp.PInt64()
|
||||
case "temp_ambient":
|
||||
ps.TempAmbient = vp.PInt64()
|
||||
case "temp_ambient_max":
|
||||
ps.TempAmbientMax = vp.PInt64()
|
||||
case "temp_ambient_min":
|
||||
ps.TempAmbientMin = vp.PInt64()
|
||||
case "temp_max":
|
||||
ps.TempMax = vp.PInt64()
|
||||
case "temp_min":
|
||||
ps.TempMin = vp.PInt64()
|
||||
case "time_to_empty_avg":
|
||||
ps.TimeToEmptyAvg = vp.PInt64()
|
||||
case "time_to_empty_now":
|
||||
ps.TimeToEmptyNow = vp.PInt64()
|
||||
case "time_to_full_avg":
|
||||
ps.TimeToFullAvg = vp.PInt64()
|
||||
case "time_to_full_now":
|
||||
ps.TimeToFullNow = vp.PInt64()
|
||||
case "type":
|
||||
ps.Type = value
|
||||
case "usb_type":
|
||||
ps.UsbType = value
|
||||
case "voltage_avg":
|
||||
ps.VoltageAvg = vp.PInt64()
|
||||
case "voltage_boot":
|
||||
ps.VoltageBoot = vp.PInt64()
|
||||
case "voltage_max":
|
||||
ps.VoltageMax = vp.PInt64()
|
||||
case "voltage_max_design":
|
||||
ps.VoltageMaxDesign = vp.PInt64()
|
||||
case "voltage_min":
|
||||
ps.VoltageMin = vp.PInt64()
|
||||
case "voltage_min_design":
|
||||
ps.VoltageMinDesign = vp.PInt64()
|
||||
case "voltage_now":
|
||||
ps.VoltageNow = vp.PInt64()
|
||||
case "voltage_ocv":
|
||||
ps.VoltageOCV = vp.PInt64()
|
||||
}
|
||||
|
||||
if err := vp.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return &powerSupply, nil
|
||||
return &ps, nil
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ github.com/prometheus/common/version
|
|||
github.com/prometheus/common/expfmt
|
||||
github.com/prometheus/common/model
|
||||
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
|
||||
# github.com/prometheus/procfs v0.0.2
|
||||
# github.com/prometheus/procfs v0.0.3
|
||||
github.com/prometheus/procfs
|
||||
github.com/prometheus/procfs/bcache
|
||||
github.com/prometheus/procfs/nfs
|
||||
|
|
Loading…
Reference in New Issue