Fix parsing of dos line endings in smart input (#3960)

This commit is contained in:
Daniel Nelson 2018-04-02 13:55:10 -07:00 committed by GitHub
parent fe173c18bd
commit 7079c6ee60
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package smart package smart
import ( import (
"bufio"
"fmt" "fmt"
"os/exec" "os/exec"
"path" "path"
@ -202,7 +203,10 @@ func gatherDisk(acc telegraf.Accumulator, usesudo, attributes bool, smartctl, no
device_fields := make(map[string]interface{}) device_fields := make(map[string]interface{})
device_fields["exit_status"] = exitStatus device_fields["exit_status"] = exitStatus
for _, line := range strings.Split(outStr, "\n") { scanner := bufio.NewScanner(strings.NewReader(outStr))
for scanner.Scan() {
line := scanner.Text()
model := modelInInfo.FindStringSubmatch(line) model := modelInInfo.FindStringSubmatch(line)
if len(model) > 1 { if len(model) > 1 {