From 5fe8903fd2c229260e140af99d91255531b4f5ef Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Mon, 4 Apr 2016 11:59:28 +0200 Subject: [PATCH] Use timeout smaller than 10 seconds closes #959 --- plugins/inputs/mongodb/mongodb.go | 2 +- plugins/inputs/mongodb/mongodb_test.go | 2 +- plugins/inputs/prometheus/prometheus.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/inputs/mongodb/mongodb.go b/plugins/inputs/mongodb/mongodb.go index 3be04477b..381814531 100644 --- a/plugins/inputs/mongodb/mongodb.go +++ b/plugins/inputs/mongodb/mongodb.go @@ -103,7 +103,7 @@ func (m *MongoDB) gatherServer(server *Server, acc telegraf.Accumulator) error { dialAddrs[0], err.Error()) } dialInfo.Direct = true - dialInfo.Timeout = time.Duration(10) * time.Second + dialInfo.Timeout = 5 * time.Second if m.Ssl.Enabled { tlsConfig := &tls.Config{} diff --git a/plugins/inputs/mongodb/mongodb_test.go b/plugins/inputs/mongodb/mongodb_test.go index 174128d19..73e68ed37 100644 --- a/plugins/inputs/mongodb/mongodb_test.go +++ b/plugins/inputs/mongodb/mongodb_test.go @@ -43,7 +43,7 @@ func testSetup(m *testing.M) { log.Fatalf("Unable to parse URL (%s), %s\n", dialAddrs[0], err.Error()) } dialInfo.Direct = true - dialInfo.Timeout = time.Duration(10) * time.Second + dialInfo.Timeout = 5 * time.Second sess, err := mgo.DialWithInfo(dialInfo) if err != nil { log.Fatalf("Unable to connect to MongoDB, %s\n", err.Error()) diff --git a/plugins/inputs/prometheus/prometheus.go b/plugins/inputs/prometheus/prometheus.go index 460a79faf..1c60a363e 100644 --- a/plugins/inputs/prometheus/prometheus.go +++ b/plugins/inputs/prometheus/prometheus.go @@ -80,10 +80,10 @@ func (p *Prometheus) gatherURL(url string, acc telegraf.Accumulator) error { var rt http.RoundTripper = &http.Transport{ Dial: (&net.Dialer{ - Timeout: 10 * time.Second, + Timeout: 5 * time.Second, KeepAlive: 30 * time.Second, }).Dial, - TLSHandshakeTimeout: 10 * time.Second, + TLSHandshakeTimeout: 5 * time.Second, TLSClientConfig: &tls.Config{ InsecureSkipVerify: p.InsecureSkipVerify, },