Set default timeout of 5s in fibaro input (#5813)

This commit is contained in:
Daniel Nelson 2019-05-07 14:15:30 -07:00 committed by GitHub
parent 23b9875462
commit 61c2cc97a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions

View File

@ -5,12 +5,15 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"strconv" "strconv"
"time"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
const defaultTimeout = 5 * time.Second
const sampleConfig = ` const sampleConfig = `
## Required Fibaro controller address/hostname. ## Required Fibaro controller address/hostname.
## Note: at the time of writing this plugin, Fibaro only implemented http - no https available ## 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 // Fibaro contains connection information
type Fibaro struct { type Fibaro struct {
URL string URL string `toml:"url"`
// HTTP Basic Auth Credentials // HTTP Basic Auth Credentials
Username string Username string `toml:"username"`
Password string Password string `toml:"password"`
Timeout internal.Duration Timeout internal.Duration `toml:"timeout"`
client *http.Client client *http.Client
} }
@ -212,6 +215,8 @@ func (f *Fibaro) Gather(acc telegraf.Accumulator) error {
func init() { func init() {
inputs.Add("fibaro", func() telegraf.Input { inputs.Add("fibaro", func() telegraf.Input {
return &Fibaro{} return &Fibaro{
Timeout: internal.Duration{Duration: defaultTimeout},
}
}) })
} }