Refactoring: Use array of pointers

This commit is contained in:
Holger Obermaier 2022-02-15 15:37:25 +01:00
parent d6154ff35b
commit 542520d2c0
2 changed files with 4 additions and 6 deletions

View File

@ -6,6 +6,7 @@
"test_fs" "test_fs"
] ]
}, },
"ibstat": {},
"loadavg": { "loadavg": {
"exclude_metrics": [ "exclude_metrics": [
"proc_total" "proc_total"

View File

@ -31,7 +31,7 @@ type InfinibandCollector struct {
config struct { config struct {
ExcludeDevices []string `json:"exclude_devices,omitempty"` // IB device to exclude e.g. mlx5_0 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 // 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, m.info = append(m.info,
InfinibandCollectorInfo{ &InfinibandCollectorInfo{
LID: LID, LID: LID,
device: device, device: device,
port: port, port: port,
@ -142,10 +142,7 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMetr
} }
now := time.Now() now := time.Now()
for i := range m.info { for _, info := range m.info {
// device info
info := &m.info[i]
for counterName, counterFile := range info.portCounterFiles { for counterName, counterFile := range info.portCounterFiles {
line, err := ioutil.ReadFile(counterFile) line, err := ioutil.ReadFile(counterFile)
if err != nil { if err != nil {