Skip to content

Commit 8a6aca3

Browse files
authored
Merge pull request #9 from stackhpc/bugfix/storage-volume
Quick and dirty fix for duplicate volume metrics
2 parents b172152 + d56a725 commit 8a6aca3

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:rc-bullseye AS builder
1+
FROM golang:1.24.2 AS builder
22

33
LABEL maintainer="Jennings Liu <[email protected]>"
44

@@ -17,7 +17,7 @@ RUN mkdir -p /go/src/github.com/ && \
1717
cd /go/src/github.com/jenningsloy318/redfish_exporter && \
1818
make build
1919

20-
FROM golang:rc-bullseye
20+
FROM golang:1.24.2
2121

2222
COPY --from=builder /go/src/github.com/jenningsloy318/redfish_exporter/build/redfish_exporter /usr/local/bin/redfish_exporter
2323
RUN mkdir /etc/prometheus

collector/system_collector.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,26 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
242242
} else if storages == nil {
243243
systemLogContext.WithField("operation", "system.Storage()").Info("no storage data found")
244244
} else {
245+
processed := make(map[string]bool)
245246
for _, storage := range storages {
246247
if volumes, err := storage.Volumes(); err != nil {
247248
systemLogContext.WithField("operation", "system.Volumes()").WithError(err).Error("error getting storage data from system")
248249
} else {
249250
wg3.Add(len(volumes))
250251

251252
for _, volume := range volumes {
253+
_, exists := processed[volume.Name]
254+
if exists {
255+
systemLogContext.WithField("operation",
256+
"system.Storage()").Info(fmt.Sprintf("Ignoring "+
257+
"duplicate storage volume: %s. Please check whether this "+
258+
"volume is returning duplicate data and report to the vendor.",
259+
volume.Name))
260+
wg3.Done()
261+
continue
262+
}
252263
go parseVolume(ch, systemHostName, volume, wg3)
264+
processed[volume.Name] = true
253265
}
254266
}
255267

@@ -347,22 +359,22 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) {
347359
} else if simpleStorages == nil {
348360
systemLogContext.WithField("operation", "system.SimpleStorages()").Info("no simple storage data found")
349361
} else {
350-
processed := make(map[string]bool)
362+
processed := make(map[string]bool)
351363
for _, simpleStorage := range simpleStorages {
352364
devices := simpleStorage.Devices
353365
wg8.Add(len(devices))
354366
for _, device := range devices {
355367
_, exists := processed[device.Name]
356368
if exists {
357369
systemLogContext.WithField("operation",
358-
"system.SimpleStorages()").Info(fmt.Sprintf("Ignoring " +
359-
"duplicate storage device: %s. Please check whether this " +
360-
"device is returning duplicate data and report to the vendor.",
361-
device.Name))
370+
"system.SimpleStorages()").Info(fmt.Sprintf("Ignoring "+
371+
"duplicate storage device: %s. Please check whether this "+
372+
"device is returning duplicate data and report to the vendor.",
373+
device.Name))
362374
wg8.Done()
363375
continue
364376
}
365-
go parseDevice(ch, systemHostName, device, wg8)
377+
go parseDevice(ch, systemHostName, device, wg8)
366378
processed[device.Name] = true
367379
}
368380
}

0 commit comments

Comments
 (0)