From 396d54c693dd4b1b5225371d34af17c224a793f0 Mon Sep 17 00:00:00 2001 From: Louis PERDEREAU Date: Wed, 30 Oct 2024 17:01:15 +0100 Subject: [PATCH] fix(summary): Correct to match PVE Datacenter UI --- src/pvecontrol/actions/cluster.py | 8 ++++---- src/pvecontrol/cluster.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pvecontrol/actions/cluster.py b/src/pvecontrol/actions/cluster.py index 3b5d907..2d07939 100644 --- a/src/pvecontrol/actions/cluster.py +++ b/src/pvecontrol/actions/cluster.py @@ -33,15 +33,15 @@ def action_summary(proxmox, args): ) metrics_memory_output = "{}/{}({:.1f}%), allocated: {}".format( - naturalsize(metrics['memory']['usage'], binary=True), - naturalsize(metrics['memory']['total'], binary=True), + naturalsize(metrics['memory']['usage'], binary=True, format="%.2f"), + naturalsize(metrics['memory']['total'], binary=True, format="%.2f"), metrics['memory']['percent'], naturalsize(metrics['memory']['allocated']), ) metrics_disk_output = "{}/{}({:.1f}%)".format( - naturalsize(metrics['disk']['usage'], binary=True), - naturalsize(metrics['disk']['total'], binary=True), + naturalsize(metrics['disk']['usage'], binary=True, format="%.2f"), + naturalsize(metrics['disk']['total'], binary=True, format="%.2f"), metrics['disk']['percent'] ) diff --git a/src/pvecontrol/cluster.py b/src/pvecontrol/cluster.py index 733795d..5188dbc 100644 --- a/src/pvecontrol/cluster.py +++ b/src/pvecontrol/cluster.py @@ -65,8 +65,8 @@ def is_healthy(self): def get_resources_nodes(self): return [resource for resource in self.resources if resource["type"] == "node"] - def get_resources_nodes(self): - return [resource for resource in self.resources if resource["type"] == "node"] + def get_resources_storages(self): + return [resource for resource in self.resources if resource["type"] == "storage"] def cpu_metrics(self): nodes = self.get_resources_nodes() @@ -97,9 +97,9 @@ def memory_metrics(self): } def disk_metrics(self): - nodes = self.get_resources_nodes() - total_disk = sum([node['maxdisk'] for node in nodes]) - total_disk_usage = sum([node['disk'] for node in nodes]) + storages = self.get_resources_storages() + total_disk = sum([node['maxdisk'] for node in storages]) + total_disk_usage = sum([node['disk'] for node in storages]) disk_percent = total_disk_usage / total_disk *100 return {