Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
8 changes: 7 additions & 1 deletion redis-statsd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import argparse
import os
import socket
import sys
import time
Expand All @@ -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()

Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -151,5 +157,5 @@ def linesplit(socket):
)

out_sock.close()
time.sleep(10)
time.sleep(int(args.period))