项目初始化
This commit is contained in:
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -29,19 +30,20 @@ public class SysAnalysisController {
|
||||
public List<ChartInfo> getHostInfo() {
|
||||
List<ChartInfo> chartInfoList = new ArrayList<>();
|
||||
CpuInfo cpuInfo = OshiUtil.getCpuInfo();
|
||||
String runTime = DateUtil.formatBetween(OshiUtil.getOs().getSystemUptime() * 1000);
|
||||
// 系统使用率(红色)
|
||||
chartInfoList.add(new ChartInfo("sys", "系统使用率", cpuInfo.getSys(), KeyUtil.getColor(), runTime));
|
||||
// 用户使用率(蓝色)
|
||||
chartInfoList.add(new ChartInfo("user", "用户使用率", cpuInfo.getUser(), KeyUtil.getColor(), runTime));
|
||||
// CPU等待率(橙色)
|
||||
chartInfoList.add(new ChartInfo("wait", "CPU等待率", cpuInfo.getWait(), KeyUtil.getColor(), runTime));
|
||||
// CPU空闲率(绿色)
|
||||
chartInfoList.add(new ChartInfo("free", "CPU空闲率", cpuInfo.getFree(), KeyUtil.getColor(), runTime));
|
||||
// CPU总使用率(粉色)
|
||||
chartInfoList.add(new ChartInfo("used", "CPU总使用率", cpuInfo.getUsed(), KeyUtil.getColor(), runTime));
|
||||
// 系统运行时间(紫色)
|
||||
chartInfoList.add(new ChartInfo("time", "服务器运行时长", 0, KeyUtil.getColor(), runTime));
|
||||
long processUptimeMs = ManagementFactory.getRuntimeMXBean().getUptime();
|
||||
String runTime = DateUtil.formatBetween(processUptimeMs);
|
||||
// 系统使用率
|
||||
chartInfoList.add(new ChartInfo("sys", "系统使用率", cpuInfo.getSys(), KeyUtil.getColor(), ""));
|
||||
// 用户使用率
|
||||
chartInfoList.add(new ChartInfo("user", "用户使用率", cpuInfo.getUser(), KeyUtil.getColor(), ""));
|
||||
// CPU等待率
|
||||
chartInfoList.add(new ChartInfo("wait", "CPU等待率", cpuInfo.getWait(), KeyUtil.getColor(), ""));
|
||||
// CPU空闲率
|
||||
chartInfoList.add(new ChartInfo("free", "CPU空闲率", cpuInfo.getFree(), KeyUtil.getColor(), ""));
|
||||
// CPU总使用率
|
||||
chartInfoList.add(new ChartInfo("used", "CPU总使用率", cpuInfo.getUsed(), KeyUtil.getColor(), ""));
|
||||
// 系统运行时间
|
||||
chartInfoList.add(new ChartInfo("time", "系统运行时长", processUptimeMs, KeyUtil.getColor(), runTime));
|
||||
return chartInfoList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user