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"
]
},
"ibstat": {},
"loadavg": {
"exclude_metrics": [
"proc_total"

View File

@ -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 {