Modified default URI for Haproxy stats

This commit is contained in:
Luis I. Perez 2016-05-02 12:58:51 +02:00
parent b93f229ca9
commit 96f97edbd1
1 changed files with 3 additions and 9 deletions

View File

@ -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)