diff --git a/main.py b/main.py index 309c0a0..38575ab 100644 --- a/main.py +++ b/main.py @@ -3,25 +3,33 @@ from nut2 import PyNUTClient import os -# hostList = os.environ["hosts"] -# hostList = hostList.split(",") - +# try: +# hostList = os.environ["hosts"] +# hostList = hostList.replace(" ","").split(",") +# except: +# print("error with hosts entry, please make sure in format -> 10.x.x.1, 10.x.x.2") # host hostList = ['10.0.5.2', '10.0.5.181'] -test = [] +upslist = {} -## pull all the UPSes froom each host +## pull all the UPSes froom each host into a nice dict for host in hostList: - input(host) + upslist[host] = [] client = PyNUTClient(host, '3493') for UPS in client.list_ups(): - test.append(str(UPS)) + upslist[host].append(UPS) -print(test) +print(upslist) -# client = PyNUTClient('10.0.5.2', '3493') +for host in upslist: + client = PyNUTClient(host, '3493') + for UPS in upslist[host]: + print() + print("{} Battery Percent: {}%".format(UPS, client.list_vars(UPS)['battery.charge'])) -# print(client.list_ups()) +# client = PyNUTClient('10.0.5.181', '3493') + +# # print(client.list_ups()) # print(client.list_vars("Net-UPS1")) \ No newline at end of file