From 60a49243cfc171487838c1966aa55cafabf138a1 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Mon, 18 May 2015 11:53:57 -0700 Subject: [PATCH] Gather stats from PG and redis from localhost by default --- plugins/postgresql/postgresql.go | 7 +++++++ plugins/redis/redis.go | 13 +++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/postgresql/postgresql.go b/plugins/postgresql/postgresql.go index 9416dbd61..ec6a9c4d5 100644 --- a/plugins/postgresql/postgresql.go +++ b/plugins/postgresql/postgresql.go @@ -17,7 +17,14 @@ type Postgresql struct { Servers []*Server } +var localhost = &Server{Address: "sslmode=disable"} + func (p *Postgresql) Gather(acc plugins.Accumulator) error { + if len(p.Servers) == 0 { + p.gatherServer(localhost, acc) + return nil + } + for _, serv := range p.Servers { err := p.gatherServer(serv, acc) if err != nil { diff --git a/plugins/redis/redis.go b/plugins/redis/redis.go index 22a9ce0d6..02b782713 100644 --- a/plugins/redis/redis.go +++ b/plugins/redis/redis.go @@ -63,10 +63,6 @@ func (g *Redis) Gather(acc plugins.Accumulator) error { return nil } - var wg sync.WaitGroup - - var outerr error - var servers []string if g.Address != "" { @@ -75,6 +71,15 @@ func (g *Redis) Gather(acc plugins.Accumulator) error { servers = append(servers, g.Servers...) + if len(servers) == 0 { + g.gatherServer(":6379", acc) + return nil + } + + var wg sync.WaitGroup + + var outerr error + for _, serv := range servers { wg.Add(1) go func(serv string) {