From 2075d715abb017ffaa903932834b572b566c3ca8 Mon Sep 17 00:00:00 2001 From: josiah Date: Tue, 28 Jan 2020 04:43:45 +0000 Subject: [PATCH] Move to single datastore dict, instead of list; add pdb. --- arke.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/arke.py b/arke.py index 0fbc5a1..f2ce39f 100644 --- a/arke.py +++ b/arke.py @@ -8,6 +8,7 @@ import whois import OpenSSL import ssl import time +import pdb logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%Y/%m/%d %I:%M:%S %p',level=logging.INFO,filename='arke.log') logger = logging.getLogger("arke") @@ -73,25 +74,20 @@ is_on = True while is_on: today = datetime.today() - + datastore = {} + # make sure http targets are /up/ - datastore = monitor_HttpTargets(arkevars.httpTargets) - json_string = json.dumps(datastore) + datastore['http'] = monitor_HttpTargets(arkevars.httpTargets) # get SSL certs on http targets - cert_info = monitor_TlsExpiry(arkevars.tlsTargets) - cert_json = json.dumps(cert_info) + datastore['certs'] = monitor_TlsExpiry(arkevars.tlsTargets) # get whois info on domain targets - domain_info = monitor_DomainExpiry(arkevars.domains_to_check) - domain_json = json.dumps(domain_info) + datastore['whois'] = monitor_DomainExpiry(arkevars.domains_to_check) # write new results to file - file = open(this_round_file, "a+") - file.write(json_string) - file.write(cert_json) - file.write(domain_json) - file.close() + with open(this_round_file, "a+", encoding="utf-8") as outfile: + json.dump(datastore, outfile, ensure_ascii=False, sort_keys=True) # track state file = open(this_round_file, "r")