summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/pharos-dashboard/dashboard/urls.py2
-rw-r--r--tools/pharos-dashboard/dashboard/views.py23
-rw-r--r--tools/pharos-dashboard/templates/dashboard/resource_utilization.html86
3 files changed, 111 insertions, 0 deletions
diff --git a/tools/pharos-dashboard/dashboard/urls.py b/tools/pharos-dashboard/dashboard/urls.py
index cf6340f6..2223e39c 100644
--- a/tools/pharos-dashboard/dashboard/urls.py
+++ b/tools/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/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
diff --git a/tools/pharos-dashboard/templates/dashboard/resource_utilization.html b/tools/pharos-dashboard/templates/dashboard/resource_utilization.html
new file mode 100644
index 00000000..fb483d60
--- /dev/null
+++ b/tools/pharos-dashboard/templates/dashboard/resource_utilization.html
@@ -0,0 +1,86 @@
+{% extends "base.html" %}
+{% load staticfiles %}
+
+{% block extrahead %}
+ <!-- Morris Charts CSS -->
+ <link href="{% static "bower_components/morrisjs/morris.css" %}" rel="stylesheet">
+
+{% endblock extrahead %}
+
+
+{% block content %}
+ <div class="row">
+ {% for resource, utilization in pods %}
+ <div class="col-lg-3">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ {{ resource.name }}
+ </div>
+ <div class="panel-body">
+ <div class="flot-chart">
+ <div class="flot-chart-content" id="{{ resource.slave.name }}"></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ {% endfor %}
+ </div>
+
+{% endblock content %}
+
+
+{% block extrajs %}
+
+ <!-- Flot Charts JavaScript -->
+ <script src="{% static "bower_components/flot/excanvas.min.js" %}"></script>
+ <script src="{% static "bower_components/flot/jquery.flot.js" %}"></script>
+ <script src="{% static "bower_components/flot/jquery.flot.pie.js" %}"></script>
+ <script src="{% static "bower_components/flot/jquery.flot.resize.js" %}"></script>
+ <script src="{% static "bower_components/flot/jquery.flot.time.js" %}"></script>
+ <script src="{% static "bower_components/flot.tooltip/js/jquery.flot.tooltip.min.js" %}"></script>
+
+ <script type="text/javascript">
+ $(document).ready(function () {
+ {% for resource, utilization in pods %}
+ $(function () {
+ var data = [{
+ label: "Offline",
+ data: {{ utilization.offline }},
+ color: '#d9534f'
+ }, {
+ label: "Online",
+ data: {{ utilization.online }},
+ color: '#5cb85c'
+ }, {
+ label: "Idle",
+ data: {{ utilization.idle }},
+ color: '#5bc0de'
+ }];
+
+ var plotObj = $.plot($("#{{ resource.slave.name }}"), data, {
+ series: {
+ pie: {
+ show: true
+ }
+ },
+ grid: {
+ hoverable: true
+ },
+ tooltip: true,
+ tooltipOpts: {
+ content: "%p.0%, %s", // show percentages, rounding to 2 decimal places
+ shifts: {
+ x: 20,
+ y: 0
+ },
+ defaultTheme: false
+ }
+ });
+
+ });
+ {% endfor %}
+
+ });
+ </script>
+
+{% endblock extrajs %} \ No newline at end of file