mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-08-20 18:33:52 -07:00
infiniband: add link_layer label (#2)
This commit is contained in:
parent
dc09a93962
commit
f53c868070
|
@ -93,7 +93,7 @@ func NewInfiniBandCollector(logger *slog.Logger) (Collector, error) {
|
|||
i.metricDescs[metricName] = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, i.subsystem, metricName),
|
||||
description,
|
||||
[]string{"device", "port"},
|
||||
[]string{"device", "port", "link_layer"},
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
@ -101,13 +101,13 @@ func NewInfiniBandCollector(logger *slog.Logger) (Collector, error) {
|
|||
return &i, nil
|
||||
}
|
||||
|
||||
func (c *infinibandCollector) pushMetric(ch chan<- prometheus.Metric, name string, value uint64, deviceName string, port string, valueType prometheus.ValueType) {
|
||||
ch <- prometheus.MustNewConstMetric(c.metricDescs[name], valueType, float64(value), deviceName, port)
|
||||
func (c *infinibandCollector) pushMetric(ch chan<- prometheus.Metric, name string, value uint64, deviceName string, port string, linkLayer string, valueType prometheus.ValueType) {
|
||||
ch <- prometheus.MustNewConstMetric(c.metricDescs[name], valueType, float64(value), deviceName, port, linkLayer)
|
||||
}
|
||||
|
||||
func (c *infinibandCollector) pushCounter(ch chan<- prometheus.Metric, name string, value *uint64, deviceName string, port string) {
|
||||
func (c *infinibandCollector) pushCounter(ch chan<- prometheus.Metric, name string, value *uint64, deviceName string, port string, linkLayer string) {
|
||||
if value != nil {
|
||||
c.pushMetric(ch, name, *value, deviceName, port, prometheus.CounterValue)
|
||||
c.pushMetric(ch, name, *value, deviceName, port, linkLayer, prometheus.CounterValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,44 +134,40 @@ func (c *infinibandCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
for _, port := range device.Ports {
|
||||
portStr := strconv.FormatUint(uint64(port.Port), 10)
|
||||
|
||||
if port.LinkLayer != "InfiniBand" {
|
||||
continue
|
||||
}
|
||||
c.pushMetric(ch, "state_id", uint64(port.StateID), port.Name, portStr, port.LinkLayer, prometheus.GaugeValue)
|
||||
c.pushMetric(ch, "physical_state_id", uint64(port.PhysStateID), port.Name, portStr, port.LinkLayer, prometheus.GaugeValue)
|
||||
c.pushMetric(ch, "rate_bytes_per_second", port.Rate, port.Name, portStr, port.LinkLayer, prometheus.GaugeValue)
|
||||
|
||||
c.pushMetric(ch, "state_id", uint64(port.StateID), port.Name, portStr, prometheus.GaugeValue)
|
||||
c.pushMetric(ch, "physical_state_id", uint64(port.PhysStateID), port.Name, portStr, prometheus.GaugeValue)
|
||||
c.pushMetric(ch, "rate_bytes_per_second", port.Rate, port.Name, portStr, prometheus.GaugeValue)
|
||||
|
||||
c.pushCounter(ch, "legacy_multicast_packets_received_total", port.Counters.LegacyPortMulticastRcvPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_multicast_packets_transmitted_total", port.Counters.LegacyPortMulticastXmitPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_data_received_bytes_total", port.Counters.LegacyPortRcvData64, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_packets_received_total", port.Counters.LegacyPortRcvPackets64, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_unicast_packets_received_total", port.Counters.LegacyPortUnicastRcvPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_unicast_packets_transmitted_total", port.Counters.LegacyPortUnicastXmitPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_data_transmitted_bytes_total", port.Counters.LegacyPortXmitData64, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_packets_transmitted_total", port.Counters.LegacyPortXmitPackets64, port.Name, portStr)
|
||||
c.pushCounter(ch, "excessive_buffer_overrun_errors_total", port.Counters.ExcessiveBufferOverrunErrors, port.Name, portStr)
|
||||
c.pushCounter(ch, "link_downed_total", port.Counters.LinkDowned, port.Name, portStr)
|
||||
c.pushCounter(ch, "link_error_recovery_total", port.Counters.LinkErrorRecovery, port.Name, portStr)
|
||||
c.pushCounter(ch, "local_link_integrity_errors_total", port.Counters.LocalLinkIntegrityErrors, port.Name, portStr)
|
||||
c.pushCounter(ch, "multicast_packets_received_total", port.Counters.MulticastRcvPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "multicast_packets_transmitted_total", port.Counters.MulticastXmitPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_constraint_errors_received_total", port.Counters.PortRcvConstraintErrors, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_constraint_errors_transmitted_total", port.Counters.PortXmitConstraintErrors, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_data_received_bytes_total", port.Counters.PortRcvData, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_data_transmitted_bytes_total", port.Counters.PortXmitData, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_discards_received_total", port.Counters.PortRcvDiscards, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_discards_transmitted_total", port.Counters.PortXmitDiscards, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_errors_received_total", port.Counters.PortRcvErrors, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_packets_received_total", port.Counters.PortRcvPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_packets_transmitted_total", port.Counters.PortXmitPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_transmit_wait_total", port.Counters.PortXmitWait, port.Name, portStr)
|
||||
c.pushCounter(ch, "unicast_packets_received_total", port.Counters.UnicastRcvPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "unicast_packets_transmitted_total", port.Counters.UnicastXmitPackets, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_receive_remote_physical_errors_total", port.Counters.PortRcvRemotePhysicalErrors, port.Name, portStr)
|
||||
c.pushCounter(ch, "port_receive_switch_relay_errors_total", port.Counters.PortRcvSwitchRelayErrors, port.Name, portStr)
|
||||
c.pushCounter(ch, "symbol_error_total", port.Counters.SymbolError, port.Name, portStr)
|
||||
c.pushCounter(ch, "vl15_dropped_total", port.Counters.VL15Dropped, port.Name, portStr)
|
||||
c.pushCounter(ch, "legacy_multicast_packets_received_total", port.Counters.LegacyPortMulticastRcvPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "legacy_multicast_packets_transmitted_total", port.Counters.LegacyPortMulticastXmitPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "legacy_data_received_bytes_total", port.Counters.LegacyPortRcvData64, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "legacy_packets_received_total", port.Counters.LegacyPortRcvPackets64, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "legacy_unicast_packets_received_total", port.Counters.LegacyPortUnicastRcvPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "legacy_unicast_packets_transmitted_total", port.Counters.LegacyPortUnicastXmitPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "legacy_data_transmitted_bytes_total", port.Counters.LegacyPortXmitData64, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "legacy_packets_transmitted_total", port.Counters.LegacyPortXmitPackets64, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "excessive_buffer_overrun_errors_total", port.Counters.ExcessiveBufferOverrunErrors, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "link_downed_total", port.Counters.LinkDowned, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "link_error_recovery_total", port.Counters.LinkErrorRecovery, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "local_link_integrity_errors_total", port.Counters.LocalLinkIntegrityErrors, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "multicast_packets_received_total", port.Counters.MulticastRcvPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "multicast_packets_transmitted_total", port.Counters.MulticastXmitPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_constraint_errors_received_total", port.Counters.PortRcvConstraintErrors, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_constraint_errors_transmitted_total", port.Counters.PortXmitConstraintErrors, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_data_received_bytes_total", port.Counters.PortRcvData, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_data_transmitted_bytes_total", port.Counters.PortXmitData, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_discards_received_total", port.Counters.PortRcvDiscards, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_discards_transmitted_total", port.Counters.PortXmitDiscards, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_errors_received_total", port.Counters.PortRcvErrors, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_packets_received_total", port.Counters.PortRcvPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_packets_transmitted_total", port.Counters.PortXmitPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_transmit_wait_total", port.Counters.PortXmitWait, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "unicast_packets_received_total", port.Counters.UnicastRcvPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "unicast_packets_transmitted_total", port.Counters.UnicastXmitPackets, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_receive_remote_physical_errors_total", port.Counters.PortRcvRemotePhysicalErrors, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "port_receive_switch_relay_errors_total", port.Counters.PortRcvSwitchRelayErrors, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "symbol_error_total", port.Counters.SymbolError, port.Name, portStr, port.LinkLayer)
|
||||
c.pushCounter(ch, "vl15_dropped_total", port.Counters.VL15Dropped, port.Name, portStr, port.LinkLayer)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue