From e4b3f0eec112fe0d3f97d5fd6947d29b1130fc90 Mon Sep 17 00:00:00 2001 From: zhuyong Date: Tue, 9 Oct 2018 14:41:06 +0800 Subject: [PATCH] fix #1641, support get system load on windows. --- .../dubbo/common/status/support/LoadStatusChecker.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java index 20715c5d71b..0ed290f5746 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java @@ -37,6 +37,11 @@ public Status check() { try { Method method = OperatingSystemMXBean.class.getMethod("getSystemLoadAverage", new Class[0]); load = (Double) method.invoke(operatingSystemMXBean, new Object[0]); + if (load == -1) { + com.sun.management.OperatingSystemMXBean bean = + (com.sun.management.OperatingSystemMXBean) operatingSystemMXBean; + load = bean.getSystemCpuLoad(); + } } catch (Throwable e) { load = -1; }