diff --git a/stackviz/settings.py b/stackviz/settings.py index 7f59438..a32bbf2 100644 --- a/stackviz/settings.py +++ b/stackviz/settings.py @@ -92,6 +92,8 @@ TEST_REPOSITORIES = [ BASE_DIR ] +DSTAT_CSV = 'dstat.log' + # If true, AJAX calls should attempt to load `*.json.gz` files rather than plain # `*.json` files. This should only ever be toggled `True` for static site # exports and is not currently supported on live servers. diff --git a/stackviz/urls.py b/stackviz/urls.py index 84bea0c..6f4fb42 100644 --- a/stackviz/urls.py +++ b/stackviz/urls.py @@ -12,5 +12,6 @@ urlpatterns = patterns('', url(r'^index.html$', IndexView.as_view(), name="index"), url(r'^tempest_', include('stackviz.views.tempest.urls')), url(r'^devstack_', include('stackviz.views.devstack.urls')), - url(r'^upstream_', include ('stackviz.views.upstream.urls')) + url(r'^upstream_', include ('stackviz.views.upstream.urls')), + url(r'^dstat_', include ('stackviz.views.dstat.urls')) ) diff --git a/stackviz/views/dstat/__init__.py b/stackviz/views/dstat/__init__.py new file mode 100644 index 0000000..f87606f --- /dev/null +++ b/stackviz/views/dstat/__init__.py @@ -0,0 +1 @@ +__author__ = 'tim' diff --git a/stackviz/views/dstat/api.py b/stackviz/views/dstat/api.py new file mode 100644 index 0000000..a7a2864 --- /dev/null +++ b/stackviz/views/dstat/api.py @@ -0,0 +1,22 @@ +from django.http import HttpResponse +from django.views.generic import View + +from stackviz import settings + +_cached_csv = None + + +def _load_csv(): + global _cached_csv + + if _cached_csv: + return _cached_csv + + with open(settings.DSTAT_CSV, 'r') as f: + _cached_csv = f.readlines() + return _cached_csv + + +class DStatCSVEndpoint(View): + def get(self, request): + return HttpResponse(_load_csv(), content_type="text/csv") diff --git a/stackviz/views/dstat/urls.py b/stackviz/views/dstat/urls.py new file mode 100644 index 0000000..24aeb72 --- /dev/null +++ b/stackviz/views/dstat/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import patterns, include, url + +from .api import DStatCSVEndpoint + +urlpatterns = patterns('', + url(r'^log.csv$', DStatCSVEndpoint.as_view()), +)