Skip to content

Commit 5831581

Browse files
committed
Merge pull request ganglia#124 from moonranger/redis-support-auth
Make redis-gmond support redis authentication
2 parents c090498 + b488377 commit 5831581

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

redis-gmond/conf.d/redis-gmond.pyconf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ modules {
44
language = "python"
55
param host { value = "127.0.0.1" }
66
param port { value = 6379 }
7+
/* param auth { value = "passwordhere" } */
78
}
89
}
910
collection_group {

redis-gmond/python_modules/redis-gmond.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ def metric_handler(name):
1111
if 15 < time.time() - metric_handler.timestamp:
1212
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1313
s.connect((metric_handler.host, metric_handler.port))
14-
s.send("INFO\r\n")
14+
if metric_handler.auth is not None:
15+
s.send("*2\r\n$4\r\nAUTH\r\n$%d\r\n%s\r\n" % (len(metric_handler.auth), metric_handler.auth));
16+
result = s.recv(100)
17+
if not 'OK' in result:
18+
return 0
19+
s.send("*1\r\n$4\r\nINFO\r\n")
1520
#logging.debug("sent INFO")
1621
info = s.recv(4096)
1722
#logging.debug("rcvd INFO")
@@ -70,6 +75,7 @@ def metric_handler(name):
7075
def metric_init(params={}):
7176
metric_handler.host = params.get("host", "127.0.0.1")
7277
metric_handler.port = int(params.get("port", 6379))
78+
metric_handler.auth = params.get("auth", None)
7379
metric_handler.timestamp = 0
7480
metric_handler.prev_total_commands = 0
7581
metric_handler.prev_total_connections = 0

0 commit comments

Comments
 (0)