mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-12 16:44:18 -08:00
Address review comments
Signed-off-by: Xiaodong Ye <yeahdongcn@gmail.com>
This commit is contained in:
parent
e009bf5f48
commit
e35eb3ccfe
|
@ -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)
|
||||
}
|
||||
|
|
4
go.mod
4
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
|
||||
|
|
7
go.sum
7
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=
|
||||
|
|
Loading…
Reference in a new issue