From 9fcd4bb23e5dfea4483788357d7644cc8e203f53 Mon Sep 17 00:00:00 2001 From: five-iron <33008162+five-iron@users.noreply.github.com> Date: Wed, 7 Aug 2024 18:57:50 -0400 Subject: [PATCH] fix(CPU load): Fix CPU load showing 0% in Runtime -> Metrics -> System --- packages/hawtio/src/plugins/runtime/runtime-service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/hawtio/src/plugins/runtime/runtime-service.ts b/packages/hawtio/src/plugins/runtime/runtime-service.ts index f44bac0f..7f671df1 100644 --- a/packages/hawtio/src/plugins/runtime/runtime-service.ts +++ b/packages/hawtio/src/plugins/runtime/runtime-service.ts @@ -105,7 +105,8 @@ class RuntimeService { } case 'java.lang:type=OperatingSystem': { const osMetrics = response.value as { - SystemCpuLoad: number + CpuLoad?: number + SystemCpuLoad?: number SystemLoadAverage: number FreePhysicalMemorySize: number TotalPhysicalMemorySize: number @@ -113,7 +114,7 @@ class RuntimeService { OpenFileDescriptorCount: number MaxFileDescriptorCount: number } - const cpuLoad = osMetrics.SystemCpuLoad * 100 + const cpuLoad = (osMetrics.CpuLoad ?? osMetrics.SystemCpuLoad ?? 0) * 100 const loadAverage = osMetrics.SystemLoadAverage const memFree = this.formatBytes(osMetrics.FreePhysicalMemorySize) const memTotal = this.formatBytes(osMetrics.TotalPhysicalMemorySize)