Fix accidently empty lines in meminfo_linux (#1671)

* Fix accidently empty lines in meminfo_linux

Signed-off-by: qwertysun <qwertysun@tencent.com>
pull/1678/head
alpaca 5 years ago committed by GitHub
parent bd0918f29a
commit fa4edd700e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -45,6 +45,10 @@ func parseMemInfo(r io.Reader) (map[string]float64, error) {
for scanner.Scan() {
line := scanner.Text()
parts := strings.Fields(line)
// Workaround for empty lines occasionally occur in CentOS 6.2 kernel 3.10.90.
if len(parts) == 0 {
continue
}
fv, err := strconv.ParseFloat(parts[1], 64)
if err != nil {
return nil, fmt.Errorf("invalid value in meminfo: %s", err)

Loading…
Cancel
Save