Skip to content

Commit 9676f5f

Browse files
Merge pull request #523 from roclark/support-legacy-infiniband
Add support for legacy InfiniBand drivers
2 parents 620e993 + 3a5917d commit 9676f5f

18 files changed

+91
-2
lines changed

collector/fixtures/e2e-output.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,38 @@ node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp2"} 84
689689
node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp3"} 84
690690
node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp4"} 84
691691
node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp5"} 84
692+
# HELP node_infiniband_legacy_data_received_bytes_total Number of data octets received on all links
693+
# TYPE node_infiniband_legacy_data_received_bytes_total counter
694+
node_infiniband_legacy_data_received_bytes_total{device="mlx4_0",port="1"} 4.631917e+06
695+
node_infiniband_legacy_data_received_bytes_total{device="mlx4_0",port="2"} 4.631917e+06
696+
# HELP node_infiniband_legacy_data_transmitted_bytes_total Number of data octets transmitted on all links
697+
# TYPE node_infiniband_legacy_data_transmitted_bytes_total counter
698+
node_infiniband_legacy_data_transmitted_bytes_total{device="mlx4_0",port="1"} 3.73344e+06
699+
node_infiniband_legacy_data_transmitted_bytes_total{device="mlx4_0",port="2"} 3.73344e+06
700+
# HELP node_infiniband_legacy_multicast_packets_received_total Number of multicast packets received
701+
# TYPE node_infiniband_legacy_multicast_packets_received_total counter
702+
node_infiniband_legacy_multicast_packets_received_total{device="mlx4_0",port="1"} 93
703+
node_infiniband_legacy_multicast_packets_received_total{device="mlx4_0",port="2"} 93
704+
# HELP node_infiniband_legacy_multicast_packets_transmitted_total Number of multicast packets transmitted
705+
# TYPE node_infiniband_legacy_multicast_packets_transmitted_total counter
706+
node_infiniband_legacy_multicast_packets_transmitted_total{device="mlx4_0",port="1"} 16
707+
node_infiniband_legacy_multicast_packets_transmitted_total{device="mlx4_0",port="2"} 16
708+
# HELP node_infiniband_legacy_packets_received_total Number of data packets received on all links
709+
# TYPE node_infiniband_legacy_packets_received_total counter
710+
node_infiniband_legacy_packets_received_total{device="mlx4_0",port="1"} 0
711+
node_infiniband_legacy_packets_received_total{device="mlx4_0",port="2"} 0
712+
# HELP node_infiniband_legacy_packets_transmitted_total Number of data packets received on all links
713+
# TYPE node_infiniband_legacy_packets_transmitted_total counter
714+
node_infiniband_legacy_packets_transmitted_total{device="mlx4_0",port="1"} 0
715+
node_infiniband_legacy_packets_transmitted_total{device="mlx4_0",port="2"} 0
716+
# HELP node_infiniband_legacy_unicast_packets_received_total Number of unicast packets received
717+
# TYPE node_infiniband_legacy_unicast_packets_received_total counter
718+
node_infiniband_legacy_unicast_packets_received_total{device="mlx4_0",port="1"} 61148
719+
node_infiniband_legacy_unicast_packets_received_total{device="mlx4_0",port="2"} 61148
720+
# HELP node_infiniband_legacy_unicast_packets_transmitted_total Number of unicast packets transmitted
721+
# TYPE node_infiniband_legacy_unicast_packets_transmitted_total counter
722+
node_infiniband_legacy_unicast_packets_transmitted_total{device="mlx4_0",port="1"} 61239
723+
node_infiniband_legacy_unicast_packets_transmitted_total{device="mlx4_0",port="2"} 61239
692724
# HELP node_infiniband_link_downed_total Number of times the link failed to recover from an error state and went down
693725
# TYPE node_infiniband_link_downed_total counter
694726
node_infiniband_link_downed_total{device="mlx4_0",port="1"} 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
93
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4631917
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
61148
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
61239
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3733440
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
93
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4631917
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
61148
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
61239
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3733440
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

collector/infiniband_linux.go

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ var (
3333
)
3434

3535
type infinibandCollector struct {
36-
metricDescs map[string]*prometheus.Desc
37-
counters map[string]infinibandMetric
36+
metricDescs map[string]*prometheus.Desc
37+
counters map[string]infinibandMetric
38+
legacyCounters map[string]infinibandMetric
3839
}
3940

4041
type infinibandMetric struct {
@@ -62,6 +63,18 @@ func NewInfiniBandCollector() (Collector, error) {
6263
"unicast_packets_transmitted_total": {"unicast_xmit_packets", "Number of unicast packets transmitted (including errors)"},
6364
}
6465

66+
// Deprecated counters for some older versions of InfiniBand drivers.
67+
i.legacyCounters = map[string]infinibandMetric{
68+
"legacy_multicast_packets_received_total": {"port_multicast_rcv_packets", "Number of multicast packets received"},
69+
"legacy_multicast_packets_transmitted_total": {"port_multicast_xmit_packets", "Number of multicast packets transmitted"},
70+
"legacy_data_received_bytes_total": {"port_rcv_data_64", "Number of data octets received on all links"},
71+
"legacy_packets_received_total": {"port_rcv_packets_64", "Number of data packets received on all links"},
72+
"legacy_unicast_packets_received_total": {"port_unicast_rcv_packets", "Number of unicast packets received"},
73+
"legacy_unicast_packets_transmitted_total": {"port_unicast_xmit_packets", "Number of unicast packets transmitted"},
74+
"legacy_data_transmitted_bytes_total": {"port_xmit_data_64", "Number of data octets transmitted on all links"},
75+
"legacy_packets_transmitted_total": {"port_xmit_packets_64", "Number of data packets received on all links"},
76+
}
77+
6578
subsystem := "infiniband"
6679
i.metricDescs = make(map[string]*prometheus.Desc)
6780

@@ -74,6 +87,15 @@ func NewInfiniBandCollector() (Collector, error) {
7487
)
7588
}
7689

90+
for metricName, infinibandMetric := range i.legacyCounters {
91+
i.metricDescs[metricName] = prometheus.NewDesc(
92+
prometheus.BuildFQName(Namespace, subsystem, metricName),
93+
infinibandMetric.Help,
94+
[]string{"device", "port"},
95+
nil,
96+
)
97+
}
98+
7799
return &i, nil
78100
}
79101

@@ -175,6 +197,25 @@ func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error {
175197
port,
176198
)
177199
}
200+
201+
// Add metrics for the legacy InfiniBand counters.
202+
for metricName, infinibandMetric := range c.legacyCounters {
203+
if _, err := os.Stat(filepath.Join(portFiles, "counters_ext", infinibandMetric.File)); os.IsNotExist(err) {
204+
continue
205+
}
206+
metric, err := readMetric(filepath.Join(portFiles, "counters_ext"), infinibandMetric.File)
207+
if err != nil {
208+
return err
209+
}
210+
211+
ch <- prometheus.MustNewConstMetric(
212+
c.metricDescs[metricName],
213+
prometheus.CounterValue,
214+
float64(metric),
215+
device,
216+
port,
217+
)
218+
}
178219
}
179220
}
180221

0 commit comments

Comments
 (0)