From 3c612ad536b02baedca53d2dab9aee9e539949c5 Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Tue, 4 Mar 2025 15:43:31 +0000 Subject: [PATCH 1/3] Fix duplicate storage devices --- collector/system_collector.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/collector/system_collector.go b/collector/system_collector.go index 9ed8a4f..134573c 100755 --- a/collector/system_collector.go +++ b/collector/system_collector.go @@ -350,8 +350,18 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) { for _, simpleStorage := range simpleStorages { devices := simpleStorage.Devices wg8.Add(len(devices)) + processed := make(map[string]bool) for _, device := range devices { - go parseDevice(ch, systemHostName, device, wg8) + _, exists := processed[device.Name] + if exists { + systemLogContext.WithField("operation", "system.SimpleStorages()").Info(fmt.Sprintf("Ignoring duplicate storage device: %s", device.Name)) + wg8.Done() + continue + } else { + go parseDevice(ch, systemHostName, device, wg8) + } + + processed[device.Name] = true } } } From cfc13a90aee39259209a6ba26219e2dd46dba516 Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Tue, 4 Mar 2025 15:56:51 +0000 Subject: [PATCH 2/3] ... --- collector/system_collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/system_collector.go b/collector/system_collector.go index 134573c..12d0da7 100755 --- a/collector/system_collector.go +++ b/collector/system_collector.go @@ -347,10 +347,10 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) { } else if simpleStorages == nil { systemLogContext.WithField("operation", "system.SimpleStorages()").Info("no simple storage data found") } else { + processed := make(map[string]bool) for _, simpleStorage := range simpleStorages { devices := simpleStorage.Devices wg8.Add(len(devices)) - processed := make(map[string]bool) for _, device := range devices { _, exists := processed[device.Name] if exists { From cd3650fe44c6e1028cac7f65800c22de9fa6dc29 Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Mon, 17 Mar 2025 09:57:49 +0000 Subject: [PATCH 3/3] Address comments from code review --- collector/system_collector.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/collector/system_collector.go b/collector/system_collector.go index 12d0da7..9da3c70 100755 --- a/collector/system_collector.go +++ b/collector/system_collector.go @@ -354,13 +354,15 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) { for _, device := range devices { _, exists := processed[device.Name] if exists { - systemLogContext.WithField("operation", "system.SimpleStorages()").Info(fmt.Sprintf("Ignoring duplicate storage device: %s", device.Name)) + systemLogContext.WithField("operation", + "system.SimpleStorages()").Info(fmt.Sprintf("Ignoring " + + "duplicate storage device: %s. Please check whether this " + + "device is returning duplicate data and report to the vendor.", + device.Name)) wg8.Done() continue - } else { - go parseDevice(ch, systemHostName, device, wg8) } - + go parseDevice(ch, systemHostName, device, wg8) processed[device.Name] = true } }