mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
fix(computes): a host's CPU chart counts I/O wait as idle, and its memory in GiB
The CPU in use was the share of time not idle, with I/O wait counted as busy: a host that only waited for its disks showed 100% CPU in use. Time waiting for I/O is idle now: no CPU runs then. The memory chart divided by 1024³ and labelled the values GB; it says GiB now.
This commit is contained in:
parent
1f6cc15ddf
commit
81d183f802
4 changed files with 15 additions and 5 deletions
|
|
@ -65,9 +65,10 @@ class wvmHostDetails(wvmConnect):
|
|||
return {"total": None, "usage": None, "percent": None}
|
||||
|
||||
def _cpu_times(self):
|
||||
"""(idle, total) nanoseconds of all host CPUs, from one reading."""
|
||||
"""(idle, total) nanoseconds of all host CPUs, from one reading. Time
|
||||
waiting for I/O is idle: no CPU runs then, it only waits for disks."""
|
||||
stats = self.wvm.getCPUStats(VIR_NODE_CPU_STATS_ALL_CPUS, 0)
|
||||
return stats["idle"], sum(stats.get(name, 0) for name in CPU_TIMES)
|
||||
return stats["idle"] + stats.get("iowait", 0), sum(stats.get(name, 0) for name in CPU_TIMES)
|
||||
|
||||
def get_cpu_usage(self, previous=None):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -337,6 +337,14 @@ class CpuUsageTestCase(UnitTestCase):
|
|||
# total = kernel + user + idle + iowait; guest (inside user) and utilization are left out
|
||||
self.assertEqual(usage, {"usage": 70.0, "sample": (130, 200, 105.0), "window": 5.0})
|
||||
|
||||
def test_time_waiting_for_disks_is_not_cpu_in_use(self, clock):
|
||||
# a host that only waits for its disks: no CPU runs
|
||||
clock.monotonic.return_value = 105.0
|
||||
h = wvmHostDetails.__new__(wvmHostDetails)
|
||||
h.wvm = MagicMock()
|
||||
h.wvm.getCPUStats.return_value = {"kernel": 0, "user": 0, "idle": 100, "iowait": 100}
|
||||
self.assertEqual(h.get_cpu_usage(previous=(100, 100, 100.0))["usage"], 0.0)
|
||||
|
||||
def test_over_one_second_without_a_sample(self, clock):
|
||||
clock.monotonic.side_effect = [10.0, 11.0]
|
||||
h = host((100, 100), (110, 190))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue