Move to alert_file var; fix json parsing error from last commit.

master
jowj 4 years ago
parent 71a2df01f8
commit 97b222491a

@ -14,8 +14,9 @@ logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%Y/%m/%d %I:%M:%S
logger = logging.getLogger("arke")
last_round_file = "/shared/state.log"
last_round_file = "/shared/state.json"
this_round_file = "/shared/results.json"
alert_file = "/shared/alerts.log"
def monitor_HttpTargets(monitoringtargets):
@ -75,7 +76,7 @@ while is_on:
today = datetime.today()
datastore = {}
# make sure http targets are /up/
datastore['http'] = monitor_HttpTargets(arkevars.httpTargets)
@ -110,16 +111,13 @@ while is_on:
# queue up an alert if stateChanged = True
results = []
with open(this_round_file, "r+", encoding="utf-8") as json_File:
pdb.set_trace()
json_data = json.load(json_File)
for item in json_data:
results.append(item)
for item in results:
for key, value in item.items():
if stateChanged is True:
errorFile = open("/shared/alerts.log", "a+")
errorText = key + " returned with status " + str(value) + "\n"
errorFile.write(errorText)
for key, value in json_data.items():
for key, value in value.items():
if stateChanged is True:
errorFile = open(alert_file, "a+")
errorText = str(key) + " " + str(value) + "\n"
errorFile.write(errorText)
# Copy current results to state.log file for next iteration
with open(last_round_file, "a+") as json_File:

Loading…
Cancel
Save