Skip to content

Commit 715457d

Browse files
author
Thomas Hahn
committed
Add password functionality
1 parent 15752f6 commit 715457d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

redis-statsd.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

33
import argparse
4+
import os
45
import socket
56
import sys
67
import time
@@ -12,6 +13,7 @@
1213
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')
1314
parser.add_argument('--global-tags', dest='global_tags', type=str, help='Global tags to add to all metrics')
1415
parser.add_argument('--no-tags', dest='tags', action='store_false', help='Disable tags for use with DogStatsD')
16+
parser.add_argument('--password', dest='password', type=str, default=os.getenv("REDIS_PASSWORD"), help='Password for redis authentication')
1517

1618
args = parser.parse_args()
1719

@@ -103,6 +105,10 @@ def linesplit(socket):
103105
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
104106
(redis_host, redis_port) = args.redis_host.split(':')
105107
s.connect((redis_host, int(redis_port)))
108+
109+
if args.password:
110+
s.send("AUTH %s\n" % password)
111+
106112
s.send("INFO\n")
107113

108114
stats = {}

0 commit comments

Comments
 (0)