From 542520d2c01cd66fc2dd1945f740749e85085243 Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Tue, 15 Feb 2022 15:37:25 +0100 Subject: [PATCH] Refactoring: Use array of pointers --- collectors.json | 1 + collectors/infinibandMetric.go | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/collectors.json b/collectors.json index cbfc23d..669355c 100644 --- a/collectors.json +++ b/collectors.json @@ -6,6 +6,7 @@ "test_fs" ] }, + "ibstat": {}, "loadavg": { "exclude_metrics": [ "proc_total" diff --git a/collectors/infinibandMetric.go b/collectors/infinibandMetric.go index e5197de..ac79e0a 100644 --- a/collectors/infinibandMetric.go +++ b/collectors/infinibandMetric.go @@ -31,7 +31,7 @@ type InfinibandCollector struct { config struct { ExcludeDevices []string `json:"exclude_devices,omitempty"` // IB device to exclude e.g. mlx5_0 } - info []InfinibandCollectorInfo + info []*InfinibandCollectorInfo } // Init initializes the Infiniband collector by walking through files below IB_BASEPATH @@ -111,7 +111,7 @@ func (m *InfinibandCollector) Init(config json.RawMessage) error { } m.info = append(m.info, - InfinibandCollectorInfo{ + &InfinibandCollectorInfo{ LID: LID, device: device, port: port, @@ -142,10 +142,7 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMetr } now := time.Now() - for i := range m.info { - - // device info - info := &m.info[i] + for _, info := range m.info { for counterName, counterFile := range info.portCounterFiles { line, err := ioutil.ReadFile(counterFile) if err != nil {