Fix parsing of dos line endings in smart input (#3960)
This commit is contained in:
parent
109c1a4344
commit
19c102cf4b
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue