Merge pull request #133 from lidongdai/dev-20190415

add monitor
This commit is contained in:
easyscheduler 2019-04-24 18:23:51 +08:00 committed by GitHub
commit 46dda9589d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,11 @@ public class ResInfo {
*/
private double memoryUsage;
/**
* loadAverage
*/
private double loadAverage;
public ResInfo(){}
public ResInfo(double cpuUsage , double memoryUsage){
@ -42,6 +47,12 @@ public class ResInfo {
this.memoryUsage = memoryUsage;
}
public ResInfo(double cpuUsage, double memoryUsage, double loadAverage) {
this.cpuUsage = cpuUsage;
this.memoryUsage = memoryUsage;
this.loadAverage = loadAverage;
}
public double getCpuUsage() {
return cpuUsage;
}
@ -58,12 +69,21 @@ public class ResInfo {
this.memoryUsage = memoryUsage;
}
public double getLoadAverage() {
return loadAverage;
}
public void setLoadAverage(double loadAverage) {
this.loadAverage = loadAverage;
}
/**
* get CPU and memory usage
* add cpu load average by lidong for service monitor
* @return
*/
public static String getResInfoJson(){
ResInfo resInfo = new ResInfo(OSUtils.cpuUsage(), OSUtils.memoryUsage());
ResInfo resInfo = new ResInfo(OSUtils.cpuUsage(), OSUtils.memoryUsage(),OSUtils.loadAverage());
return JSONUtils.toJson(resInfo);
}