blob: 3aabc4a0b730d5b21e2883ef9f6fc0e156235c77 [file] [log] [blame]
from django.http import HttpResponse
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))