How to get cpu usage in java other than using OperatingSystemMXBean?

63 Views Asked by At
double getCPUUsage() {
        OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
        return osBean.getProcessCpuLoad();
}

Cpu usage from above method is not giving as accurate cpu usage as kubernetes metrics.

This is same as spring boot metric system_cpu_usage as it also uses the same OperatingSystemMXBean in its implementation.

Other methods to get cpu usage in java?

0

There are 0 best solutions below