diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-19 17:14:11 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-19 17:14:11 +0200 |
commit | 217e6dd3c193b5f576ade7581775993c8ed82294 (patch) | |
tree | 5a8af7492b5759eee9578e6079886f6ffc69ccd6 /pharos-dashboard/dashboard | |
parent | a1da09ca6e089913a6aacd5f55051a7f19d6f1fc (diff) |
Add a resource utilization page
JIRA: RELENG-12
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'pharos-dashboard/dashboard')
-rw-r--r-- | pharos-dashboard/dashboard/urls.py | 2 | ||||
-rw-r--r-- | pharos-dashboard/dashboard/views.py | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/pharos-dashboard/dashboard/urls.py b/pharos-dashboard/dashboard/urls.py index cf6340f..2223e39 100644 --- a/pharos-dashboard/dashboard/urls.py +++ b/pharos-dashboard/dashboard/urls.py @@ -21,6 +21,8 @@ urlpatterns = [ url(r'^ci_pods/$', CIPodsView.as_view(), name='ci_pods'), url(r'^dev_pods/$', DevelopmentPodsView.as_view(), name='dev_pods'), url(r'^jenkins_slaves/$', JenkinsSlavesView.as_view(), name='jenkins_slaves'), + url(r'^resource/all/utilization$', ResourceUtilizationView.as_view(), + name='resource_utilization'), url(r'^$', DevelopmentPodsView.as_view(), name="index"), ] diff --git a/pharos-dashboard/dashboard/views.py b/pharos-dashboard/dashboard/views.py index a4c0c4e..da31802 100644 --- a/pharos-dashboard/dashboard/views.py +++ b/pharos-dashboard/dashboard/views.py @@ -48,3 +48,26 @@ class DevelopmentPodsView(TemplateView): context = super(DevelopmentPodsView, self).get_context_data(**kwargs) context.update({'title': "Development Pods", 'dev_pods': dev_pods}) return context + + +class ResourceUtilizationView(TemplateView): + template_name = "dashboard/resource_utilization.html" + + def get_context_data(self, **kwargs): + resources = Resource.objects.all() + pods = [] + for resource in resources: + utilization = {'idle': 0, 'online': 0, 'offline': 0} + # query measurement points for the last week + statistics = JenkinsStatistic.objects.filter(slave=resource.slave, + timestamp__gte=timezone.now() - timedelta( + days=7)) + statistics_cnt = statistics.count() + if statistics_cnt != 0: + utilization['idle'] = statistics.filter(idle=True).count() + utilization['online'] = statistics.filter(online=True).count() + utilization['offline'] = statistics.filter(offline=True).count() + pods.append((resource, utilization)) + context = super(ResourceUtilizationView, self).get_context_data(**kwargs) + context.update({'title': "Development Pods", 'pods': pods}) + return context |