import json
import os
import logging
import sys
from pyssdb import pyssdb

def parameter_check(argv):

    parameters = {"ConfigFile": ""}
    idx, argc = 0, len(argv)

    while idx < argc:
        if (sys.argv[idx] == "-f") and (idx < argc - 1):
            idx = idx + 1
            parameters["ConfigFile"] = sys.argv[idx]
        idx = idx + 1

    if (parameters["ConfigFile"] == ""):
        print("Usage:")
        print("    python ssdbtest.py -f <config_file_name>")
        exit(0)
    else:
        return parameters

def load_config(filename):

    fd = open(filename)
    data = fd.read()
    fd.close()

    return data

if __name__ == '__main__':

    parameters = parameter_check(sys.argv)

    logging.basicConfig(level=logging.DEBUG, format="%(asctime)s-%(thread)06d-%(levelname)s: %(message)s", datefmt="%Y%m%d-%H%M%S")

    confData = load_config(parameters["ConfigFile"])
    agentConf = json.loads(confData)
    ssdbHost = agentConf["SSDB"]["Host"]
    ssdbPort = agentConf["SSDB"]["Port"]
    ssdbPasscode = agentConf["SSDB"]["Passcode"]

    confSSDB = pyssdb.Client(host = ssdbHost, port = ssdbPort)

    confSSDB.auth(ssdbPasscode)

    names = confSSDB.hlist("", "", 100)

    for name in names:
        logging.info(name.decode("utf-8"))

    logging.info("------------------------------")

    statusSize = confSSDB.hsize("DNS-Agent-Sync")
    statusHashes = confSSDB.hkeys("DNS-Agent-Sync", "", "", statusSize)

    for agent in statusHashes:
        status = confSSDB.hget("DNS-Agent-Sync", agent)
        if status == b"Sync":
            logging.info("%s is good", agent.decode("utf-8"))
        else:
            logging.info("%s is in trouble!!", agent.decode("utf-8"))

    confSSDB.disconnect()
@@ -72,25 +72,28 @@
 db%0A%0Adef 
-p
+GetP
 arameter
 _check(a
@@ -84,22 +84,17 @@
 arameter
-_check
+s
 (argv):%0A
@@ -525,22 +525,21 @@
 rs%0A%0Adef 
-load_c
+LoadC
 onfig(fi
@@ -671,25 +671,28 @@
 eters = 
-p
+GetP
 arameter
 _check(s
@@ -687,14 +687,9 @@
 eter
-_check
+s
 (sys
@@ -848,14 +848,13 @@
 a = 
-load_c
+LoadC
 onfi
@@ -922,17 +922,39 @@
 ta)%0A
+%0A
     
-ssdbH
+confSSDB = pyssdb.Client(h
 ost 
@@ -980,26 +980,19 @@
 %5B%22Host%22%5D
-%0A    ssdbP
+, p
 ort = ag
@@ -1018,28 +1018,29 @@
 rt%22%5D
+)%0A
 %0A    
-ssdbPasscode = 
+confSSDB.auth(
 agen
@@ -1068,104 +1068,8 @@
 de%22%5D
-%0A%0A    confSSDB = pyssdb.Client(host = ssdbHost, port = ssdbPort)%0A%0A    confSSDB.auth(ssdbPasscode
 )%0A%0A 
@@ -1639,8 +1639,9 @@
 onnect()
+%0A

change names