From 91a9c8fc9f36101ece75efcbd6d4dde4518d6e73 Mon Sep 17 00:00:00 2001 From: qwertysun Date: Fri, 10 Apr 2020 10:09:49 +0800 Subject: [PATCH 1/2] Fix accidently empty lines in meminfo_linux Signed-off-by: qwertysun asd --- collector/meminfo_linux.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/collector/meminfo_linux.go b/collector/meminfo_linux.go index 9aac018d94..5c967c1cf4 100644 --- a/collector/meminfo_linux.go +++ b/collector/meminfo_linux.go @@ -45,6 +45,9 @@ func parseMemInfo(r io.Reader) (map[string]float64, error) { for scanner.Scan() { line := scanner.Text() parts := strings.Fields(line) + 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) From 925cda72f87d9c5baec94047bbcb4725d059846f Mon Sep 17 00:00:00 2001 From: qwertysun Date: Fri, 17 Apr 2020 17:53:08 +0800 Subject: [PATCH 2/2] add comment to notice this workaround Signed-off-by: qwertysun 123 --- collector/meminfo_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/collector/meminfo_linux.go b/collector/meminfo_linux.go index 5c967c1cf4..c5de4329b3 100644 --- a/collector/meminfo_linux.go +++ b/collector/meminfo_linux.go @@ -45,6 +45,7 @@ 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 }