From a7d778cb774282ae635e454e5eb6a30364759882 Mon Sep 17 00:00:00 2001 From: Tobias Richter Date: Tue, 25 Aug 2020 21:46:53 +0200 Subject: [PATCH] Add support for passing a password to the redis script --- snmp/redis.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/snmp/redis.py b/snmp/redis.py index 097dda78c..9ad081327 100755 --- a/snmp/redis.py +++ b/snmp/redis.py @@ -2,8 +2,27 @@ import subprocess import json +import sys +import getopt + +auth_param = "" + +try: + opts, args = getopt.getopt(sys.argv[1:],"ha:",["auth="]) +except getopt.GetoptError: + print('redis.py -a AUTH') + sys.exit(2) +for opt, arg in opts: + if opt == '-h': + print('redis.py -a AUTH') + sys.exit() + elif opt in ("-a", "--auth"): + auth_param = "-a %s" % arg shell_cmd = "redis-cli info" +if auth_param: + shell_cmd = "redis-cli %s info" % (auth_param) + all_data = subprocess.Popen(shell_cmd, shell=True, stdout=subprocess.PIPE).stdout.read().split(b'\n') version = 1