|
|
|
@ -1,8 +1,14 @@
|
|
|
|
|
import requests, arkevars, json, logging, datetime, os, time
|
|
|
|
|
import requests
|
|
|
|
|
import arkevars
|
|
|
|
|
import json
|
|
|
|
|
import logging
|
|
|
|
|
import os
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def monitor_AllTargets(monitoringtargets):
|
|
|
|
|
responseTable = {}
|
|
|
|
|
for target in monitoringtargets:
|
|
|
|
@ -17,7 +23,9 @@ def monitor_AllTargets(monitoringtargets):
|
|
|
|
|
|
|
|
|
|
return responseTable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_on = True
|
|
|
|
|
|
|
|
|
|
while is_on:
|
|
|
|
|
datastore = monitor_AllTargets(arkevars.httpTargets)
|
|
|
|
|
json_string = json.dumps(datastore)
|
|
|
|
@ -48,7 +56,7 @@ while is_on:
|
|
|
|
|
results.append(json.loads(line))
|
|
|
|
|
for item in results:
|
|
|
|
|
for key, value in item.items():
|
|
|
|
|
if stateChanged == True:
|
|
|
|
|
if stateChanged is True:
|
|
|
|
|
errorFile = open("/shared/alerts.log", "a+")
|
|
|
|
|
errorText = key + " returned with status " + str(value) + "\n"
|
|
|
|
|
errorFile.write(errorText)
|
|
|
|
@ -61,4 +69,3 @@ while is_on:
|
|
|
|
|
errorFile.close()
|
|
|
|
|
os.remove("/shared/results.json")
|
|
|
|
|
time.sleep(60)
|
|
|
|
|
|
|
|
|
|