This commit is contained in:
Krzysztof Majewski 2018-08-10 09:31:34 +02:00
parent 83cba874f2
commit 711a352d7f
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package com.baeldung.reactive.util;
import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;
public class CpuUtils {
private static OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
static Double getUsage() {
return (operatingSystemMXBean.getSystemCpuLoad() / operatingSystemMXBean.getAvailableProcessors()) * 100;
}
}