mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
optimize system usage
This commit is contained in:
parent
2e691411b9
commit
9fd3224cd2
@ -15,6 +15,7 @@ public class DefaultConfig {
|
||||
@Deprecated
|
||||
private String logLanguage;
|
||||
private Boolean logEnable;
|
||||
private Boolean versionNotice;
|
||||
private Double threshold;
|
||||
private Double discardRate;
|
||||
private String pointcut;
|
||||
@ -33,6 +34,14 @@ public class DefaultConfig {
|
||||
|
||||
private Long authExpire;
|
||||
|
||||
public Boolean getVersionNotice() {
|
||||
return versionNotice;
|
||||
}
|
||||
|
||||
public void setVersionNotice(Boolean versionNotice) {
|
||||
this.versionNotice = versionNotice;
|
||||
}
|
||||
|
||||
public Long getAuthExpire() {
|
||||
return authExpire;
|
||||
}
|
||||
|
||||
@ -94,6 +94,7 @@ public class LoadConfig {
|
||||
config.setAuthEnable(defaultConfig.getAuthEnable() == null ? false : defaultConfig.getAuthEnable());
|
||||
config.setParamAnalyse(defaultConfig.getParamAnalyse() == null ? true : defaultConfig.getParamAnalyse());
|
||||
config.setDataReset(defaultConfig.getDataReset() == null ? false : defaultConfig.getDataReset());
|
||||
config.setVersionNotice(defaultConfig.getVersionNotice() == null ? true : defaultConfig.getVersionNotice());
|
||||
configDataSource(config);
|
||||
configRedisTemplate(config);
|
||||
Context.setConfig(config);
|
||||
|
||||
@ -4,8 +4,17 @@ public class CpuInfo {
|
||||
private Double systemLoad;
|
||||
private Double userRate;
|
||||
private Double sysRate;
|
||||
private Double waitRate;
|
||||
private Integer logicalNum;
|
||||
|
||||
public Double getWaitRate() {
|
||||
return waitRate;
|
||||
}
|
||||
|
||||
public void setWaitRate(Double waitRate) {
|
||||
this.waitRate = waitRate;
|
||||
}
|
||||
|
||||
public Double getSystemLoad() {
|
||||
return systemLoad;
|
||||
}
|
||||
|
||||
@ -57,6 +57,7 @@ public class SysUsageService {
|
||||
cpuInfo.setLogicalNum(processor.getLogicalProcessorCount());
|
||||
cpuInfo.setUserRate(user * 1.0 / totalCpu);
|
||||
cpuInfo.setSysRate(cSys * 1.0 / totalCpu);
|
||||
cpuInfo.setWaitRate(iowait * 1.0 / totalCpu);
|
||||
cpuInfo.setSystemLoad(processor.getSystemCpuLoad(1000));
|
||||
return cpuInfo;
|
||||
}
|
||||
|
||||
@ -123,6 +123,13 @@
|
||||
"description": "to enable authentication",
|
||||
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||
},
|
||||
{
|
||||
"name": "ko-time.version-notice",
|
||||
"type": "java.lang.Boolean",
|
||||
"defaultValue": true,
|
||||
"description": "to enable version-notice",
|
||||
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
|
||||
},
|
||||
{
|
||||
"name": "ko-time.auth-expire",
|
||||
"type": "java.lang.Long",
|
||||
|
||||
@ -31,6 +31,10 @@
|
||||
return;
|
||||
};
|
||||
$.get('contextPath/koTime/getConfig?token='+globalToken, function (data) {
|
||||
let versionNoticeEnable = data['versionNotice'];
|
||||
if (versionNoticeEnable) {
|
||||
loadLatestVersion();
|
||||
}
|
||||
let exceptionEnable = data['exceptionEnable'];
|
||||
|
||||
let exceptionEnableDom = document.getElementById('exceptionEnable');
|
||||
@ -155,7 +159,6 @@
|
||||
element.innerHTML = html;
|
||||
});
|
||||
$.ajaxSettings.async = true;
|
||||
loadLatestVersion();
|
||||
loadCpuInfo();
|
||||
loadHeapMemoryInfo();
|
||||
loadPhysicalMemoryInfo();
|
||||
@ -387,7 +390,7 @@
|
||||
})
|
||||
}
|
||||
function loadLatestVersion(){
|
||||
/*get latest version so that you can update kotime immediately*/
|
||||
/*get the latest version so that you can update kotime immediately*/
|
||||
$.ajax({
|
||||
url: 'http://kotimedoc.langpy.cn/common/latestVersion',
|
||||
type: 'GET',
|
||||
@ -411,6 +414,8 @@
|
||||
let userRate = data['userRate']*100;
|
||||
let sysRate = data['sysRate']*100;
|
||||
let logicalNum = data['logicalNum'];
|
||||
let waitRate = data['waitRate'];
|
||||
|
||||
var systemLoadDom = document.querySelector("#systemLoad");
|
||||
if (systemLoad>50) {
|
||||
systemLoadDom.style.color='#cc0c0c';
|
||||
@ -420,8 +425,8 @@
|
||||
systemLoadDom.innerHTML = `${systemLoad.toFixed(2)}%`;
|
||||
document.querySelector("#cpuSysRate").innerHTML = `${sysRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuUserRate").innerHTML = `${userRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuLogicalAmount").innerHTML = `${logicalNum}`;
|
||||
|
||||
document.querySelector("#cpuWaitRate").innerHTML = `${waitRate}%`;
|
||||
document.querySelector("#cpuLogicalAmount").innerHTML = `CPU Usage(${logicalNum}):`;
|
||||
|
||||
});
|
||||
}
|
||||
@ -544,12 +549,12 @@
|
||||
<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>
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;text-transform: unset" id="cpuLogicalAmount">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>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;text-transform: unset">IO Wait Rate:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuWaitRate" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -31,6 +31,11 @@
|
||||
return;
|
||||
};
|
||||
$.get('contextPath/koTime/getConfig?token='+globalToken, function (data) {
|
||||
let versionNoticeEnable = data['versionNotice'];
|
||||
if (versionNoticeEnable) {
|
||||
loadLatestVersion();
|
||||
}
|
||||
|
||||
let exceptionEnable = data['exceptionEnable'];
|
||||
|
||||
let exceptionEnableDom = document.getElementById('exceptionEnable');
|
||||
@ -154,7 +159,6 @@
|
||||
element.innerHTML = html;
|
||||
});
|
||||
$.ajaxSettings.async = true;
|
||||
loadLatestVersion();
|
||||
loadCpuInfo();
|
||||
loadHeapMemoryInfo();
|
||||
loadPhysicalMemoryInfo();
|
||||
@ -401,7 +405,7 @@
|
||||
error: function (XmlHttpRequest, textStatus, errorThrown) {
|
||||
},
|
||||
complete: function () {}
|
||||
})
|
||||
});
|
||||
}
|
||||
function loadCpuInfo() {
|
||||
$.get('contextPath/koTime/getCpuInfo?token='+globalToken, function (data) {
|
||||
@ -409,6 +413,7 @@
|
||||
let userRate = data['userRate']*100;
|
||||
let sysRate = data['sysRate']*100;
|
||||
let logicalNum = data['logicalNum'];
|
||||
let waitRate = data['waitRate'];
|
||||
var systemLoadDom = document.querySelector("#systemLoad");
|
||||
if (systemLoad>50) {
|
||||
systemLoadDom.style.color='#cc0c0c';
|
||||
@ -418,9 +423,8 @@
|
||||
systemLoadDom.innerHTML = `${systemLoad.toFixed(2)}%`;
|
||||
document.querySelector("#cpuSysRate").innerHTML = `${sysRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuUserRate").innerHTML = `${userRate.toFixed(2)}%`;
|
||||
document.querySelector("#cpuLogicalAmount").innerHTML = `${logicalNum}个`;
|
||||
|
||||
|
||||
document.querySelector("#cpuLogicalAmount").innerHTML = `CPU使用率(${logicalNum}):`;
|
||||
document.querySelector("#cpuWaitRate").innerHTML = `${waitRate}%`;
|
||||
});
|
||||
}
|
||||
function loadHeapMemoryInfo() {
|
||||
@ -539,12 +543,12 @@
|
||||
<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>
|
||||
<span style="font-size: 12px;color: #3b3f4f;justify-content: space-around;" id="cpuLogicalAmount">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">
|
||||
<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>
|
||||
<li style="margin-top: -2px;"><span style="font-size: 8px;color: #3b3f4f;">IO 等待率:</span><span style="font-size: 12px;color: #020718;font-weight: bold" id="cpuWaitRate" >0</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user