diff options
author | Robert Clark <robert.d.clark@hpe.com> | 2017-03-09 16:10:36 -0600 |
---|---|---|
committer | Robert Clark <robert.d.clark@hpe.com> | 2017-03-20 10:37:21 -0500 |
commit | 3a5917dfdca469c3d97649554f9a98731ba0b8bc (patch) | |
tree | ae71decf3336e23e16c6ece8f336b39559b666dc /collector/infiniband_linux.go | |
parent | 8529cd3359f16f08368279bb5735254fe16c0af4 (diff) | |
download | prometheus_node_collector-3a5917dfdca469c3d97649554f9a98731ba0b8bc.tar.bz2 prometheus_node_collector-3a5917dfdca469c3d97649554f9a98731ba0b8bc.tar.xz prometheus_node_collector-3a5917dfdca469c3d97649554f9a98731ba0b8bc.zip |
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 <robert.d.clark@hpe.com>
Diffstat (limited to 'collector/infiniband_linux.go')
-rw-r--r-- | collector/infiniband_linux.go | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/collector/infiniband_linux.go b/collector/infiniband_linux.go index 0ec1bd8..bb4add4 100644 --- a/collector/infiniband_linux.go +++ b/collector/infiniband_linux.go | |||
@@ -33,8 +33,9 @@ var ( | |||
33 | ) | 33 | ) |
34 | 34 | ||
35 | type infinibandCollector struct { | 35 | type infinibandCollector struct { |
36 | metricDescs map[string]*prometheus.Desc | 36 | metricDescs map[string]*prometheus.Desc |
37 | counters map[string]infinibandMetric | 37 | counters map[string]infinibandMetric |
38 | legacyCounters map[string]infinibandMetric | ||
38 | } | 39 | } |
39 | 40 | ||
40 | type infinibandMetric struct { | 41 | type infinibandMetric struct { |
@@ -62,6 +63,18 @@ func NewInfiniBandCollector() (Collector, error) { | |||
62 | "unicast_packets_transmitted_total": {"unicast_xmit_packets", "Number of unicast packets transmitted (including errors)"}, | 63 | "unicast_packets_transmitted_total": {"unicast_xmit_packets", "Number of unicast packets transmitted (including errors)"}, |
63 | } | 64 | } |
64 | 65 | ||
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 | |||
65 | subsystem := "infiniband" | 78 | subsystem := "infiniband" |
66 | i.metricDescs = make(map[string]*prometheus.Desc) | 79 | i.metricDescs = make(map[string]*prometheus.Desc) |
67 | 80 | ||
@@ -74,6 +87,15 @@ func NewInfiniBandCollector() (Collector, error) { | |||
74 | ) | 87 | ) |
75 | } | 88 | } |
76 | 89 | ||
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 | |||
77 | return &i, nil | 99 | return &i, nil |
78 | } | 100 | } |
79 | 101 | ||
@@ -175,6 +197,25 @@ func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error { | |||
175 | port, | 197 | port, |
176 | ) | 198 | ) |
177 | } | 199 | } |
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 | } | ||
178 | } | 219 | } |
179 | } | 220 | } |
180 | 221 | ||