Repository: prometheus/procfs
Pull request #374 (2021-04-05 15:46:22)

Add several Infiniband counters
Counters added:
* excessive_buffer_overrun_errors
* local_link_integrity_errors

Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>


Patch:
diff --git a/sysfs/class_infiniband.go b/sysfs/class_infiniband.go
index cb71824..e9ee284 100644
--- a/sysfs/class_infiniband.go
+++ b/sysfs/class_infiniband.go
@@ -42,26 +42,28 @@ type InfiniBandCounters struct {
 	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
-	PortRcvRemotePhysicalErrors *uint64 // counters/port_rcv_remote_physical_errors
-	PortRcvSwitchRelayErrors    *uint64 // counters/port_rcv_switch_relay_errors
-	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
-	SymbolError                 *uint64 // counters/symbol_error
-	UnicastRcvPackets           *uint64 // counters/unicast_rcv_packets
-	UnicastXmitPackets          *uint64 // counters/unicast_xmit_packets
-	VL15Dropped                 *uint64 // counters/VL15_dropped
+	ExcessiveBufferOverrunErrors *uint64 // counters/excessive_buffer_overrun_errors
+	LinkDowned                   *uint64 // counters/link_downed
+	LinkErrorRecovery            *uint64 // counters/link_error_recovery
+	LocalLinkIntegrityErrors     *uint64 // counters/local_link_integrity_errors
+	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
+	PortRcvRemotePhysicalErrors  *uint64 // counters/port_rcv_remote_physical_errors
+	PortRcvSwitchRelayErrors     *uint64 // counters/port_rcv_switch_relay_errors
+	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
+	SymbolError                  *uint64 // counters/symbol_error
+	UnicastRcvPackets            *uint64 // counters/unicast_rcv_packets
+	UnicastXmitPackets           *uint64 // counters/unicast_xmit_packets
+	VL15Dropped                  *uint64 // counters/VL15_dropped
 }
 
 // InfiniBandPort contains info from files in
@@ -270,10 +272,14 @@ func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) {
 		vp := util.NewValueParser(value)
 
 		switch f.Name() {
+		case "excessive_buffer_overrun_errors":
+			counters.ExcessiveBufferOverrunErrors = vp.PUInt64()
 		case "link_downed":
 			counters.LinkDowned = vp.PUInt64()
 		case "link_error_recovery":
 			counters.LinkErrorRecovery = vp.PUInt64()
+		case "local_link_integrity_errors":
+			counters.LocalLinkIntegrityErrors = vp.PUInt64()
 		case "multicast_rcv_packets":
 			counters.MulticastRcvPackets = vp.PUInt64()
 		case "multicast_xmit_packets":


Test patch:
diff --git a/sysfs/class_infiniband_test.go b/sysfs/class_infiniband_test.go
index dd377a6..d7592ea 100644
--- a/sysfs/class_infiniband_test.go
+++ b/sysfs/class_infiniband_test.go
@@ -63,37 +63,41 @@ func TestInfiniBandClass(t *testing.T) {
 	}
 
 	var (
-		port1LinkDowned                  uint64
-		port1LinkErrorRecovery           uint64
-		port1PortRcvConstraintErrors     uint64
-		port1PortRcvData                 uint64 = 8884894436
-		port1PortRcvErrors               uint64
-		port1PortRcvPackets              uint64 = 87169372
-		port1PortRcvRemotePhysicalErrors uint64
-		port1PortRcvSwitchRelayErrors    uint64
-		port1PortXmitConstraintErrors    uint64
-		port1PortXmitData                uint64 = 106036453180
-		port1PortXmitDiscards            uint64
-		port1PortXmitPackets             uint64 = 85734114
-		port1PortXmitWait                uint64 = 3599
-		port1SymbolError                 uint64
-		port1VL15Dropped                 uint64
+		port1ExcessiveBufferOverrunErrors uint64
+		port1LinkDowned                   uint64
+		port1LinkErrorRecovery            uint64
+		port1LocalLinkIntegrityErrors     uint64
+		port1PortRcvConstraintErrors      uint64
+		port1PortRcvData                  uint64 = 8884894436
+		port1PortRcvErrors                uint64
+		port1PortRcvPackets               uint64 = 87169372
+		port1PortRcvRemotePhysicalErrors  uint64
+		port1PortRcvSwitchRelayErrors     uint64
+		port1PortXmitConstraintErrors     uint64
+		port1PortXmitData                 uint64 = 106036453180
+		port1PortXmitDiscards             uint64
+		port1PortXmitPackets              uint64 = 85734114
+		port1PortXmitWait                 uint64 = 3599
+		port1SymbolError                  uint64
+		port1VL15Dropped                  uint64
 
-		port2LinkDowned                  uint64
-		port2LinkErrorRecovery           uint64
-		port2PortRcvConstraintErrors     uint64
-		port2PortRcvData                 uint64 = 9841747136
-		port2PortRcvErrors               uint64
-		port2PortRcvPackets              uint64 = 89332064
-		port2PortRcvRemotePhysicalErrors uint64
-		port2PortRcvSwitchRelayErrors    uint64
-		port2PortXmitConstraintErrors    uint64
-		port2PortXmitData                uint64 = 106161427560
-		port2PortXmitDiscards            uint64
-		port2PortXmitPackets             uint64 = 88622850
-		port2PortXmitWait                uint64 = 3846
-		port2SymbolError                 uint64
-		port2VL15Dropped                 uint64
+		port2ExcessiveBufferOverrunErrors uint64
+		port2LinkDowned                   uint64
+		port2LinkErrorRecovery            uint64
+		port2LocalLinkIntegrityErrors     uint64
+		port2PortRcvConstraintErrors      uint64
+		port2PortRcvData                  uint64 = 9841747136
+		port2PortRcvErrors                uint64
+		port2PortRcvPackets               uint64 = 89332064
+		port2PortRcvRemotePhysicalErrors  uint64
+		port2PortRcvSwitchRelayErrors     uint64
+		port2PortXmitConstraintErrors     uint64
+		port2PortXmitData                 uint64 = 106161427560
+		port2PortXmitDiscards             uint64
+		port2PortXmitPackets              uint64 = 88622850
+		port2PortXmitWait                 uint64 = 3846
+		port2SymbolError                  uint64
+		port2VL15Dropped                  uint64
 	)
 
 	want := InfiniBandClass{
@@ -112,21 +116,23 @@ func TestInfiniBandClass(t *testing.T) {
 					PhysStateID: 5,
 					Rate:        5000000000,
 					Counters: InfiniBandCounters{
-						LinkDowned:                  &port1LinkDowned,
-						LinkErrorRecovery:           &port1LinkErrorRecovery,
-						PortRcvConstraintErrors:     &port1PortRcvConstraintErrors,
-						PortRcvData:                 &port1PortRcvData,
-						PortRcvErrors:               &port1PortRcvErrors,
-						PortRcvPackets:              &port1PortRcvPackets,
-						PortRcvRemotePhysicalErrors: &port1PortRcvRemotePhysicalErrors,
-						PortRcvSwitchRelayErrors:    &port1PortRcvSwitchRelayErrors,
-						PortXmitConstraintErrors:    &port1PortXmitConstraintErrors,
-						PortXmitData:                &port1PortXmitData,
-						PortXmitDiscards:            &port1PortXmitDiscards,
-						PortXmitPackets:             &port1PortXmitPackets,
-						PortXmitWait:                &port1PortXmitWait,
-						SymbolError:                 &port1SymbolError,
-						VL15Dropped:                 &port1VL15Dropped,
+						ExcessiveBufferOverrunErrors: &port1ExcessiveBufferOverrunErrors,
+						LinkDowned:                   &port1LinkDowned,
+						LinkErrorRecovery:            &port1LinkErrorRecovery,
+						LocalLinkIntegrityErrors:     &port1LocalLinkIntegrityErrors,
+						PortRcvConstraintErrors:      &port1PortRcvConstraintErrors,
+						PortRcvData:                  &port1PortRcvData,
+						PortRcvErrors:                &port1PortRcvErrors,
+						PortRcvPackets:               &port1PortRcvPackets,
+						PortRcvRemotePhysicalErrors:  &port1PortRcvRemotePhysicalErrors,
+						PortRcvSwitchRelayErrors:     &port1PortRcvSwitchRelayErrors,
+						PortXmitConstraintErrors:     &port1PortXmitConstraintErrors,
+						PortXmitData:                 &port1PortXmitData,
+						PortXmitDiscards:             &port1PortXmitDiscards,
+						PortXmitPackets:              &port1PortXmitPackets,
+						PortXmitWait:                 &port1PortXmitWait,
+						SymbolError:                  &port1SymbolError,
+						VL15Dropped:                  &port1VL15Dropped,
 					},
 				},
 				2: {
@@ -138,21 +144,23 @@ func TestInfiniBandClass(t *testing.T) {
 					PhysStateID: 5,
 					Rate:        5000000000,
 					Counters: InfiniBandCounters{
-						LinkDowned:                  &port2LinkDowned,
-						LinkErrorRecovery:           &port2LinkErrorRecovery,
-						PortRcvConstraintErrors:     &port2PortRcvConstraintErrors,
-						PortRcvData:                 &port2PortRcvData,
-						PortRcvErrors:               &port2PortRcvErrors,
-						PortRcvPackets:              &port2PortRcvPackets,
-						PortRcvRemotePhysicalErrors: &port2PortRcvRemotePhysicalErrors,
-						PortRcvSwitchRelayErrors:    &port2PortRcvSwitchRelayErrors,
-						PortXmitConstraintErrors:    &port2PortXmitConstraintErrors,
-						PortXmitData:                &port2PortXmitData,
-						PortXmitDiscards:            &port2PortXmitDiscards,
-						PortXmitPackets:             &port2PortXmitPackets,
-						PortXmitWait:                &port2PortXmitWait,
-						SymbolError:                 &port2SymbolError,
-						VL15Dropped:                 &port2VL15Dropped,
+						ExcessiveBufferOverrunErrors: &port2ExcessiveBufferOverrunErrors,
+						LinkDowned:                   &port2LinkDowned,
+						LinkErrorRecovery:            &port2LinkErrorRecovery,
+						LocalLinkIntegrityErrors:     &port2LocalLinkIntegrityErrors,
+						PortRcvConstraintErrors:      &port2PortRcvConstraintErrors,
+						PortRcvData:                  &port2PortRcvData,
+						PortRcvErrors:                &port2PortRcvErrors,
+						PortRcvPackets:               &port2PortRcvPackets,
+						PortRcvRemotePhysicalErrors:  &port2PortRcvRemotePhysicalErrors,
+						PortRcvSwitchRelayErrors:     &port2PortRcvSwitchRelayErrors,
+						PortXmitConstraintErrors:     &port2PortXmitConstraintErrors,
+						PortXmitData:                 &port2PortXmitData,
+						PortXmitDiscards:             &port2PortXmitDiscards,
+						PortXmitPackets:              &port2PortXmitPackets,
+						PortXmitWait:                 &port2PortXmitWait,
+						SymbolError:                  &port2SymbolError,
+						VL15Dropped:                  &port2VL15Dropped,
 					},
 				},
 			},