Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for passing a password to the redis script #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions snmp/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down