Select default apache port depending on url scheme

This commit is contained in:
Ruslan Islamgaliev 2015-09-22 20:37:13 +03:00
parent 05804230b4
commit e1eb25abb0
1 changed files with 11 additions and 4 deletions

View File

@ -134,11 +134,18 @@ func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[str
// Get tag(s) for the apache plugin
func getTags(addr *url.URL) map[string]string {
h := addr.Host
if host, port, err := net.SplitHostPort(h); err == nil {
return map[string]string{"server": host, "port": port}
host, port, err := net.SplitHostPort(h)
if err != nil {
host = addr.Host
if addr.Scheme == "http" {
port = "80"
} else if addr.Scheme == "https" {
port = "443"
} else {
return map[string]string{"server": h, "port": "80"}
port = ""
}
}
return map[string]string{"server": host, "port": port}
}
func init() {