Use the DefaultURL parameter if no url is explicitly set by the user

closes #1278
closes #1277
This commit is contained in:
Martin Seener
2016-05-26 11:25:21 +02:00
committed by Cameron Sparr
parent 6828fc48e1
commit 42d7fc5e16
3 changed files with 6 additions and 2 deletions

View File

@@ -102,7 +102,7 @@ type gatherFunc func(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error)
var gatherFunctions = []gatherFunc{gatherOverview, gatherNodes, gatherQueues}
var sampleConfig = `
url = "http://localhost:15672" # required
# url = "http://localhost:15672"
# name = "rmq-server-1" # optional tag
# username = "guest"
# password = "guest"
@@ -146,6 +146,9 @@ func (r *RabbitMQ) Gather(acc telegraf.Accumulator) error {
}
func (r *RabbitMQ) requestJSON(u string, target interface{}) error {
if r.URL == "" {
r.URL = DefaultURL
}
u = fmt.Sprintf("%s%s", r.URL, u)
req, err := http.NewRequest("GET", u, nil)