Django view that exports Observer status
diff --git a/planetstack/core/views/observer.py b/planetstack/core/views/observer.py
new file mode 100644
index 0000000..67b2fde
--- /dev/null
+++ b/planetstack/core/views/observer.py
@@ -0,0 +1,19 @@
+from django.http import HttpResponse
+from monitor import driver
+from core.models import *
+import json
+import time
+
+def Observer(request):
+ 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))
diff --git a/planetstack/planetstack/urls.py b/planetstack/planetstack/urls.py
index 30ad665..7e780fb 100644
--- a/planetstack/planetstack/urls.py
+++ b/planetstack/planetstack/urls.py
@@ -26,8 +26,9 @@
# Examples:
# url(r'^$', 'planetstack.views.home', name='home'),
# url(r'^planetstack/', include('planetstack.foo.urls')),
-
url(r'^stats', 'core.views.stats.Stats', name='stats'),
+ url(r'^observer', 'core.views.observer.Observer', name='observer'),
+
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),