Skip to content

Commit 369a997

Browse files
committed
Merge pull request cloudartisan#1 from josephholsten/master
Add configurable password
2 parents 54af9a6 + 47f01f6 commit 369a997

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Redis.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import commands
66

77

8-
REDIS_INFO_CMD = "redis-cli info"
9-
10-
118
class Redis:
129
def __init__(self, agent_config, checks_logger, raw_config):
1310
self.agent_config = agent_config
@@ -16,7 +13,7 @@ def __init__(self, agent_config, checks_logger, raw_config):
1613

1714
def run(self):
1815
stats = {}
19-
status, out = commands.getstatusoutput(REDIS_INFO_CMD)
16+
status, out = commands.getstatusoutput(self.redis_info_cmd())
2017
if status != 0:
2118
return stats
2219
# Grab every statistic available and leave it to the end user to
@@ -25,6 +22,13 @@ def run(self):
2522
stats[key] = val
2623
return stats
2724

25+
def redis_info_cmd(self):
26+
if self.raw_config.get('Redis') and self.raw_config['Redis'].get('password'):
27+
self.checks_logger.debug('Found Redis password in config')
28+
return "redis_cli -a %s info" % self.raw_config['Redis']['password']
29+
else:
30+
return "redis_cli info"
31+
2832

2933
if __name__ == '__main__':
3034
redis = Redis(None, None, None)

0 commit comments

Comments
 (0)