mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2026-02-21 18:27:29 +01:00
Fix: Close file /proc/cpuinfo only once
This commit is contained in:
@@ -86,10 +86,6 @@ func (m *CPUFreqCpuInfoCollector) Init(_ json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := file.Close(); err != nil {
|
|
||||||
return fmt.Errorf("%s Init(): Call to file.Close() failed: %w", m.name, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// were all topology information collected?
|
// were all topology information collected?
|
||||||
if foundFreq &&
|
if foundFreq &&
|
||||||
len(processor) > 0 &&
|
len(processor) > 0 &&
|
||||||
@@ -121,6 +117,10 @@ func (m *CPUFreqCpuInfoCollector) Init(_ json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := file.Close(); err != nil {
|
||||||
|
return fmt.Errorf("%s Init(): Call to file.Close() failed: %w", m.name, err)
|
||||||
|
}
|
||||||
|
|
||||||
// Check if at least one CPU with frequency information was detected
|
// Check if at least one CPU with frequency information was detected
|
||||||
if len(m.topology) == 0 {
|
if len(m.topology) == 0 {
|
||||||
return fmt.Errorf("%s Init(): no CPU frequency info found in %s", m.name, cpuInfoFile)
|
return fmt.Errorf("%s Init(): no CPU frequency info found in %s", m.name, cpuInfoFile)
|
||||||
|
|||||||
Reference in New Issue
Block a user