| Sapan Bhatia | 8e6f53d | 2015-01-29 21:05:39 +0000 | [diff] [blame^] | 1 | from django.http import HttpResponse |
| 2 | from monitor import driver | ||||
| 3 | from core.models import * | ||||
| 4 | import json | ||||
| 5 | import time | ||||
| 6 | |||||
| 7 | def Observer(request): | ||||
| 8 | t = time.time() | ||||
| 9 | status_str = open('/tmp/observer_last_run','r').read() | ||||
| 10 | d = json.loads(status_str) | ||||
| 11 | comp = d['last_run'] + d['last_duration']*2 + 300 | ||||
| 12 | if comp>t: | ||||
| 13 | d['health'] = ':-)' | ||||
| 14 | else: | ||||
| 15 | d['health'] = ':-X' | ||||
| 16 | d['time'] = t | ||||
| 17 | d['comp'] = comp | ||||
| 18 | |||||
| 19 | return HttpResponse(json.dumps(d)) | ||||