diff --git a/arke.py b/arke.py index 59db4e1..b264459 100644 --- a/arke.py +++ b/arke.py @@ -10,7 +10,6 @@ def monitor_AllTargets(monitoringtargets): statuscode = requests.get(target).status_code logger.info(f"target: {target} statuscode: {statuscode}") responseTable[target] = statuscode - # prints the int of the status code. Find more at httpstatusrappers.com :) except requests.ConnectionError: logger.warn(f"target: {target} ERROR: Failure to connect.") @@ -18,12 +17,9 @@ def monitor_AllTargets(monitoringtargets): return responseTable -target_Codes = monitor_AllTargets(arkevars.httpTargets) -currentdate = datetime.datetime.now().isoformat() +datastore = monitor_AllTargets(arkevars.httpTargets) +json_string = json.dumps(datastore) -# export shit as a dict -with open(f'{currentdate}.py','w') as file: - file.write("results = { \n") - for k in sorted (target_Codes.keys()): - file.write("'%s':'%s', \n" % (k, target_Codes[k])) - file.write("}\n") +file = open("results.json", "a+") +file.write(json_string) +file.write("\n") \ No newline at end of file diff --git a/gateway.py b/gateway.py new file mode 100644 index 0000000..cf4758b --- /dev/null +++ b/gateway.py @@ -0,0 +1,20 @@ +import json, datetime, os + +""" +basically read a log file, +if what is being read contains a WARN: + Look at timestamp, target, + if more > 1 consecutive timestamp with the same target: + send to slack + +""" +results = [] +with open("results.json", "r") as json_File: + for line in json_File: + results.append(json.loads(line)) + +for key,value in results[-1].items(): + if value != 200: + errorFile = open("errors.log", "w") + errorText = key + " is down." + "\n" + errorFile.write(errorText) \ No newline at end of file