mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
add system usage
This commit is contained in:
parent
2b28ec4ed5
commit
2e691411b9
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.langpy</groupId>
|
||||
<artifactId>ko-time</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
<name>KoTime</name>
|
||||
<description>A springboot tool for tracking the paths of the methods,which can help you find method's performances easily.</description>
|
||||
<licenses>
|
||||
@ -32,7 +32,7 @@
|
||||
<spring-redis.version>2.6.2</spring-redis.version>
|
||||
<spring-mail.version>2.7.3</spring-mail.version>
|
||||
<fastjson.version>2.0.9</fastjson.version>
|
||||
<oshi-core.version>4.4.2</oshi-core.version>
|
||||
<oshi-core.version>6.2.2</oshi-core.version>
|
||||
<byte-agent.version>1.12.13</byte-agent.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.langpy.kotime.constant.KoConstant;
|
||||
import cn.langpy.kotime.model.*;
|
||||
import cn.langpy.kotime.service.ClassService;
|
||||
import cn.langpy.kotime.service.GraphService;
|
||||
import cn.langpy.kotime.service.SysUsageService;
|
||||
import cn.langpy.kotime.util.Context;
|
||||
import cn.langpy.kotime.util.InvalidAuthInfoException;
|
||||
import cn.langpy.kotime.util.KoUtil;
|
||||
@ -307,4 +308,30 @@ public class KoTimeController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping("/getCpuInfo")
|
||||
@ResponseBody
|
||||
@Auth
|
||||
public CpuInfo getCpuInfo() {
|
||||
SysUsageService usageService = SysUsageService.newInstance();
|
||||
CpuInfo cpuInfo = usageService.getCpuInfo();
|
||||
return cpuInfo;
|
||||
}
|
||||
|
||||
@GetMapping("/getHeapMemoryInfo")
|
||||
@ResponseBody
|
||||
@Auth
|
||||
public HeapMemoryInfo getHeapMemoryInfo() {
|
||||
SysUsageService usageService = SysUsageService.newInstance();
|
||||
HeapMemoryInfo heapMemoryInfo = usageService.getHeapMemoryInfo();
|
||||
return heapMemoryInfo;
|
||||
}
|
||||
@GetMapping("/getPhysicalMemoryInfo")
|
||||
@ResponseBody
|
||||
@Auth
|
||||
public PhysicalMemoryInfo getPhysicalMemoryInfo() {
|
||||
SysUsageService usageService = SysUsageService.newInstance();
|
||||
PhysicalMemoryInfo physicalMemoryInfo = usageService.getPhysicalMemoryInfo();
|
||||
return physicalMemoryInfo;
|
||||
}
|
||||
}
|
||||
|
||||
40
src/main/java/cn/langpy/kotime/model/CpuInfo.java
Normal file
40
src/main/java/cn/langpy/kotime/model/CpuInfo.java
Normal file
@ -0,0 +1,40 @@
|
||||
package cn.langpy.kotime.model;
|
||||
|
||||
public class CpuInfo {
|
||||
private Double systemLoad;
|
||||
private Double userRate;
|
||||
private Double sysRate;
|
||||
private Integer logicalNum;
|
||||
|
||||
public Double getSystemLoad() {
|
||||
return systemLoad;
|
||||
}
|
||||
|
||||
public void setSystemLoad(Double systemLoad) {
|
||||
this.systemLoad = systemLoad;
|
||||
}
|
||||
|
||||
public Double getUserRate() {
|
||||
return userRate;
|
||||
}
|
||||
|
||||
public void setUserRate(Double userRate) {
|
||||
this.userRate = userRate;
|
||||
}
|
||||
|
||||
public Double getSysRate() {
|
||||
return sysRate;
|
||||
}
|
||||
|
||||
public void setSysRate(Double sysRate) {
|
||||
this.sysRate = sysRate;
|
||||
}
|
||||
|
||||
public Integer getLogicalNum() {
|
||||
return logicalNum;
|
||||
}
|
||||
|
||||
public void setLogicalNum(Integer logicalNum) {
|
||||
this.logicalNum = logicalNum;
|
||||
}
|
||||
}
|
||||
40
src/main/java/cn/langpy/kotime/model/HeapMemoryInfo.java
Normal file
40
src/main/java/cn/langpy/kotime/model/HeapMemoryInfo.java
Normal file
@ -0,0 +1,40 @@
|
||||
package cn.langpy.kotime.model;
|
||||
|
||||
public class HeapMemoryInfo {
|
||||
private Long initValue;
|
||||
private Long maxValue;
|
||||
private Long usedValue;
|
||||
private Double usedRate;
|
||||
|
||||
public Long getInitValue() {
|
||||
return initValue;
|
||||
}
|
||||
|
||||
public void setInitValue(Long initValue) {
|
||||
this.initValue = initValue;
|
||||
}
|
||||
|
||||
public Long getMaxValue() {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
public void setMaxValue(Long maxValue) {
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public Long getUsedValue() {
|
||||
return usedValue;
|
||||
}
|
||||
|
||||
public void setUsedValue(Long usedValue) {
|
||||
this.usedValue = usedValue;
|
||||
}
|
||||
|
||||
public Double getUsedRate() {
|
||||
return usedRate;
|
||||
}
|
||||
|
||||
public void setUsedRate(Double usedRate) {
|
||||
this.usedRate = usedRate;
|
||||
}
|
||||
}
|
||||
40
src/main/java/cn/langpy/kotime/model/PhysicalMemoryInfo.java
Normal file
40
src/main/java/cn/langpy/kotime/model/PhysicalMemoryInfo.java
Normal file
@ -0,0 +1,40 @@
|
||||
package cn.langpy.kotime.model;
|
||||
|
||||
public class PhysicalMemoryInfo {
|
||||
private Long initValue;
|
||||
private Long freeValue;
|
||||
private Long usedValue;
|
||||
private Double usedRate;
|
||||
|
||||
public Long getInitValue() {
|
||||
return initValue;
|
||||
}
|
||||
|
||||
public void setInitValue(Long initValue) {
|
||||
this.initValue = initValue;
|
||||
}
|
||||
|
||||
public Long getFreeValue() {
|
||||
return freeValue;
|
||||
}
|
||||
|
||||
public void setFreeValue(Long freeValue) {
|
||||
this.freeValue = freeValue;
|
||||
}
|
||||
|
||||
public Long getUsedValue() {
|
||||
return usedValue;
|
||||
}
|
||||
|
||||
public void setUsedValue(Long usedValue) {
|
||||
this.usedValue = usedValue;
|
||||
}
|
||||
|
||||
public Double getUsedRate() {
|
||||
return usedRate;
|
||||
}
|
||||
|
||||
public void setUsedRate(Double usedRate) {
|
||||
this.usedRate = usedRate;
|
||||
}
|
||||
}
|
||||
@ -25,9 +25,7 @@ public class EmailHandler implements InvokedHandler {
|
||||
if (current == null || current.getValue() < Context.getConfig().getThreshold()) {
|
||||
return;
|
||||
}
|
||||
if (mailScope.equals("All")) {
|
||||
emailSendService.sendNoticeAsync(current);
|
||||
}else if (current.getMethodType().name().equals(mailScope)) {
|
||||
if (mailScope.equals("All") || current.getMethodType().name().equals(mailScope)) {
|
||||
emailSendService.sendNoticeAsync(current);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public final class KoInvokedHandler implements InvokedHandler {
|
||||
|
||||
private MethodNode filter(MethodNode currentNode) {
|
||||
if (BloomFilter.exists(currentNode.getId())) {
|
||||
//allow controllers's routes to be updated
|
||||
//allow controller's routes to be updated
|
||||
if (!StringUtils.isEmpty(currentNode.getRouteName())) {
|
||||
return currentNode;
|
||||
}
|
||||
|
||||
90
src/main/java/cn/langpy/kotime/service/SysUsageService.java
Normal file
90
src/main/java/cn/langpy/kotime/service/SysUsageService.java
Normal file
@ -0,0 +1,90 @@
|
||||
package cn.langpy.kotime.service;
|
||||
|
||||
import cn.langpy.kotime.model.CpuInfo;
|
||||
import cn.langpy.kotime.model.HeapMemoryInfo;
|
||||
import cn.langpy.kotime.model.PhysicalMemoryInfo;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class SysUsageService {
|
||||
|
||||
public static SysUsageService newInstance() {
|
||||
return new SysUsageService();
|
||||
}
|
||||
|
||||
public CpuInfo getCpuInfo() {
|
||||
SystemInfo systemInfo = new SystemInfo();
|
||||
CentralProcessor processor = systemInfo.getHardware().getProcessor();
|
||||
long[] prevTicks = processor.getSystemCpuLoadTicks();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long[] ticks = processor.getSystemCpuLoadTicks();
|
||||
long nice = ticks[CentralProcessor.TickType.NICE.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.NICE.getIndex()];
|
||||
|
||||
long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
|
||||
|
||||
long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
|
||||
|
||||
long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
|
||||
|
||||
long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
|
||||
|
||||
long user = ticks[CentralProcessor.TickType.USER.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.USER.getIndex()];
|
||||
|
||||
long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
|
||||
|
||||
long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()]
|
||||
- prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
|
||||
|
||||
long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
|
||||
CpuInfo cpuInfo = new CpuInfo();
|
||||
cpuInfo.setLogicalNum(processor.getLogicalProcessorCount());
|
||||
cpuInfo.setUserRate(user * 1.0 / totalCpu);
|
||||
cpuInfo.setSysRate(cSys * 1.0 / totalCpu);
|
||||
cpuInfo.setSystemLoad(processor.getSystemCpuLoad(1000));
|
||||
return cpuInfo;
|
||||
}
|
||||
|
||||
public HeapMemoryInfo getHeapMemoryInfo() {
|
||||
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
|
||||
MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage();
|
||||
long initTotalMemorySize = memoryUsage.getInit();
|
||||
long maxMemorySize = memoryUsage.getMax();
|
||||
long usedMemorySize = memoryUsage.getUsed();
|
||||
HeapMemoryInfo heapMemoryInfo = new HeapMemoryInfo();
|
||||
heapMemoryInfo.setInitValue(initTotalMemorySize);
|
||||
heapMemoryInfo.setMaxValue(maxMemorySize);
|
||||
heapMemoryInfo.setUsedValue(usedMemorySize);
|
||||
heapMemoryInfo.setUsedRate(usedMemorySize * 1.0 / maxMemorySize);
|
||||
return heapMemoryInfo;
|
||||
}
|
||||
|
||||
public PhysicalMemoryInfo getPhysicalMemoryInfo() {
|
||||
OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
||||
PhysicalMemoryInfo physicalMemoryInfo = new PhysicalMemoryInfo();
|
||||
physicalMemoryInfo.setInitValue(osmxb.getTotalPhysicalMemorySize());
|
||||
physicalMemoryInfo.setUsedValue(osmxb.getTotalPhysicalMemorySize() - osmxb.getFreePhysicalMemorySize());
|
||||
physicalMemoryInfo.setFreeValue(osmxb.getFreePhysicalMemorySize());
|
||||
physicalMemoryInfo.setUsedValue(physicalMemoryInfo.getInitValue() - physicalMemoryInfo.getFreeValue());
|
||||
physicalMemoryInfo.setUsedRate(physicalMemoryInfo.getUsedValue() * 1.0 / physicalMemoryInfo.getInitValue());
|
||||
return physicalMemoryInfo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -156,6 +156,9 @@
|
||||
});
|
||||
$.ajaxSettings.async = true;
|
||||
loadLatestVersion();
|
||||
loadCpuInfo();
|
||||
loadHeapMemoryInfo();
|
||||
loadPhysicalMemoryInfo();
|
||||
});
|
||||
|
||||
let methodParamMap = new Map();
|
||||
@ -402,6 +405,62 @@
|
||||
complete: function () {}
|
||||
})
|
||||
}
|
||||
function loadCpuInfo() {
|
||||
$.get('contextPath/koTime/getCpuInfo?token='+globalToken, function (data) {
|
||||
let systemLoad = data['systemLoad']*100;
|
||||
let userRate = data['userRate']*100;
|
||||
let sysRate = data['sysRate']*100;
|
||||
let logicalNum = data['logicalNum'];
|
||||
var systemLoadDom = document.querySelector("#systemLoad");
|
||||
if (systemLoad>50) {
|
||||
systemLoadDom.style.color='#cc0c0c';
|
||||
}else {
|
||||
systemLoadDom.style.color='#29da93';
|
||||
};
|
||||
systemLoadDom.innerHTML = `${systemLoad.toFixed(2)}%`;
|
||||
document.querySelector("#cpuSysRate").innerHTML = `${sysRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuUserRate").innerHTML = `${userRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuLogicalAmount").innerHTML = `${logicalNum}`;
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
function loadHeapMemoryInfo() {
|
||||
$.get('contextPath/koTime/getHeapMemoryInfo?token='+globalToken, function (data) {
|
||||
let initValue = data['initValue']/1024/1024;
|
||||
let maxValue = data['maxValue']/1024/1024;
|
||||
let usedValue = data['usedValue']/1024/1024;
|
||||
let usedRate = data['usedRate']*100;
|
||||
var heapUsedRateDom = document.querySelector("#heapUsedRate");
|
||||
if (usedRate>50) {
|
||||
heapUsedRateDom.style.color='#cc0c0c';
|
||||
}else {
|
||||
heapUsedRateDom.style.color='#29da93';
|
||||
};
|
||||
document.querySelector("#heapInit").innerHTML = `${initValue.toFixed()}M`;
|
||||
document.querySelector("#heapMax").innerHTML = `${maxValue.toFixed()}M`;
|
||||
document.querySelector("#heapUsed").innerHTML = `${usedValue.toFixed()}M`;
|
||||
heapUsedRateDom.innerHTML = `${usedRate.toFixed(2)}%`;
|
||||
});
|
||||
}
|
||||
function loadPhysicalMemoryInfo() {
|
||||
$.get('contextPath/koTime/getPhysicalMemoryInfo?token='+globalToken, function (data) {
|
||||
let initValue = data['initValue']/1024/1024;
|
||||
let freeValue = data['freeValue']/1024/1024;
|
||||
let usedValue = data['usedValue']/1024/1024;
|
||||
let usedRate = data['usedRate']*100;
|
||||
var physicalUsedRateDom = document.querySelector("#physicalUsedRate");
|
||||
if (usedRate>50) {
|
||||
physicalUsedRateDom.style.color='#cc0c0c';
|
||||
}else {
|
||||
physicalUsedRateDom.style.color='#29da93';
|
||||
};
|
||||
document.querySelector("#physicalAmount").innerHTML = `${initValue.toFixed()}M`;
|
||||
document.querySelector("#physicalFree").innerHTML = `${freeValue.toFixed()}M`;
|
||||
document.querySelector("#physicalUsed").innerHTML = `${usedValue.toFixed()}M`;
|
||||
physicalUsedRateDom.innerHTML = `${usedRate.toFixed(2)}%`;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<!--endreplace-->
|
||||
@ -479,6 +538,44 @@
|
||||
<span style="font-size: 30px;color: #020718;font-weight: bold" id="systemMinRunTime">0</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="uk-flex-left" uk-tab>
|
||||
<li class="uk-active"><a href="#" style="text-transform: capitalize">System Usage</a></li>
|
||||
</ul>
|
||||
<div style="margin-top: 20px;" class="uk-grid-small uk-child-width-expand@s uk-text-center" uk-grid>
|
||||
<div>
|
||||
<div id="cpuInfo-div" style="border-radius: 10px;background-color: #fefffe;padding: 20px" class="uk-card uk-card-default uk-card-body uk-label-success">
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;text-transform: unset">CPU Usage:</span><span style="font-size: 15px;color: #020718;font-weight: bold" id="systemLoad" >0</span>
|
||||
<hr style="margin-top: 7px">
|
||||
<ul class="uk-list-bullet" style="text-align: left;margin-top: -13px">
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">User Usage:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuUserRate" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">System Usage:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuSysRate" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">Logical Core:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuLogicalAmount" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="heapMemory-div" style="border-radius: 10px;background-color: #fefffe;padding: 20px" class="uk-card uk-card-default uk-card-body uk-label-success">
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;text-transform: unset">Heap Memory:</span><span style="font-size: 15px;color: #020718;font-weight: bold" id="heapUsedRate" >0</span>
|
||||
<hr style="margin-top: 7px">
|
||||
<ul class="uk-list-bullet" style="text-align: left;margin-top: -13px">
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">Init:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="heapInit" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">Max:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="heapMax" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">Used:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="heapUsed" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="physicalMemory-div" style="border-radius: 10px;background-color: #fefffe;padding: 20px" class="uk-card uk-card-default uk-card-body uk-label-success">
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;text-transform: unset">Physical Memory:</span><span style="font-size: 15px;color: #020718;font-weight: bold" id="physicalUsedRate" >0</span>
|
||||
<hr style="margin-top: 7px">
|
||||
<ul class="uk-list-bullet" style="text-align: left;margin-top: -13px">
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">All:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="physicalAmount" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">Used:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="physicalUsed" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">Free:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="physicalFree" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-alert-success" uk-alert>
|
||||
<a class="uk-alert-close" uk-close></a>
|
||||
<p id="apiTip">Please call apis before visiting this page!</p>
|
||||
|
||||
@ -155,6 +155,9 @@
|
||||
});
|
||||
$.ajaxSettings.async = true;
|
||||
loadLatestVersion();
|
||||
loadCpuInfo();
|
||||
loadHeapMemoryInfo();
|
||||
loadPhysicalMemoryInfo();
|
||||
});
|
||||
|
||||
let methodParamMap = new Map();
|
||||
@ -400,6 +403,63 @@
|
||||
complete: function () {}
|
||||
})
|
||||
}
|
||||
function loadCpuInfo() {
|
||||
$.get('contextPath/koTime/getCpuInfo?token='+globalToken, function (data) {
|
||||
let systemLoad = data['systemLoad']*100;
|
||||
let userRate = data['userRate']*100;
|
||||
let sysRate = data['sysRate']*100;
|
||||
let logicalNum = data['logicalNum'];
|
||||
var systemLoadDom = document.querySelector("#systemLoad");
|
||||
if (systemLoad>50) {
|
||||
systemLoadDom.style.color='#cc0c0c';
|
||||
}else {
|
||||
systemLoadDom.style.color='#29da93';
|
||||
};
|
||||
systemLoadDom.innerHTML = `${systemLoad.toFixed(2)}%`;
|
||||
document.querySelector("#cpuSysRate").innerHTML = `${sysRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuUserRate").innerHTML = `${userRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuLogicalAmount").innerHTML = `${logicalNum}个`;
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
function loadHeapMemoryInfo() {
|
||||
$.get('contextPath/koTime/getHeapMemoryInfo?token='+globalToken, function (data) {
|
||||
let initValue = data['initValue']/1024/1024;
|
||||
let maxValue = data['maxValue']/1024/1024;
|
||||
let usedValue = data['usedValue']/1024/1024;
|
||||
let usedRate = data['usedRate']*100;
|
||||
var heapUsedRateDom = document.querySelector("#heapUsedRate");
|
||||
if (usedRate>50) {
|
||||
heapUsedRateDom.style.color='#cc0c0c';
|
||||
}else {
|
||||
heapUsedRateDom.style.color='#29da93';
|
||||
};
|
||||
document.querySelector("#heapInit").innerHTML = `${initValue.toFixed()}M`;
|
||||
document.querySelector("#heapMax").innerHTML = `${maxValue.toFixed()}M`;
|
||||
document.querySelector("#heapUsed").innerHTML = `${usedValue.toFixed()}M`;
|
||||
heapUsedRateDom.innerHTML = `${usedRate.toFixed(2)}%`;
|
||||
});
|
||||
}
|
||||
function loadPhysicalMemoryInfo() {
|
||||
$.get('contextPath/koTime/getPhysicalMemoryInfo?token='+globalToken, function (data) {
|
||||
let initValue = data['initValue']/1024/1024;
|
||||
let freeValue = data['freeValue']/1024/1024;
|
||||
let usedValue = data['usedValue']/1024/1024;
|
||||
let usedRate = data['usedRate']*100;
|
||||
var physicalUsedRateDom = document.querySelector("#physicalUsedRate");
|
||||
if (usedRate>50) {
|
||||
physicalUsedRateDom.style.color='#cc0c0c';
|
||||
}else {
|
||||
physicalUsedRateDom.style.color='#29da93';
|
||||
};
|
||||
document.querySelector("#physicalAmount").innerHTML = `${initValue.toFixed()}M`;
|
||||
document.querySelector("#physicalFree").innerHTML = `${freeValue.toFixed()}M`;
|
||||
document.querySelector("#physicalUsed").innerHTML = `${usedValue.toFixed()}M`;
|
||||
physicalUsedRateDom.innerHTML = `${usedRate.toFixed(2)}%`;
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<!--endreplace-->
|
||||
@ -473,6 +533,45 @@
|
||||
<span style="font-size: 30px;color: #020718;font-weight: bold" id="systemMinRunTime">0</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="uk-flex-left" uk-tab>
|
||||
<li class="uk-active"><a href="#" >系统使用情况</a></li>
|
||||
</ul>
|
||||
<div style="margin-top: 20px;" class="uk-grid-small uk-child-width-expand@s uk-text-center" uk-grid>
|
||||
<div>
|
||||
<div id="cpuInfo-div" style="border-radius: 10px;background-color: #fefffe;padding: 20px" class="uk-card uk-card-default uk-card-body uk-label-success">
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;">CPU负载:</span><span style="font-size: 15px;color: #020718;font-weight: bold" id="systemLoad" >0</span>
|
||||
<hr style="margin-top: 7px">
|
||||
<ul class="uk-list-bullet" style="text-align: left;margin-top: -13px">
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">用户使用率:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuUserRate" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">系统使用率:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuSysRate" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">逻辑核心数:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuLogicalAmount" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="heapMemory-div" style="border-radius: 10px;background-color: #fefffe;padding: 20px" class="uk-card uk-card-default uk-card-body uk-label-success">
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;">堆内存:</span><span style="font-size: 15px;color: #020718;font-weight: bold" id="heapUsedRate" >0</span>
|
||||
<hr style="margin-top: 7px">
|
||||
<ul class="uk-list-bullet" style="text-align: left;margin-top: -13px">
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">初始值:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="heapInit" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">最大值:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="heapMax" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">已使用:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="heapUsed" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="physicalMemory-div" style="border-radius: 10px;background-color: #fefffe;padding: 20px" class="uk-card uk-card-default uk-card-body uk-label-success">
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;">物理内存:</span><span style="font-size: 15px;color: #020718;font-weight: bold" id="physicalUsedRate" >0</span>
|
||||
<hr style="margin-top: 7px">
|
||||
<ul class="uk-list-bullet" style="text-align: left;margin-top: -13px">
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">总内存:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="physicalAmount" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">已使用:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="physicalUsed" >0</span></li>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">未使用:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="physicalFree" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-alert-success" uk-alert>
|
||||
<a class="uk-alert-close" uk-close></a>
|
||||
<p id="apiTip">接口根据调用情况统计,未调用的接口无法被统计到,请先调用接口</p>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user