Skip to content

Commit aaeec30

Browse files
author
Cory G Watson
committed
Use single arg for redis & statsd location
1 parent d2edc92 commit aaeec30

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

redis-statsd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
parser = argparse.ArgumentParser(description='Collect metrics from Redis and emit to StatsD')
99
parser.add_argument('--period', dest='period', type=int, default=20, help='The period at which to collect and emit metrics')
1010
parser.add_argument('--prefix', dest='prefix', type=str, default='redis', help='The prefix to use for metric names')
11-
parser.add_argument('--redis-host', dest='redis_host', type=str, default='localhost', help='The address of the Redis host to connect to')
12-
parser.add_argument('--redis-port', dest='redis_port', type=int, default=6379, help='The port of the Redis host to connect to')
13-
parser.add_argument('--statsd-host', dest='statsd_host', type=str, default='localhost', help='The port of the StatsD host to connect to')
14-
parser.add_argument('--statsd-port', dest='statsd_port', type=int, default=8125, help='The port of the Redis port to connect to')
11+
parser.add_argument('--redis-host', dest='redis_host', type=str, default='localhost:6379', help='The address and port of the Redis host to connect to')
12+
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')
1513
parser.add_argument('--no-tags', dest='tags', action='store_false', help='Disable tags for use with DogStatsD')
1614

1715
args = parser.parse_args()
@@ -72,7 +70,8 @@ def send_metric(name, mtype, value, tags=None):
7270
last_seens[mkey] = value
7371

7472
met = '{}:{}|{}{}'.format(name, finalvalue, mtype, tagstring)
75-
out_sock.sendto(met, (args.statsd_host, args.statsd_port))
73+
(statsd_host, statsd_port) = args.statsd_host.split(':')
74+
out_sock.sendto(met, (statsd_host, int(statsd_port)))
7675

7776
def linesplit(socket):
7877
buffer = socket.recv(4096)
@@ -94,7 +93,8 @@ def linesplit(socket):
9493

9594
while True:
9695
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
97-
s.connect((args.redis_host, args.redis_port))
96+
(redis_host, redis_port) = args.redis_host.split(':')
97+
s.connect((redis_host, int(redis_port)))
9898
s.send("INFO\n")
9999

100100
stats = {}

0 commit comments

Comments
 (0)