Use v2.0.0 of mq-golang now it has been created (#159)
* Use v2.0.0 of mq-golang now it has been created * do a strip vendor
This commit is contained in:
committed by
Stephen Marshall
parent
59eaa9c7d2
commit
e4f02d55cf
6
vendor/github.com/prometheus/procfs/Makefile
generated
vendored
6
vendor/github.com/prometheus/procfs/Makefile
generated
vendored
@@ -59,6 +59,12 @@ staticcheck: $(STATICCHECK)
|
||||
./ttar -C $(dir $*) -x -f $*.ttar
|
||||
touch $@
|
||||
|
||||
update_fixtures: fixtures.ttar sysfs/fixtures.ttar
|
||||
|
||||
%fixtures.ttar: %/fixtures
|
||||
rm -v $(dir $*)fixtures/.unpacked
|
||||
./ttar -C $(dir $*) -c -f $*fixtures.ttar fixtures/
|
||||
|
||||
$(FIRST_GOPATH)/bin/staticcheck:
|
||||
@GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
|
||||
|
||||
|
||||
51
vendor/github.com/prometheus/procfs/mountstats.go
generated
vendored
51
vendor/github.com/prometheus/procfs/mountstats.go
generated
vendored
@@ -39,8 +39,11 @@ const (
|
||||
statVersion10 = "1.0"
|
||||
statVersion11 = "1.1"
|
||||
|
||||
fieldTransport10Len = 10
|
||||
fieldTransport11Len = 13
|
||||
fieldTransport10TCPLen = 10
|
||||
fieldTransport10UDPLen = 7
|
||||
|
||||
fieldTransport11TCPLen = 13
|
||||
fieldTransport11UDPLen = 10
|
||||
)
|
||||
|
||||
// A Mount is a device mount parsed from /proc/[pid]/mountstats.
|
||||
@@ -186,6 +189,8 @@ type NFSOperationStats struct {
|
||||
// A NFSTransportStats contains statistics for the NFS mount RPC requests and
|
||||
// responses.
|
||||
type NFSTransportStats struct {
|
||||
// The transport protocol used for the NFS mount.
|
||||
Protocol string
|
||||
// The local port used for the NFS mount.
|
||||
Port uint64
|
||||
// Number of times the client has had to establish a connection from scratch
|
||||
@@ -360,7 +365,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
|
||||
return nil, fmt.Errorf("not enough information for NFS transport stats: %v", ss)
|
||||
}
|
||||
|
||||
tstats, err := parseNFSTransportStats(ss[2:], statVersion)
|
||||
tstats, err := parseNFSTransportStats(ss[1:], statVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -522,13 +527,33 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) {
|
||||
// parseNFSTransportStats parses a NFSTransportStats line using an input set of
|
||||
// integer fields matched to a specific stats version.
|
||||
func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats, error) {
|
||||
// Extract the protocol field. It is the only string value in the line
|
||||
protocol := ss[0]
|
||||
ss = ss[1:]
|
||||
|
||||
switch statVersion {
|
||||
case statVersion10:
|
||||
if len(ss) != fieldTransport10Len {
|
||||
var expectedLength int
|
||||
if protocol == "tcp" {
|
||||
expectedLength = fieldTransport10TCPLen
|
||||
} else if protocol == "udp" {
|
||||
expectedLength = fieldTransport10UDPLen
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.0 statement: %v", protocol, ss)
|
||||
}
|
||||
if len(ss) != expectedLength {
|
||||
return nil, fmt.Errorf("invalid NFS transport stats 1.0 statement: %v", ss)
|
||||
}
|
||||
case statVersion11:
|
||||
if len(ss) != fieldTransport11Len {
|
||||
var expectedLength int
|
||||
if protocol == "tcp" {
|
||||
expectedLength = fieldTransport11TCPLen
|
||||
} else if protocol == "udp" {
|
||||
expectedLength = fieldTransport11UDPLen
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.1 statement: %v", protocol, ss)
|
||||
}
|
||||
if len(ss) != expectedLength {
|
||||
return nil, fmt.Errorf("invalid NFS transport stats 1.1 statement: %v", ss)
|
||||
}
|
||||
default:
|
||||
@@ -536,12 +561,13 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
|
||||
}
|
||||
|
||||
// Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay
|
||||
// in a v1.0 response.
|
||||
// in a v1.0 response. Since the stat length is bigger for TCP stats, we use
|
||||
// the TCP length here.
|
||||
//
|
||||
// Note: slice length must be set to length of v1.1 stats to avoid a panic when
|
||||
// only v1.0 stats are present.
|
||||
// See: https://github.com/prometheus/node_exporter/issues/571.
|
||||
ns := make([]uint64, fieldTransport11Len)
|
||||
ns := make([]uint64, fieldTransport11TCPLen)
|
||||
for i, s := range ss {
|
||||
n, err := strconv.ParseUint(s, 10, 64)
|
||||
if err != nil {
|
||||
@@ -551,7 +577,18 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
|
||||
ns[i] = n
|
||||
}
|
||||
|
||||
// The fields differ depending on the transport protocol (TCP or UDP)
|
||||
// From https://utcc.utoronto.ca/%7Ecks/space/blog/linux/NFSMountstatsXprt
|
||||
//
|
||||
// For the udp RPC transport there is no connection count, connect idle time,
|
||||
// or idle time (fields #3, #4, and #5); all other fields are the same. So
|
||||
// we set them to 0 here.
|
||||
if protocol == "udp" {
|
||||
ns = append(ns[:2], append(make([]uint64, 3), ns[2:]...)...)
|
||||
}
|
||||
|
||||
return &NFSTransportStats{
|
||||
Protocol: protocol,
|
||||
Port: ns[0],
|
||||
Bind: ns[1],
|
||||
Connect: ns[2],
|
||||
|
||||
96
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
96
vendor/github.com/prometheus/procfs/mountstats_test.go
generated
vendored
@@ -103,7 +103,12 @@ func TestMountStats(t *testing.T) {
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device with transport stats version 1.0 OK",
|
||||
name: "NFSv3 device with bad transport protocol",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nxprt: tcpx 0 0 0 0 0 0 0 0 0 0",
|
||||
invalid: true,
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using TCP with transport stats version 1.0 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.0\nxprt: tcp 1 2 3 4 5 6 7 8 9 10",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
@@ -112,6 +117,7 @@ func TestMountStats(t *testing.T) {
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.0",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "tcp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 3,
|
||||
@@ -122,6 +128,93 @@ func TestMountStats(t *testing.T) {
|
||||
BadTransactionIDs: 8,
|
||||
CumulativeActiveRequests: 9,
|
||||
CumulativeBacklog: 10,
|
||||
MaximumRPCSlotsUsed: 0, // these three are not
|
||||
CumulativeSendingQueue: 0, // present in statvers=1.0
|
||||
CumulativePendingQueue: 0, //
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using UDP with transport stats version 1.0 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.0\nxprt: udp 1 2 3 4 5 6 7",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.0",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "udp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 0,
|
||||
ConnectIdleTime: 0,
|
||||
IdleTime: 0,
|
||||
Sends: 3,
|
||||
Receives: 4,
|
||||
BadTransactionIDs: 5,
|
||||
CumulativeActiveRequests: 6,
|
||||
CumulativeBacklog: 7,
|
||||
MaximumRPCSlotsUsed: 0, // these three are not
|
||||
CumulativeSendingQueue: 0, // present in statvers=1.0
|
||||
CumulativePendingQueue: 0, //
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using TCP with transport stats version 1.1 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.1\nxprt: tcp 1 2 3 4 5 6 7 8 9 10 11 12 13",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.1",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "tcp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 3,
|
||||
ConnectIdleTime: 4,
|
||||
IdleTime: 5 * time.Second,
|
||||
Sends: 6,
|
||||
Receives: 7,
|
||||
BadTransactionIDs: 8,
|
||||
CumulativeActiveRequests: 9,
|
||||
CumulativeBacklog: 10,
|
||||
MaximumRPCSlotsUsed: 11,
|
||||
CumulativeSendingQueue: 12,
|
||||
CumulativePendingQueue: 13,
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "NFSv3 device using UDP with transport stats version 1.1 OK",
|
||||
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.1\nxprt: udp 1 2 3 4 5 6 7 8 9 10",
|
||||
mounts: []*Mount{{
|
||||
Device: "192.168.1.1:/srv",
|
||||
Mount: "/mnt/nfs",
|
||||
Type: "nfs",
|
||||
Stats: &MountStatsNFS{
|
||||
StatVersion: "1.1",
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "udp",
|
||||
Port: 1,
|
||||
Bind: 2,
|
||||
Connect: 0, // these three are not
|
||||
ConnectIdleTime: 0, // present for UDP
|
||||
IdleTime: 0, //
|
||||
Sends: 3,
|
||||
Receives: 4,
|
||||
BadTransactionIDs: 5,
|
||||
CumulativeActiveRequests: 6,
|
||||
CumulativeBacklog: 7,
|
||||
MaximumRPCSlotsUsed: 8,
|
||||
CumulativeSendingQueue: 9,
|
||||
CumulativePendingQueue: 10,
|
||||
},
|
||||
},
|
||||
}},
|
||||
@@ -212,6 +305,7 @@ func TestMountStats(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Transport: NFSTransportStats{
|
||||
Protocol: "tcp",
|
||||
Port: 832,
|
||||
Connect: 1,
|
||||
IdleTime: 11 * time.Second,
|
||||
|
||||
266
vendor/github.com/prometheus/procfs/sysfs/fixtures.ttar
generated
vendored
266
vendor/github.com/prometheus/procfs/sysfs/fixtures.ttar
generated
vendored
@@ -1,7 +1,142 @@
|
||||
# Archive created by ttar -c -f fixtures.ttar fixtures/
|
||||
# Archive created by ttar -C sysfs/ -c -f sysfs/fixtures.ttar fixtures/
|
||||
Directory: fixtures
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/class
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/class/net
|
||||
Mode: 775
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/class/net/eth0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/addr_assign_type
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/addr_len
|
||||
Lines: 1
|
||||
6
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/address
|
||||
Lines: 1
|
||||
01:01:01:01:01:01
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/broadcast
|
||||
Lines: 1
|
||||
ff:ff:ff:ff:ff:ff
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_changes
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_down_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_up_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/dev_id
|
||||
Lines: 1
|
||||
0x20
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/dormant
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/duplex
|
||||
Lines: 1
|
||||
full
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/flags
|
||||
Lines: 1
|
||||
0x1303
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/ifalias
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/ifindex
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/iflink
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/link_mode
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/mtu
|
||||
Lines: 1
|
||||
1500
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/name_assign_type
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/netdev_group
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/operstate
|
||||
Lines: 1
|
||||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_port_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_port_name
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_switch_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/speed
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/tx_queue_len
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/type
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/devices
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -720,132 +855,3 @@ Lines: 1
|
||||
extent_alloc 2 0 0 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/class/net/eth0/
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/addr_assign_type
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/addr_len
|
||||
Lines: 1
|
||||
6
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/address
|
||||
Lines: 1
|
||||
01:01:01:01:01:01
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/broadcast
|
||||
Lines: 1
|
||||
ff:ff:ff:ff:ff:ff
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_changes
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_down_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/carrier_up_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/dev_id
|
||||
Lines: 1
|
||||
0x20
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/dormant
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/duplex
|
||||
Lines: 1
|
||||
full
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/flags
|
||||
Lines: 1
|
||||
0x1303
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/ifalias
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/ifindex
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/iflink
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/link_mode
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/mtu
|
||||
Lines: 1
|
||||
1500
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/name_assign_type
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/netdev_group
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/operstate
|
||||
Lines: 1
|
||||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_port_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_port_name
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/phys_switch_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/speed
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/tx_queue_len
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/class/net/eth0/type
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
73
vendor/github.com/prometheus/procfs/sysfs/net_class.go
generated
vendored
73
vendor/github.com/prometheus/procfs/sysfs/net_class.go
generated
vendored
@@ -27,32 +27,32 @@ import (
|
||||
// for single interface (iface).
|
||||
type NetClassIface struct {
|
||||
Name string // Interface name
|
||||
AddrAssignType int64 `fileName:"addr_assign_type"` // /sys/class/net/<iface>/addr_assign_type
|
||||
AddrLen int64 `fileName:"addr_len"` // /sys/class/net/<iface>/addr_len
|
||||
AddrAssignType *int64 `fileName:"addr_assign_type"` // /sys/class/net/<iface>/addr_assign_type
|
||||
AddrLen *int64 `fileName:"addr_len"` // /sys/class/net/<iface>/addr_len
|
||||
Address string `fileName:"address"` // /sys/class/net/<iface>/address
|
||||
Broadcast string `fileName:"broadcast"` // /sys/class/net/<iface>/broadcast
|
||||
Carrier int64 `fileName:"carrier"` // /sys/class/net/<iface>/carrier
|
||||
CarrierChanges int64 `fileName:"carrier_changes"` // /sys/class/net/<iface>/carrier_changes
|
||||
CarrierUpCount int64 `fileName:"carrier_up_count"` // /sys/class/net/<iface>/carrier_up_count
|
||||
CarrierDownCount int64 `fileName:"carrier_down_count"` // /sys/class/net/<iface>/carrier_down_count
|
||||
DevID int64 `fileName:"dev_id"` // /sys/class/net/<iface>/dev_id
|
||||
Dormant int64 `fileName:"dormant"` // /sys/class/net/<iface>/dormant
|
||||
Carrier *int64 `fileName:"carrier"` // /sys/class/net/<iface>/carrier
|
||||
CarrierChanges *int64 `fileName:"carrier_changes"` // /sys/class/net/<iface>/carrier_changes
|
||||
CarrierUpCount *int64 `fileName:"carrier_up_count"` // /sys/class/net/<iface>/carrier_up_count
|
||||
CarrierDownCount *int64 `fileName:"carrier_down_count"` // /sys/class/net/<iface>/carrier_down_count
|
||||
DevID *int64 `fileName:"dev_id"` // /sys/class/net/<iface>/dev_id
|
||||
Dormant *int64 `fileName:"dormant"` // /sys/class/net/<iface>/dormant
|
||||
Duplex string `fileName:"duplex"` // /sys/class/net/<iface>/duplex
|
||||
Flags int64 `fileName:"flags"` // /sys/class/net/<iface>/flags
|
||||
Flags *int64 `fileName:"flags"` // /sys/class/net/<iface>/flags
|
||||
IfAlias string `fileName:"ifalias"` // /sys/class/net/<iface>/ifalias
|
||||
IfIndex int64 `fileName:"ifindex"` // /sys/class/net/<iface>/ifindex
|
||||
IfLink int64 `fileName:"iflink"` // /sys/class/net/<iface>/iflink
|
||||
LinkMode int64 `fileName:"link_mode"` // /sys/class/net/<iface>/link_mode
|
||||
MTU int64 `fileName:"mtu"` // /sys/class/net/<iface>/mtu
|
||||
NameAssignType int64 `fileName:"name_assign_type"` // /sys/class/net/<iface>/name_assign_type
|
||||
NetDevGroup int64 `fileName:"netdev_group"` // /sys/class/net/<iface>/netdev_group
|
||||
IfIndex *int64 `fileName:"ifindex"` // /sys/class/net/<iface>/ifindex
|
||||
IfLink *int64 `fileName:"iflink"` // /sys/class/net/<iface>/iflink
|
||||
LinkMode *int64 `fileName:"link_mode"` // /sys/class/net/<iface>/link_mode
|
||||
MTU *int64 `fileName:"mtu"` // /sys/class/net/<iface>/mtu
|
||||
NameAssignType *int64 `fileName:"name_assign_type"` // /sys/class/net/<iface>/name_assign_type
|
||||
NetDevGroup *int64 `fileName:"netdev_group"` // /sys/class/net/<iface>/netdev_group
|
||||
OperState string `fileName:"operstate"` // /sys/class/net/<iface>/operstate
|
||||
PhysPortID string `fileName:"phys_port_id"` // /sys/class/net/<iface>/phys_port_id
|
||||
PhysPortName string `fileName:"phys_port_name"` // /sys/class/net/<iface>/phys_port_name
|
||||
PhysSwitchID string `fileName:"phys_switch_id"` // /sys/class/net/<iface>/phys_switch_id
|
||||
Speed int64 `fileName:"speed"` // /sys/class/net/<iface>/speed
|
||||
TxQueueLen int64 `fileName:"tx_queue_len"` // /sys/class/net/<iface>/tx_queue_len
|
||||
Type int64 `fileName:"type"` // /sys/class/net/<iface>/type
|
||||
Speed *int64 `fileName:"speed"` // /sys/class/net/<iface>/speed
|
||||
TxQueueLen *int64 `fileName:"tx_queue_len"` // /sys/class/net/<iface>/tx_queue_len
|
||||
Type *int64 `fileName:"type"` // /sys/class/net/<iface>/type
|
||||
}
|
||||
|
||||
// NetClass is collection of info for every interface (iface) in /sys/class/net. The map keys
|
||||
@@ -80,6 +80,9 @@ func (fs FS) NewNetClass() (NetClass, error) {
|
||||
|
||||
netClass := NetClass{}
|
||||
for _, deviceDir := range devices {
|
||||
if deviceDir.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
interfaceClass, err := netClass.parseNetClassIface(path + "/" + deviceDir.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -117,22 +120,28 @@ func (nc NetClass) parseNetClassIface(devicePath string) (*NetClassIface, error)
|
||||
value := strings.TrimSpace(string(fileContents))
|
||||
|
||||
switch fieldValue.Kind() {
|
||||
case reflect.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)
|
||||
}
|
||||
fieldValue.SetInt(intValue)
|
||||
} 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.SetInt(intValue)
|
||||
}
|
||||
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())
|
||||
}
|
||||
|
||||
57
vendor/github.com/prometheus/procfs/sysfs/net_class_test.go
generated
vendored
57
vendor/github.com/prometheus/procfs/sysfs/net_class_test.go
generated
vendored
@@ -29,35 +29,56 @@ func TestNewNetClass(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var (
|
||||
addrAssignType int64 = 3
|
||||
addrLen int64 = 6
|
||||
carrier int64 = 1
|
||||
carrierChanges int64 = 2
|
||||
carrierDownCount int64 = 1
|
||||
carrierUpCount int64 = 1
|
||||
devID int64 = 32
|
||||
dormant int64 = 1
|
||||
flags int64 = 4867
|
||||
ifIndex int64 = 2
|
||||
ifLink int64 = 2
|
||||
linkMode int64 = 1
|
||||
mtu int64 = 1500
|
||||
nameAssignType int64 = 2
|
||||
netDevGroup int64 = 0
|
||||
speed int64 = 1000
|
||||
txQueueLen int64 = 1000
|
||||
netType int64 = 1
|
||||
)
|
||||
|
||||
netClass := NetClass{
|
||||
"eth0": {
|
||||
Address: "01:01:01:01:01:01",
|
||||
AddrAssignType: 3,
|
||||
AddrLen: 6,
|
||||
AddrAssignType: &addrAssignType,
|
||||
AddrLen: &addrLen,
|
||||
Broadcast: "ff:ff:ff:ff:ff:ff",
|
||||
Carrier: 1,
|
||||
CarrierChanges: 2,
|
||||
CarrierDownCount: 1,
|
||||
CarrierUpCount: 1,
|
||||
DevID: 32,
|
||||
Dormant: 1,
|
||||
Carrier: &carrier,
|
||||
CarrierChanges: &carrierChanges,
|
||||
CarrierDownCount: &carrierDownCount,
|
||||
CarrierUpCount: &carrierUpCount,
|
||||
DevID: &devID,
|
||||
Dormant: &dormant,
|
||||
Duplex: "full",
|
||||
Flags: 4867,
|
||||
Flags: &flags,
|
||||
IfAlias: "",
|
||||
IfIndex: 2,
|
||||
IfLink: 2,
|
||||
LinkMode: 1,
|
||||
MTU: 1500,
|
||||
IfIndex: &ifIndex,
|
||||
IfLink: &ifLink,
|
||||
LinkMode: &linkMode,
|
||||
MTU: &mtu,
|
||||
Name: "eth0",
|
||||
NameAssignType: 2,
|
||||
NetDevGroup: 0,
|
||||
NameAssignType: &nameAssignType,
|
||||
NetDevGroup: &netDevGroup,
|
||||
OperState: "up",
|
||||
PhysPortID: "",
|
||||
PhysPortName: "",
|
||||
PhysSwitchID: "",
|
||||
Speed: 1000,
|
||||
TxQueueLen: 1000,
|
||||
Type: 1,
|
||||
Speed: &speed,
|
||||
TxQueueLen: &txQueueLen,
|
||||
Type: &netType,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/prometheus/procfs/xfrm.go
generated
vendored
2
vendor/github.com/prometheus/procfs/xfrm.go
generated
vendored
@@ -113,7 +113,7 @@ func (fs FS) NewXfrmStat() (XfrmStat, error) {
|
||||
|
||||
if len(fields) != 2 {
|
||||
return XfrmStat{}, fmt.Errorf(
|
||||
"couldnt parse %s line %s", file.Name(), s.Text())
|
||||
"couldn't parse %s line %s", file.Name(), s.Text())
|
||||
}
|
||||
|
||||
name := fields[0]
|
||||
|
||||
Reference in New Issue
Block a user