Akshay Vala
Akshay Vala

Reputation: 1

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

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?

Upvotes: 0

Views: 121

Answers (0)

Related Questions