1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,62 @@
//go:build linux
package infiniband
import (
"errors"
"strconv"
"github.com/Mellanox/rdmamap"
"github.com/influxdata/telegraf"
)
// Gather statistics from our infiniband cards
func (ib *Infiniband) Gather(acc telegraf.Accumulator) error {
rdmaDevices := rdmamap.GetRdmaDeviceList()
if len(rdmaDevices) == 0 {
return errors.New("no InfiniBand devices found in /sys/class/infiniband/")
}
for _, dev := range rdmaDevices {
devicePorts := rdmamap.GetPorts(dev)
for _, port := range devicePorts {
portInt, err := strconv.Atoi(port)
if err != nil {
return err
}
stats, err := rdmamap.GetRdmaSysfsStats(dev, portInt)
if err != nil {
continue
}
addStats(dev, port, stats, acc)
if ib.RDMA {
stats, err := rdmamap.GetRdmaSysfsHwStats(dev, portInt)
if err != nil {
continue
}
addStats(dev, port, stats, acc)
}
}
}
return nil
}
// Add the statistics to the accumulator
func addStats(dev, port string, stats []rdmamap.RdmaStatEntry, acc telegraf.Accumulator) {
// Allow users to filter by card and port
tags := map[string]string{"device": dev, "port": port}
fields := make(map[string]interface{})
for _, entry := range stats {
fields[entry.Name] = entry.Value
}
acc.AddFields("infiniband", fields, tags)
}