blob: 2912db9174f5b3c8ea1d1dd215509dd2ee4170ea [file] [log] [blame]
from django.http import HttpResponse
from monitor import driver
from core.models import *
import json
import os
import time
def Observer(request):
if not os.path.exists('/tmp/observer_last_run'):
return HttpResponse(json.dumps({"health": ":-X", "time": time.time(), "comp": 0}))
t = time.time()
status_str = open('/tmp/observer_last_run','r').read()
d = json.loads(status_str)
comp = d['last_run'] + d['last_duration']*2 + 300
if comp>t:
d['health'] = ':-)'
else:
d['health'] = ':-X'
d['time'] = t
d['comp'] = comp
return HttpResponse(json.dumps(d))