Commit 713258e5 authored by Daniele Venzano's avatar Daniele Venzano

Expose service statistics on the web interface

parent f4b6d508
......@@ -240,7 +240,7 @@
<tr>
<td class="cell-host">{{ node.name }}</td>
{% for service in node.services %}
<td><a href="{{ reverse_url('execution_inspect', service['execution_id']) }}">{{ service['name'] }}</a> (M: <script>format_bytes({{ service['description']['resources']['memory']['max'] }});</script> C: {{ service['description']['resources']['cores']['max'] }})</td>
<td><a href="{{ reverse_url('execution_inspect', service['execution_id']) }}">{{ service['name'] }}</a> (M: <script>format_bytes({{ node.service_stats[service['id']|string]['mem_limit'] }});</script> C: {{ node.service_stats[service['id']|string]['core_limit'] }})</td>
{% endfor %}
</tr>
{% endfor %}
......
......@@ -149,6 +149,7 @@ class DockerEngineBackend(zoe_master.backends.base.BaseBackend):
stats[cont['id']] = {}
stats[cont['id']]['core_limit'] = cont['cpu_quota'] / cont['cpu_period']
stats[cont['id']]['mem_limit'] = cont['memory_soft_limit']
node_stats.service_stats = stats
if get_usage_stats:
if get_conf().kairosdb_enable:
......
......@@ -190,6 +190,12 @@ def get_platform_state(state: SQLManager, with_usage_stats=False) -> ClusterStat
platform_state = backend.platform_state(with_usage_stats)
for node in platform_state.nodes: # type: NodeStats
node.services = state.service_list(backend_host=node.name, backend_status=Service.BACKEND_START_STATUS)
for k, v in node.service_stats.items():
for service in node.services:
if service.backend_id == k:
node.service_stats[service.id] = v
del node.service_stats[k]
break
return platform_state
......
......@@ -64,6 +64,7 @@ class NodeStats(Stats):
self.status = None
self.error = ''
self.services = []
self.service_stats = {}
def serialize(self):
"""Convert the object into a dict."""
......@@ -79,7 +80,8 @@ class NodeStats(Stats):
'labels': list(self.labels),
'status': self.status,
'error': self.error,
'services': []
'services': [],
'service_stats': self.service_stats
}
for service in self.services:
ret['services'].append(service.serialize())
......
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