Browse Source

add monitor by lidong

pull/2/head
dailidong 6 years ago
parent
commit
4b930ade92
  1. 22
      escheduler-server/src/main/java/cn/escheduler/server/ResInfo.java

22
escheduler-server/src/main/java/cn/escheduler/server/ResInfo.java

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

Loading…
Cancel
Save