From 96f97edbd114b701e1cb0ab90ad4ce547baf4652 Mon Sep 17 00:00:00 2001 From: "Luis I. Perez" Date: Mon, 2 May 2016 12:58:51 +0200 Subject: [PATCH] Modified default URI for Haproxy stats --- plugins/inputs/haproxy/haproxy.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/plugins/inputs/haproxy/haproxy.go b/plugins/inputs/haproxy/haproxy.go index fb028c26d..942453ab4 100644 --- a/plugins/inputs/haproxy/haproxy.go +++ b/plugins/inputs/haproxy/haproxy.go @@ -107,7 +107,7 @@ func (r *haproxy) Description() string { // Returns one of the errors encountered while gather stats (if any). func (g *haproxy) Gather(acc telegraf.Accumulator) error { if len(g.Servers) == 0 { - return g.gatherServer("http://127.0.0.1:1936", acc) + return g.gatherServer("http://127.0.0.1:1936/;csv", acc) } var wg sync.WaitGroup @@ -140,15 +140,9 @@ func (g *haproxy) gatherServer(addr string, acc telegraf.Accumulator) error { u, err := url.Parse(addr) if err != nil { return fmt.Errorf("Unable parse server address '%s': %s", addr, err) - } - var uri string + } //Checking for default Haproxy Status page - if u.RawQuery == "" { - uri = fmt.Sprintf("%s://%s%s;csv", u.Scheme, u.Host, u.Path) - } else { - uri = fmt.Sprintf("%s://%s%s?%s;csv", u.Scheme, u.Host, u.Path, u.RawQuery) - } - req, err := http.NewRequest("GET", uri, nil) + req, err := http.NewRequest("GET", fmt.Sprintf("%s://%s%s?%s", u.Scheme, u.Host, u.Path, u.RawQuery), nil) if u.User != nil { p, _ := u.User.Password() req.SetBasicAuth(u.User.Username(), p)