From 1292cb3db6ff1ae78e5144457e7dd95cb0f35007 Mon Sep 17 00:00:00 2001 From: Sebastian Luna-Valero Date: Wed, 16 Oct 2024 14:42:57 +0200 Subject: [PATCH] improve quota output info --- fedcloud_vm_monitoring/site_monitor.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fedcloud_vm_monitoring/site_monitor.py b/fedcloud_vm_monitoring/site_monitor.py index d71e433..5bbd18e 100644 --- a/fedcloud_vm_monitoring/site_monitor.py +++ b/fedcloud_vm_monitoring/site_monitor.py @@ -390,13 +390,18 @@ def show_quotas(self): if r["Resource"] in resources: if r["Resource"] == "ram": quota_info["ram (GB)"] = { - "In Use": int(r["In Use"] / 1024), - "Limit": int(r["Limit"] / 1024) - } + "In Use": int(r["In Use"] / 1024), + "Limit": int(r["Limit"] / 1024) + } else: quota_info[r["Resource"]] = {"In Use": r["In Use"], "Limit": r["Limit"]} for k, v in quota_info.items(): - click.echo(f" {k:<14} = {v}") + click.echo(" {:<14} = Limit: {:>3}, Used: {:>3} ({}%)".format( + k, + v["Limit"], + v["In Use"], + round(v["In Use"]/v["Limit"]*100) + )) # checks on quota if quota_info.get("ram (GB)").get("Limit", 1) / quota_info.get("cores").get("Limit", 1) < self.min_ram_cpu_ratio: click.secho(