Browse Source

Merge branch 'master' of https://gitee.com/y_project/RuoYi

pull/51/MERGE^2
RuoYi 6 years ago
parent
commit
6a4b1898b1
  1. 4
      ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java
  2. 5
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java

4
ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java

@ -86,6 +86,10 @@ public class Arith
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b1.compareTo(BigDecimal.ZERO) == 0)
{
return BigDecimal.ZERO.doubleValue();
}
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}

5
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java

@ -28,6 +28,9 @@ import oshi.util.Util;
*/
public class Server
{
private static final int OSHI_WAIT_SECOND = 1000;
/**
* CPU相关信息
*/
@ -126,7 +129,7 @@ public class Server
{
// CPU信息
long[] prevTicks = processor.getSystemCpuLoadTicks();
Util.sleep(500);
Util.sleep(OSHI_WAIT_SECOND);
long[] ticks = processor.getSystemCpuLoadTicks();
long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()];
long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()];

Loading…
Cancel
Save