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 109c1a4344
commit 19c102cf4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package smart
import (
"bufio"
"fmt"
"os/exec"
"path"
@ -202,7 +203,10 @@ func gatherDisk(acc telegraf.Accumulator, usesudo, attributes bool, smartctl, no
device_fields := make(map[string]interface{})
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)
if len(model) > 1 {