From b12b804f0a6faa2056418de7ab8233e4032bf15b Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Wed, 23 Sep 2015 12:00:23 -0700 Subject: [PATCH] Make redis password config more clear. Also make certain that the 'host' tag does not include the password for security reasons Closes #225 --- plugins/redis/redis.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/redis/redis.go b/plugins/redis/redis.go index 8270c2d6a..a04729af3 100644 --- a/plugins/redis/redis.go +++ b/plugins/redis/redis.go @@ -18,12 +18,15 @@ type Redis struct { } var sampleConfig = ` - # An array of URI to gather stats about. Specify an ip or hostname - # with optional port add password. ie redis://localhost, redis://10.10.3.33:18832, - # 10.0.0.1:10000, etc. + # specify servers via a url matching: + # [protocol://][:password]@address[:port] + # e.g. + # tcp://localhost:6379 + # tcp://:password@192.168.99.100 # # 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 { @@ -142,11 +145,10 @@ func (r *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error { rdr := bufio.NewReader(c) // Setup tags for all redis metrics - _, rPort, err := net.SplitHostPort(addr.Host) - if err != nil { - rPort = defaultPort - } - tags := map[string]string{"host": addr.String(), "port": rPort} + host, port := "unknown", "unknown" + // If there's an error, ignore and use 'unknown' tags + host, port, _ = net.SplitHostPort(addr.Host) + tags := map[string]string{"host": host, "port": port} return gatherInfoOutput(rdr, acc, tags) }