Fix timeout parsing error in nvidia_smi (#4070)

This commit is contained in:
Jack Zampolin 2018-04-24 14:40:19 -07:00 committed by Daniel Nelson
parent 7f1e4c847f
commit 2c4d6a867f
1 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ var (
// NvidiaSMI holds the methods for this plugin // NvidiaSMI holds the methods for this plugin
type NvidiaSMI struct { type NvidiaSMI struct {
BinPath string BinPath string
Timeout time.Duration Timeout internal.Duration
metrics string metrics string
} }
@ -81,7 +81,7 @@ func init() {
inputs.Add("nvidia_smi", func() telegraf.Input { inputs.Add("nvidia_smi", func() telegraf.Input {
return &NvidiaSMI{ return &NvidiaSMI{
BinPath: "/usr/bin/nvidia-smi", BinPath: "/usr/bin/nvidia-smi",
Timeout: 5 * time.Second, Timeout: internal.Duration{Duration: 5 * time.Second},
metrics: metrics, metrics: metrics,
} }
}) })
@ -90,7 +90,7 @@ func init() {
func (smi *NvidiaSMI) pollSMI() (string, error) { func (smi *NvidiaSMI) pollSMI() (string, error) {
// Construct and execute metrics query // Construct and execute metrics query
opts := []string{"--format=noheader,nounits,csv", fmt.Sprintf("--query-gpu=%s", smi.metrics)} opts := []string{"--format=noheader,nounits,csv", fmt.Sprintf("--query-gpu=%s", smi.metrics)}
ret, err := internal.CombinedOutputTimeout(exec.Command(smi.BinPath, opts...), smi.Timeout) ret, err := internal.CombinedOutputTimeout(exec.Command(smi.BinPath, opts...), smi.Timeout.Duration)
if err != nil { if err != nil {
return "", err return "", err
} }