Make redis password config more clear.

Also make certain that the 'host' tag does not include the password for
security reasons

Closes #225
This commit is contained in:
Cameron Sparr 2015-09-23 12:00:23 -07:00
parent 64d38ed17e
commit b12b804f0a
1 changed files with 11 additions and 9 deletions

View File

@ -18,12 +18,15 @@ type Redis struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of URI to gather stats about. Specify an ip or hostname # specify servers via a url matching:
# with optional port add password. ie redis://localhost, redis://10.10.3.33:18832, # [protocol://][:password]@address[:port]
# 10.0.0.1:10000, etc. # e.g.
# tcp://localhost:6379
# tcp://:password@192.168.99.100
# #
# If no servers are specified, then localhost is used as the host. # If no servers are specified, then localhost is used as the host.
servers = ["localhost"] # If no port is specified, 6379 is used
servers = ["tcp://localhost:6379"]
` `
func (r *Redis) SampleConfig() string { func (r *Redis) SampleConfig() string {
@ -142,11 +145,10 @@ func (r *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
rdr := bufio.NewReader(c) rdr := bufio.NewReader(c)
// Setup tags for all redis metrics // Setup tags for all redis metrics
_, rPort, err := net.SplitHostPort(addr.Host) host, port := "unknown", "unknown"
if err != nil { // If there's an error, ignore and use 'unknown' tags
rPort = defaultPort host, port, _ = net.SplitHostPort(addr.Host)
} tags := map[string]string{"host": host, "port": port}
tags := map[string]string{"host": addr.String(), "port": rPort}
return gatherInfoOutput(rdr, acc, tags) return gatherInfoOutput(rdr, acc, tags)
} }