From 634ce3f9a0455c71dc79d8fa7f4198c297060f39 Mon Sep 17 00:00:00 2001 From: Thomas Hahn Date: Mon, 31 Dec 2018 15:19:19 -0800 Subject: [PATCH 1/3] Fix period. --- redis-statsd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis-statsd.py b/redis-statsd.py index 168cf80..5dcaa12 100755 --- a/redis-statsd.py +++ b/redis-statsd.py @@ -151,5 +151,5 @@ def linesplit(socket): ) out_sock.close() - time.sleep(10) + time.sleep(int(args.period)) From 15752f6baf04cf3c4c3b4ea5627a607419b405bc Mon Sep 17 00:00:00 2001 From: Thomas Hahn Date: Mon, 31 Dec 2018 15:22:11 -0800 Subject: [PATCH 2/3] Document global tags --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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 ``` From 5b7e7c7ffc6b536ab943a1cc38b8c03187306605 Mon Sep 17 00:00:00 2001 From: Thomas Hahn Date: Mon, 31 Dec 2018 15:35:14 -0800 Subject: [PATCH 3/3] Add password functionality --- redis-statsd.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/redis-statsd.py b/redis-statsd.py index 5dcaa12..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 = {}