Fix accidently empty lines in meminfo_linux (#1671)

* Fix accidently empty lines in meminfo_linux

Signed-off-by: qwertysun <qwertysun@tencent.com>
This commit is contained in:
alpaca 2020-04-17 18:07:35 +08:00 committed by GitHub
parent bd0918f29a
commit fa4edd700e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)