|
|
|
@ -14,9 +14,9 @@ logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%Y/%m/%d %I:%M:%S
|
|
|
|
|
logger = logging.getLogger("arke")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
last_round_file_path = "/Users/jledbetter/shared/state.json"
|
|
|
|
|
this_round_file_path = "/Users/jledbetter/shared/results.json"
|
|
|
|
|
alert_file_path = "/Users/jledbetter/shared/alerts.log"
|
|
|
|
|
last_round_file_path = "/shared/state.json"
|
|
|
|
|
this_round_file_path = "/shared/results.json"
|
|
|
|
|
alert_file_path = "/shared/alerts.log"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def monitor_HttpTargets(monitoringtargets):
|
|
|
|
@ -100,14 +100,11 @@ while is_on:
|
|
|
|
|
oldData = old_file.read()
|
|
|
|
|
newData = open(this_round_file_path, "r").read()
|
|
|
|
|
|
|
|
|
|
# pdb.set_trace()
|
|
|
|
|
if oldData != newData:
|
|
|
|
|
stateChanged = True
|
|
|
|
|
else:
|
|
|
|
|
stateChanged = False
|
|
|
|
|
|
|
|
|
|
pdb.set_trace()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
# delete state.json so I can write to it cleanly
|
|
|
|
|
os.remove(last_round_file_path)
|
|
|
|
@ -115,13 +112,13 @@ while is_on:
|
|
|
|
|
# queue up an alert if stateChanged = True
|
|
|
|
|
results = []
|
|
|
|
|
with open(this_round_file_path, "r+", encoding="utf-8") as json_File:
|
|
|
|
|
json_data = json.load(json_File)
|
|
|
|
|
for key, value in json_data.items():
|
|
|
|
|
for key, value in value.items():
|
|
|
|
|
if stateChanged is True:
|
|
|
|
|
errorFile = open(alert_file_path, "a+")
|
|
|
|
|
errorText = str(key) + " " + str(value) + "\n"
|
|
|
|
|
errorFile.write(errorText)
|
|
|
|
|
if stateChanged is True:
|
|
|
|
|
json_data = json.load(json_File)
|
|
|
|
|
for inner_key, inner_value in json_data.items():
|
|
|
|
|
for key, value in inner_value.items():
|
|
|
|
|
with open(alert_file_path, "a") as error_file:
|
|
|
|
|
error_text = str(key) + " " + str(value) + "\n"
|
|
|
|
|
error_file.write(error_text)
|
|
|
|
|
|
|
|
|
|
# Copy current results to state.log file for next iteration
|
|
|
|
|
with open(last_round_file_path, "a+") as json_File:
|
|
|
|
|