Skip to content

Commit

Permalink
Add password functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hahn committed Dec 31, 2018
1 parent 15752f6 commit 715457d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions 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" % password)

s.send("INFO\n")

stats = {}
Expand Down

0 comments on commit 715457d

Please sign in to comment.