From 3b37d67a2b7b3728507d598cb9bec5bc6e11794f Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Mon, 2 Dec 2019 14:48:09 +0100 Subject: [PATCH] Collect non-numeric data from /sys/class/infiniband Let the node exporter collect the non-numeric data from /sys/class/infiniband: board ID, firmware version, and HCA type. Signed-off-by: Benjamin Drung --- collector/fixtures/e2e-64k-page-output.txt | 4 ++++ collector/fixtures/e2e-output.txt | 4 ++++ collector/infiniband_linux.go | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 9f75f082a4..aa7126ce0d 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -792,6 +792,10 @@ 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_info Non-numeric data from /sys/class/infiniband/, value is always 1. +# TYPE node_infiniband_info gauge +node_infiniband_info{board_id="I40IW Board ID",device="i40iw0",firmware_version="0.2",hca_type="I40IW"} 1 +node_infiniband_info{board_id="SM_1141000001000",device="mlx4_0",firmware_version="2.31.5050",hca_type="MT4099"} 1 # 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"} 1.8527668e+07 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index e915f923ee..18152fde04 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -813,6 +813,10 @@ 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_info Non-numeric data from /sys/class/infiniband/, value is always 1. +# TYPE node_infiniband_info gauge +node_infiniband_info{board_id="I40IW Board ID",device="i40iw0",firmware_version="0.2",hca_type="I40IW"} 1 +node_infiniband_info{board_id="SM_1141000001000",device="mlx4_0",firmware_version="2.31.5050",hca_type="MT4099"} 1 # 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"} 1.8527668e+07 diff --git a/collector/infiniband_linux.go b/collector/infiniband_linux.go index 828e40e5ce..7672f6cf0b 100644 --- a/collector/infiniband_linux.go +++ b/collector/infiniband_linux.go @@ -27,6 +27,7 @@ import ( type infinibandCollector struct { fs sysfs.FS metricDescs map[string]*prometheus.Desc + subsystem string } func init() { @@ -75,10 +76,11 @@ func NewInfiniBandCollector() (Collector, error) { } i.metricDescs = make(map[string]*prometheus.Desc) + i.subsystem = "infiniband" for metricName, description := range descriptions { i.metricDescs[metricName] = prometheus.NewDesc( - prometheus.BuildFQName(namespace, "infiniband", metricName), + prometheus.BuildFQName(namespace, i.subsystem, metricName), description, []string{"device", "port"}, nil, @@ -105,6 +107,15 @@ func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error { } for _, device := range devices { + infoDesc := prometheus.NewDesc( + prometheus.BuildFQName(namespace, c.subsystem, "info"), + "Non-numeric data from /sys/class/infiniband/, value is always 1.", + []string{"device", "board_id", "firmware_version", "hca_type"}, + nil, + ) + infoValue := 1.0 + ch <- prometheus.MustNewConstMetric(infoDesc, prometheus.GaugeValue, infoValue, device.Name, device.BoardID, device.FirmwareVersion, device.HCAType) + for _, port := range device.Ports { portStr := strconv.FormatUint(uint64(port.Port), 10)