Select default apache port depending on url scheme

This commit is contained in:
Ruslan Islamgaliev 2015-09-22 20:37:13 +03:00 committed by Cameron Sparr
parent 5657e8d1da
commit 72edc3c4fe
2 changed files with 12 additions and 4 deletions

View File

@ -18,6 +18,7 @@ re-added in a "verbose" mode if there is demand for it.
- [#203](https://github.com/influxdb/telegraf/pull/200): AMQP output. Thanks @ekini! - [#203](https://github.com/influxdb/telegraf/pull/200): AMQP output. Thanks @ekini!
- [#182](https://github.com/influxdb/telegraf/pull/182): OpenTSDB output. Thanks @rplessl! - [#182](https://github.com/influxdb/telegraf/pull/182): OpenTSDB output. Thanks @rplessl!
- [#187](https://github.com/influxdb/telegraf/pull/187): Retry output sink connections on startup. - [#187](https://github.com/influxdb/telegraf/pull/187): Retry output sink connections on startup.
- [#220](https://github.com/influxdb/telegraf/pull/220): Add port tag to apache plugin. Thanks @neezgee!
### Bugfixes ### Bugfixes
- [#170](https://github.com/influxdb/telegraf/issues/170): Systemd support - [#170](https://github.com/influxdb/telegraf/issues/170): Systemd support

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 // Get tag(s) for the apache plugin
func getTags(addr *url.URL) map[string]string { func getTags(addr *url.URL) map[string]string {
h := addr.Host h := addr.Host
if host, port, err := net.SplitHostPort(h); err == nil { host, port, err := net.SplitHostPort(h)
return map[string]string{"server": host, "port": port} if err != nil {
host = addr.Host
if addr.Scheme == "http" {
port = "80"
} else if addr.Scheme == "https" {
port = "443"
} else { } else {
return map[string]string{"server": h, "port": "80"} port = ""
} }
}
return map[string]string{"server": host, "port": port}
} }
func init() { func init() {