From fa4edd700ebc1b3614bcd953c215d3f2ab2e0b35 Mon Sep 17 00:00:00 2001 From: alpaca <2419335621@qq.com> Date: Fri, 17 Apr 2020 18:07:35 +0800 Subject: [PATCH] Fix accidently empty lines in meminfo_linux (#1671) * Fix accidently empty lines in meminfo_linux Signed-off-by: qwertysun --- collector/meminfo_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/collector/meminfo_linux.go b/collector/meminfo_linux.go index 9aac018d..c5de4329 100644 --- a/collector/meminfo_linux.go +++ b/collector/meminfo_linux.go @@ -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)