Skip overs errors in the output of the sensors command (#7718)
This commit is contained in:
parent
8a456266c3
commit
e8461fe27a
|
|
@ -20,6 +20,20 @@ func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error) {
|
|||
return b.Bytes(), err
|
||||
}
|
||||
|
||||
// StdOutputTimeout runs the given command with the given timeout and
|
||||
// returns the output of stdout.
|
||||
// If the command times out, it attempts to kill the process.
|
||||
func StdOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error) {
|
||||
var b bytes.Buffer
|
||||
c.Stdout = &b
|
||||
c.Stderr = nil
|
||||
if err := c.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err := WaitTimeout(c, timeout)
|
||||
return b.Bytes(), err
|
||||
}
|
||||
|
||||
// RunTimeout runs the given command with the given timeout.
|
||||
// If the command times out, it attempts to kill the process.
|
||||
func RunTimeout(c *exec.Cmd, timeout time.Duration) error {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func (s *Sensors) parse(acc telegraf.Accumulator) error {
|
|||
fields := map[string]interface{}{}
|
||||
chip := ""
|
||||
cmd := execCommand(s.path, "-A", "-u")
|
||||
out, err := internal.CombinedOutputTimeout(cmd, s.Timeout.Duration)
|
||||
out, err := internal.StdOutputTimeout(cmd, s.Timeout.Duration)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to run command %s: %s - %s", strings.Join(cmd.Args, " "), err, string(out))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue