Skip to content

Commit

Permalink
fix(summary): Correct to match PVE Datacenter UI
Browse files Browse the repository at this point in the history
  • Loading branch information
lperdereau committed Oct 30, 2024
1 parent 9f04c2d commit 396d54c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/pvecontrol/actions/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
)

Expand Down
10 changes: 5 additions & 5 deletions src/pvecontrol/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 396d54c

Please sign in to comment.