1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 19:26:48 +00:00

fix(instances): the new-VM dialog shows each host's current CPU load

The CPU bar showed the average since the host booted, read for every
compute on every load of the VM list. The dialog now reads each compute's
graph endpoint (load over one second) when it opens, two computes at a
time so the reads hold at most two workers, and ignores answers of an
earlier opening. A host that cannot be read shows a dash. The since-boot
reading had no other caller and is removed.
This commit is contained in:
catborise 2026-10-10 16:34:13 +03:00
parent c1d2e9610d
commit a57290cdf2
11 changed files with 170 additions and 24 deletions

View file

@ -49,17 +49,14 @@ class wvmHostDetails(wvmConnect):
stats = self.wvm.getCPUStats(VIR_NODE_CPU_STATS_ALL_CPUS, 0)
return stats["idle"], sum(stats.get(name, 0) for name in CPU_TIMES)
def get_cpu_usage(self, diff=True, previous=None):
def get_cpu_usage(self, previous=None):
"""
Busy share of all host CPUs in percent. diff=False: since the host
started. Otherwise since previous, an (idle, total, time) sample this
method returned, or over one second when there is none or it does not
lead to this one (the host restarted). Also returns the closing sample
and the seconds the usage covers.
Busy share of all host CPUs in percent since previous, an (idle, total,
time) sample this method returned, or over one second when there is
none or it does not lead to this one (the host restarted). Also returns
the closing sample and the seconds the usage covers.
"""
times = self._cpu_times()
if not diff:
return {"usage": cpu_percent((0, 0), times)}
now = time.time()
usage = None
if previous is not None: