diff options
Diffstat (limited to 'metrics')
-rw-r--r-- | metrics/disk_linux.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/metrics/disk_linux.go b/metrics/disk_linux.go index d0eac08b9..8d610cd67 100644 --- a/metrics/disk_linux.go +++ b/metrics/disk_linux.go @@ -47,15 +47,16 @@ func ReadDiskStats(stats *DiskStats) error { } return err } - key, value := "", int64(0) - if parts := strings.Split(line, ":"); len(parts) != 2 { + parts := strings.Split(line, ":") + if len(parts) != 2 { continue - } else { - key = strings.TrimSpace(parts[0]) - if value, err = strconv.ParseInt(strings.TrimSpace(parts[1]), 10, 64); err != nil { - return err - } } + key := strings.TrimSpace(parts[0]) + value, err := strconv.ParseInt(strings.TrimSpace(parts[1]), 10, 64) + if err != nil { + return err + } + // Update the counter based on the key switch key { case "syscr": |