Set default timeout of 5s in fibaro input (#5813)
This commit is contained in:
parent
23b9875462
commit
61c2cc97a2
|
@ -5,12 +5,15 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
)
|
||||
|
||||
const defaultTimeout = 5 * time.Second
|
||||
|
||||
const sampleConfig = `
|
||||
## Required Fibaro controller address/hostname.
|
||||
## Note: at the time of writing this plugin, Fibaro only implemented http - no https available
|
||||
|
@ -28,13 +31,13 @@ const description = "Read devices value(s) from a Fibaro controller"
|
|||
|
||||
// Fibaro contains connection information
|
||||
type Fibaro struct {
|
||||
URL string
|
||||
URL string `toml:"url"`
|
||||
|
||||
// HTTP Basic Auth Credentials
|
||||
Username string
|
||||
Password string
|
||||
Username string `toml:"username"`
|
||||
Password string `toml:"password"`
|
||||
|
||||
Timeout internal.Duration
|
||||
Timeout internal.Duration `toml:"timeout"`
|
||||
|
||||
client *http.Client
|
||||
}
|
||||
|
@ -212,6 +215,8 @@ func (f *Fibaro) Gather(acc telegraf.Accumulator) error {
|
|||
|
||||
func init() {
|
||||
inputs.Add("fibaro", func() telegraf.Input {
|
||||
return &Fibaro{}
|
||||
return &Fibaro{
|
||||
Timeout: internal.Duration{Duration: defaultTimeout},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue