From 527eaed3d4f417547440d3c8466f43bba9d4907f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 23 Feb 2022 22:18:53 +0100 Subject: [PATCH] ansible/stats.py: include vcpu and memory stats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is achieved by extra node metadata added in: - https://github.com/status-im/infra-role-bootstrap-linux/commit/63998e7c - https://github.com/status-im/infra-role-bootstrap-macos/commit/f2dda03c - https://github.com/status-im/infra-role-bootstrap-windows/commit/99df3934 - https://github.com/status-im/infra-hq/commit/898fa9f5 Signed-off-by: Jakub SokoĊ‚owski --- ansible/stats.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ansible/stats.py b/ansible/stats.py index 4779950..95fc780 100755 --- a/ansible/stats.py +++ b/ansible/stats.py @@ -45,14 +45,26 @@ def main(): dc = dcs.setdefault(node['Datacenter'], []) fleet = fleets.setdefault(fleet_name, []) - dc.append(node['Node']) - fleet.append(node['Node']) - env.append(node['Node']) + dc.append(node) + fleet.append(node) + env.append(node) out = { 'total': len(nodes), - 'dcs': {dc: len(hosts) for dc, hosts in dcs.items()}, - 'envs': {env: len(hosts) for env, hosts in envs.items()}, + 'dcs': { + dc: { + "count": len(hosts), + "vcpus": sum(int(h['Meta'].get('hw_vcpu_count', 0)) for h in hosts), + "memory": sum(int(h['Meta'].get('hw_memory_mb', 0)) for h in hosts), + } for dc, hosts in dcs.items() + }, + 'envs': { + env: { + "count": len(hosts), + "vcpus": sum(int(h['Meta'].get('hw_vcpu_count', 0)) for h in hosts), + "memory": sum(int(h['Meta'].get('hw_memory_mb', 0)) for h in hosts), + } for env, hosts in envs.items() + }, #'fleets': {fleet: len(hosts) for fleet, hosts in fleets.items()}, }