diff --git a/README.md b/README.md index aae5f0c..34946ba 100644 --- a/README.md +++ b/README.md @@ -45,5 +45,7 @@ optional arguments: The port of the StatsD host to connect to --statsd-port STATSD_PORT The port of the Redis port to connect to + --global-tags TAG1:VAL1,TAG2:VAL2,... + Global tags to add to all metrics --no-tags Disable tags for use with DogStatsD ``` diff --git a/redis-statsd.py b/redis-statsd.py index 168cf80..2f5f78e 100755 --- a/redis-statsd.py +++ b/redis-statsd.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import argparse +import os import socket import sys import time @@ -12,6 +13,7 @@ parser.add_argument('--statsd-host', dest='statsd_host', type=str, default='localhost:8125', help='The address and port of the StatsD host to connect to') parser.add_argument('--global-tags', dest='global_tags', type=str, help='Global tags to add to all metrics') parser.add_argument('--no-tags', dest='tags', action='store_false', help='Disable tags for use with DogStatsD') +parser.add_argument('--password', dest='password', type=str, default=os.getenv("REDIS_PASSWORD"), help='Password for redis authentication') args = parser.parse_args() @@ -103,6 +105,10 @@ def linesplit(socket): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) (redis_host, redis_port) = args.redis_host.split(':') s.connect((redis_host, int(redis_port))) + + if args.password: + s.send("AUTH %s\n" % args.password) + s.send("INFO\n") stats = {} @@ -151,5 +157,5 @@ def linesplit(socket): ) out_sock.close() - time.sleep(10) + time.sleep(int(args.period))