From 54322038f766be460b676d60974886be5f04d8f3 Mon Sep 17 00:00:00 2001 From: maxbr Date: Fri, 19 Aug 2016 17:14:11 +0200 Subject: Add a resource utilization page JIRA: RELENG-12 Signed-off-by: maxbr --- tools/pharos-dashboard/dashboard/views.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tools/pharos-dashboard/dashboard/views.py') diff --git a/tools/pharos-dashboard/dashboard/views.py b/tools/pharos-dashboard/dashboard/views.py index a4c0c4e9..da31802f 100644 --- a/tools/pharos-dashboard/dashboard/views.py +++ b/tools/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 -- cgit 1.2.3-korg