Adding support for Default Haproxy Stats Page

Related to https://github.com/influxdata/telegraf/issues/1019
This commit is contained in:
chewieip 2016-04-13 16:40:31 +02:00
parent e428d11add
commit 717fe0aa20
1 changed files with 8 additions and 2 deletions

View File

@ -141,8 +141,14 @@ func (g *haproxy) gatherServer(addr string, acc telegraf.Accumulator) error {
if err != nil { if err != nil {
return fmt.Errorf("Unable parse server address '%s': %s", addr, err) return fmt.Errorf("Unable parse server address '%s': %s", addr, err)
} }
var uri string
req, err := http.NewRequest("GET", fmt.Sprintf("%s://%s%s/;csv", u.Scheme, u.Host, u.Path), nil) //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)
if u.User != nil { if u.User != nil {
p, _ := u.User.Password() p, _ := u.User.Password()
req.SetBasicAuth(u.User.Username(), p) req.SetBasicAuth(u.User.Username(), p)