Commit 97b61460 authored by Daniele Venzano's avatar Daniele Venzano 🏇

Add platform load to the status page

parent bb7e46f0
...@@ -23,6 +23,18 @@ from zoe_lib.config import get_conf ...@@ -23,6 +23,18 @@ from zoe_lib.config import get_conf
class StatusEndpointWeb(ZoeWebRequestHandler): class StatusEndpointWeb(ZoeWebRequestHandler):
"""Handler class""" """Handler class"""
def _calculate_load(self, sched):
core_total = sched['platform_stats']['cores_total']
memory_total = sched['platform_stats']['memory_total']
core_reserved = 0
memory_reserved = 0
for node in sched['platform_stats']['nodes']:
core_reserved += node['cores_reserved']
memory_reserved += node['memory_reserved']
core_usage = core_reserved / core_total
memory_usage = memory_reserved / memory_total
return core_usage, memory_usage
def get(self): def get(self):
"""Status and statistics page.""" """Status and statistics page."""
if self.current_user is None or not self.current_user.role.can_see_status: if self.current_user is None or not self.current_user.role.can_see_status:
...@@ -57,7 +69,8 @@ class StatusEndpointWeb(ZoeWebRequestHandler): ...@@ -57,7 +69,8 @@ class StatusEndpointWeb(ZoeWebRequestHandler):
"executions_in_queue": executions_in_queue, "executions_in_queue": executions_in_queue,
"services_per_node": services_per_node, "services_per_node": services_per_node,
"max_service_count": max_service_count, "max_service_count": max_service_count,
'eurecom': get_conf().eurecom 'eurecom': get_conf().eurecom,
'platform_load': self._calculate_load()
} }
self.render('status.jinja2', **template_vars) self.render('status.jinja2', **template_vars)
...@@ -146,6 +146,7 @@ ...@@ -146,6 +146,7 @@
<h3 class="section"><a name="platform">Platform</a></h3> <h3 class="section"><a name="platform">Platform</a></h3>
<ul> <ul>
<li>Current load: cores {{ '%.2f' % platform_load[0] }}, memory {{ '%.2f' % platform_load[1] }}</li>
<li>Total containers: {{ stats.platform_stats.container_count }}</li> <li>Total containers: {{ stats.platform_stats.container_count }}</li>
<li>Memory: <script>format_bytes({{ stats.platform_stats.memory_total }}, 2)</script> total, <script>format_bytes({{ stats.platform_stats.memory_reserved }}, 2)</script> reserved, <script>format_bytes({{ stats.platform_stats.memory_in_use }}, 2)</script> in use</li> <li>Memory: <script>format_bytes({{ stats.platform_stats.memory_total }}, 2)</script> total, <script>format_bytes({{ stats.platform_stats.memory_reserved }}, 2)</script> reserved, <script>format_bytes({{ stats.platform_stats.memory_in_use }}, 2)</script> in use</li>
<li>Cores: {{ '%.2f' % stats.platform_stats.cores_total }} total, {{ '%.2f' % stats.platform_stats.cores_reserved }} reserved, {{ '%.2f' % stats.platform_stats.cores_in_use }} in use</li> <li>Cores: {{ '%.2f' % stats.platform_stats.cores_total }} total, {{ '%.2f' % stats.platform_stats.cores_reserved }} reserved, {{ '%.2f' % stats.platform_stats.cores_in_use }} in use</li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment