Merge pull request #207 from sparrc/diskstats-panic-fix

Fix potential panic in linux disk IO counters
This commit is contained in:
shirou 2016-06-03 22:00:04 +09:00
commit 586bb697f3
1 changed files with 4 additions and 0 deletions

View File

@ -283,6 +283,10 @@ func IOCounters() (map[string]IOCountersStat, error) {
for _, line := range lines {
fields := strings.Fields(line)
if len(fields) < 14 {
// malformed line in /proc/diskstats, avoid panic by ignoring.
continue
}
name := fields[2]
reads, err := strconv.ParseUint((fields[3]), 10, 64)
if err != nil {