Skip to content

Commit

Permalink
Fix accidently empty lines in meminfo_linux (prometheus#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 and oblitorum committed Apr 9, 2024
1 parent 898f3c7 commit 826cf0a
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 826cf0a

Please sign in to comment.