diff --git a/collector/rdma_linux.go b/collector/rdma_linux.go index ac7bb05214..ee16c89662 100644 --- a/collector/rdma_linux.go +++ b/collector/rdma_linux.go @@ -117,6 +117,25 @@ func makeRdmaCollector(logger *slog.Logger) (*rdmaCollector, error) { logger.Info("Parsed flag --collector.rdma.metrics-include", "flag", *rdmaIncludedMetrics) } + // Update paths to respect the mount points setup. + for _, dir := range []*string{ + &rdmamap.RdmaClassDir, + &rdmamap.RdmaIbUcmDir, + &rdmamap.RdmaUmadDir, + &rdmamap.RdmaUverbsDir, + &rdmamap.PciDevDir, + &rdmamap.AuxDevDir, + } { + *dir = strings.TrimPrefix(*dir, "/sys") + *dir = sysFilePath(*dir) + } + for _, dir := range []*string{ + &rdmamap.RdmaUcmDevice, + &rdmamap.RdmaDeviceDir, + } { + *dir = rootfsFilePath(*dir) + } + entries := make(map[string]*prometheus.Desc, len(rdmaHwCounters)+len(rdmaCounters)) for metric, help := range rdmaHwCounters { entries[metric] = prometheus.NewDesc( @@ -224,8 +243,8 @@ func (c *rdmaCollector) Update(ch chan<- prometheus.Metric) error { vendorID := readStringFromFile(filepath.Join(rdmamap.RdmaClassDir, device, "device", "vendor")) deviceID := readStringFromFile(filepath.Join(rdmamap.RdmaClassDir, device, "device", "device")) - firmwareVersion := readStringFromFile("/sys/class/infiniband/mlx5_0/fw_ver") - driverVersion := readStringFromFile("/sys/module/mlx5_core/version") + firmwareVersion := readStringFromFile(filepath.Join(rdmamap.RdmaClassDir, "mlx5_0", "fw_ver")) + driverVersion := readStringFromFile(sysFilePath("module/mlx5_core/version")) ch <- prometheus.MustNewConstMetric(c.infoDesc, prometheus.GaugeValue, 1.0, device, vendorID, deviceID, firmwareVersion, driverVersion) } diff --git a/go.mod b/go.mod index 8e2a404e04..beba9d7ff8 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/siebenmann/go-kstat v0.0.0-20210513183136-173c9b0a9973 // indirect github.com/vishvananda/netlink v1.1.0 // indirect - github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect + github.com/vishvananda/netns v0.0.4 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect @@ -62,3 +62,5 @@ require ( google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) + +replace github.com/Mellanox/rdmamap => github.com/yeahdongcn/rdmamap v0.0.0-20241110052645-2f11ac5dce50 diff --git a/go.sum b/go.sum index f11073a936..7285e89af0 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/Mellanox/rdmamap v1.1.0 h1:A/W1wAXw+6vm58f3VklrIylgV+eDJlPVIMaIKuxgUT4= -github.com/Mellanox/rdmamap v1.1.0/go.mod h1:fN+/V9lf10ABnDCwTaXRjeeWijLt2iVLETnK+sx/LY8= github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY= github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= @@ -100,10 +98,13 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= -github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= +github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= +github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= +github.com/yeahdongcn/rdmamap v0.0.0-20241110052645-2f11ac5dce50 h1:S5Kx7HYonzAhND9Pb7ZekrdQ/E1uc7m6ZdmVjy8pD3o= +github.com/yeahdongcn/rdmamap v0.0.0-20241110052645-2f11ac5dce50/go.mod h1:D3ffy5KqtmeWfuW0cX/GQW0J6S3k8aORk4bf9CBOhng= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=