Collect non-numeric data from /sys/class/infiniband (#1563)

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 <benjamin.drung@cloud.ionos.com>

Co-authored-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Benjamin Drung 2020-02-19 15:18:44 +01:00 committed by GitHub
parent 14eafab016
commit ca1ac435ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View file

@ -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/<device>, 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

View file

@ -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/<device>, 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

View file

@ -31,6 +31,7 @@ type infinibandCollector struct {
fs sysfs.FS
metricDescs map[string]*prometheus.Desc
logger log.Logger
subsystem string
}
func init() {
@ -80,10 +81,11 @@ func NewInfiniBandCollector(logger log.Logger) (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,
@ -114,6 +116,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/<device>, 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)