Skip to content

Commit

Permalink
Fix accidently empty lines in meminfo_linux (#1671)
Browse files Browse the repository at this point in the history
* Fix accidently empty lines in meminfo_linux

Signed-off-by: qwertysun <qwertysun@tencent.com>
  • Loading branch information
alpaca2333 authored Apr 17, 2020
1 parent bd0918f commit fa4edd7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions collector/meminfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fa4edd7

Please sign in to comment.