Fix format for cpustat collector

This commit is contained in:
Thomas Roehl 2021-05-12 17:45:41 +02:00
parent e35a9f6b86
commit e8b2bbdae1

View File

@ -51,13 +51,13 @@ func (m *CpustatCollector) Read(interval time.Duration) {
ll := strings.Split(string(buffer), "\n")
for _, line := range ll {
if (len(line) == 0) {
if len(line) == 0 {
continue
}
ls := strings.Fields(line)
if (strings.Compare(ls[0], "cpu") == 0) {
if strings.Compare(ls[0], "cpu") == 0 {
ParseStatLine(line, m.node)
} else if (strings.HasPrefix(ls[0], "cpu")) {
} else if strings.HasPrefix(ls[0], "cpu") {
cpustr := strings.TrimLeft(ls[0], "cpu")
cpu, _ := strconv.Atoi(cpustr)
ParseStatLine(line, m.cpus[cpu])