Modified default URI for Haproxy stats
This commit is contained in:
parent
b93f229ca9
commit
96f97edbd1
|
@ -107,7 +107,7 @@ func (r *haproxy) Description() string {
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// Returns one of the errors encountered while gather stats (if any).
|
||||||
func (g *haproxy) Gather(acc telegraf.Accumulator) error {
|
func (g *haproxy) Gather(acc telegraf.Accumulator) error {
|
||||||
if len(g.Servers) == 0 {
|
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
|
var wg sync.WaitGroup
|
||||||
|
@ -141,14 +141,8 @@ 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
|
|
||||||
//Checking for default Haproxy Status page
|
//Checking for default Haproxy Status page
|
||||||
if u.RawQuery == "" {
|
req, err := http.NewRequest("GET", fmt.Sprintf("%s://%s%s?%s", u.Scheme, u.Host, u.Path, u.RawQuery), nil)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue