From 3a5917dfdca469c3d97649554f9a98731ba0b8bc Mon Sep 17 00:00:00 2001 From: Robert Clark Date: Thu, 9 Mar 2017 16:10:36 -0600 Subject: [PATCH] Add support for legacy InfiniBand drivers Older versions of the OFED drivers contain 64-bit variants of the port counters and are located in a directory named 'counters_ext'. This patch includes these older metrics that have since been deprecated with OFED 4.0. Signed-Off-By: Robert Clark --- collector/fixtures/e2e-output.txt | 32 +++++++++++++ .../1/counters_ext/port_multicast_rcv_packets | 1 + .../counters_ext/port_multicast_xmit_packets | 1 + .../ports/1/counters_ext/port_rcv_data_64 | 1 + .../ports/1/counters_ext/port_rcv_packets_64 | 1 + .../1/counters_ext/port_unicast_rcv_packets | 1 + .../1/counters_ext/port_unicast_xmit_packets | 1 + .../ports/1/counters_ext/port_xmit_data_64 | 1 + .../ports/1/counters_ext/port_xmit_packets_64 | 1 + .../2/counters_ext/port_multicast_rcv_packets | 1 + .../counters_ext/port_multicast_xmit_packets | 1 + .../ports/2/counters_ext/port_rcv_data_64 | 1 + .../ports/2/counters_ext/port_rcv_packets_64 | 1 + .../2/counters_ext/port_unicast_rcv_packets | 1 + .../2/counters_ext/port_unicast_xmit_packets | 1 + .../ports/2/counters_ext/port_xmit_data_64 | 1 + .../ports/2/counters_ext/port_xmit_packets_64 | 1 + collector/infiniband_linux.go | 45 ++++++++++++++++++- 18 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_rcv_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_xmit_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_data_64 create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_packets_64 create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_rcv_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_xmit_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_data_64 create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_packets_64 create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_rcv_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_xmit_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_data_64 create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_packets_64 create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_rcv_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_xmit_packets create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_data_64 create mode 100644 collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_packets_64 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 48df21b9..c5820264 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -689,6 +689,38 @@ node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp2"} 84 node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp3"} 84 node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp4"} 84 node_hwmon_temp_max_celsius{chip="platform_coretemp_1",sensor="temp5"} 84 +# HELP node_infiniband_legacy_data_received_bytes_total Number of data octets received on all links +# TYPE node_infiniband_legacy_data_received_bytes_total counter +node_infiniband_legacy_data_received_bytes_total{device="mlx4_0",port="1"} 4.631917e+06 +node_infiniband_legacy_data_received_bytes_total{device="mlx4_0",port="2"} 4.631917e+06 +# HELP node_infiniband_legacy_data_transmitted_bytes_total Number of data octets transmitted on all links +# TYPE node_infiniband_legacy_data_transmitted_bytes_total counter +node_infiniband_legacy_data_transmitted_bytes_total{device="mlx4_0",port="1"} 3.73344e+06 +node_infiniband_legacy_data_transmitted_bytes_total{device="mlx4_0",port="2"} 3.73344e+06 +# HELP node_infiniband_legacy_multicast_packets_received_total Number of multicast packets received +# TYPE node_infiniband_legacy_multicast_packets_received_total counter +node_infiniband_legacy_multicast_packets_received_total{device="mlx4_0",port="1"} 93 +node_infiniband_legacy_multicast_packets_received_total{device="mlx4_0",port="2"} 93 +# HELP node_infiniband_legacy_multicast_packets_transmitted_total Number of multicast packets transmitted +# TYPE node_infiniband_legacy_multicast_packets_transmitted_total counter +node_infiniband_legacy_multicast_packets_transmitted_total{device="mlx4_0",port="1"} 16 +node_infiniband_legacy_multicast_packets_transmitted_total{device="mlx4_0",port="2"} 16 +# HELP node_infiniband_legacy_packets_received_total Number of data packets received on all links +# TYPE node_infiniband_legacy_packets_received_total counter +node_infiniband_legacy_packets_received_total{device="mlx4_0",port="1"} 0 +node_infiniband_legacy_packets_received_total{device="mlx4_0",port="2"} 0 +# HELP node_infiniband_legacy_packets_transmitted_total Number of data packets received on all links +# TYPE node_infiniband_legacy_packets_transmitted_total counter +node_infiniband_legacy_packets_transmitted_total{device="mlx4_0",port="1"} 0 +node_infiniband_legacy_packets_transmitted_total{device="mlx4_0",port="2"} 0 +# HELP node_infiniband_legacy_unicast_packets_received_total Number of unicast packets received +# TYPE node_infiniband_legacy_unicast_packets_received_total counter +node_infiniband_legacy_unicast_packets_received_total{device="mlx4_0",port="1"} 61148 +node_infiniband_legacy_unicast_packets_received_total{device="mlx4_0",port="2"} 61148 +# HELP node_infiniband_legacy_unicast_packets_transmitted_total Number of unicast packets transmitted +# TYPE node_infiniband_legacy_unicast_packets_transmitted_total counter +node_infiniband_legacy_unicast_packets_transmitted_total{device="mlx4_0",port="1"} 61239 +node_infiniband_legacy_unicast_packets_transmitted_total{device="mlx4_0",port="2"} 61239 # HELP node_infiniband_link_downed_total Number of times the link failed to recover from an error state and went down # TYPE node_infiniband_link_downed_total counter node_infiniband_link_downed_total{device="mlx4_0",port="1"} 0 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_rcv_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_rcv_packets new file mode 100644 index 00000000..c67f579c --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_rcv_packets @@ -0,0 +1 @@ +93 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_xmit_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_xmit_packets new file mode 100644 index 00000000..b6a7d89c --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_multicast_xmit_packets @@ -0,0 +1 @@ +16 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_data_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_data_64 new file mode 100644 index 00000000..496ea27d --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_data_64 @@ -0,0 +1 @@ +4631917 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_packets_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_packets_64 new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_rcv_packets_64 @@ -0,0 +1 @@ +0 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_rcv_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_rcv_packets new file mode 100644 index 00000000..2406651b --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_rcv_packets @@ -0,0 +1 @@ +61148 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_xmit_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_xmit_packets new file mode 100644 index 00000000..6279bd6a --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_unicast_xmit_packets @@ -0,0 +1 @@ +61239 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_data_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_data_64 new file mode 100644 index 00000000..85ea8ebf --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_data_64 @@ -0,0 +1 @@ +3733440 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_packets_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_packets_64 new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/1/counters_ext/port_xmit_packets_64 @@ -0,0 +1 @@ +0 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_rcv_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_rcv_packets new file mode 100644 index 00000000..c67f579c --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_rcv_packets @@ -0,0 +1 @@ +93 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_xmit_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_xmit_packets new file mode 100644 index 00000000..b6a7d89c --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_multicast_xmit_packets @@ -0,0 +1 @@ +16 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_data_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_data_64 new file mode 100644 index 00000000..496ea27d --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_data_64 @@ -0,0 +1 @@ +4631917 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_packets_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_packets_64 new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_rcv_packets_64 @@ -0,0 +1 @@ +0 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_rcv_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_rcv_packets new file mode 100644 index 00000000..2406651b --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_rcv_packets @@ -0,0 +1 @@ +61148 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_xmit_packets b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_xmit_packets new file mode 100644 index 00000000..6279bd6a --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_unicast_xmit_packets @@ -0,0 +1 @@ +61239 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_data_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_data_64 new file mode 100644 index 00000000..85ea8ebf --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_data_64 @@ -0,0 +1 @@ +3733440 diff --git a/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_packets_64 b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_packets_64 new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/collector/fixtures/sys/class/infiniband/mlx4_0/ports/2/counters_ext/port_xmit_packets_64 @@ -0,0 +1 @@ +0 diff --git a/collector/infiniband_linux.go b/collector/infiniband_linux.go index 0ec1bd8b..bb4add4e 100644 --- a/collector/infiniband_linux.go +++ b/collector/infiniband_linux.go @@ -33,8 +33,9 @@ var ( ) type infinibandCollector struct { - metricDescs map[string]*prometheus.Desc - counters map[string]infinibandMetric + metricDescs map[string]*prometheus.Desc + counters map[string]infinibandMetric + legacyCounters map[string]infinibandMetric } type infinibandMetric struct { @@ -62,6 +63,18 @@ func NewInfiniBandCollector() (Collector, error) { "unicast_packets_transmitted_total": {"unicast_xmit_packets", "Number of unicast packets transmitted (including errors)"}, } + // Deprecated counters for some older versions of InfiniBand drivers. + i.legacyCounters = map[string]infinibandMetric{ + "legacy_multicast_packets_received_total": {"port_multicast_rcv_packets", "Number of multicast packets received"}, + "legacy_multicast_packets_transmitted_total": {"port_multicast_xmit_packets", "Number of multicast packets transmitted"}, + "legacy_data_received_bytes_total": {"port_rcv_data_64", "Number of data octets received on all links"}, + "legacy_packets_received_total": {"port_rcv_packets_64", "Number of data packets received on all links"}, + "legacy_unicast_packets_received_total": {"port_unicast_rcv_packets", "Number of unicast packets received"}, + "legacy_unicast_packets_transmitted_total": {"port_unicast_xmit_packets", "Number of unicast packets transmitted"}, + "legacy_data_transmitted_bytes_total": {"port_xmit_data_64", "Number of data octets transmitted on all links"}, + "legacy_packets_transmitted_total": {"port_xmit_packets_64", "Number of data packets received on all links"}, + } + subsystem := "infiniband" i.metricDescs = make(map[string]*prometheus.Desc) @@ -74,6 +87,15 @@ func NewInfiniBandCollector() (Collector, error) { ) } + for metricName, infinibandMetric := range i.legacyCounters { + i.metricDescs[metricName] = prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, metricName), + infinibandMetric.Help, + []string{"device", "port"}, + nil, + ) + } + return &i, nil } @@ -175,6 +197,25 @@ func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error { port, ) } + + // Add metrics for the legacy InfiniBand counters. + for metricName, infinibandMetric := range c.legacyCounters { + if _, err := os.Stat(filepath.Join(portFiles, "counters_ext", infinibandMetric.File)); os.IsNotExist(err) { + continue + } + metric, err := readMetric(filepath.Join(portFiles, "counters_ext"), infinibandMetric.File) + if err != nil { + return err + } + + ch <- prometheus.MustNewConstMetric( + c.metricDescs[metricName], + prometheus.CounterValue, + float64(metric), + device, + port, + ) + } } }