mirror of https://gitee.com/stylefeng/guns
【monitor】优化监控速度
parent
bb2a1d89e3
commit
57ef34ebf5
|
@ -5,7 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.guns.core.consts.ProjectConstants;
|
import cn.stylefeng.guns.core.consts.ProjectConstants;
|
||||||
import cn.stylefeng.guns.modular.system.monitor.model.PromResultInfo;
|
import cn.stylefeng.guns.modular.system.monitor.model.PromResultInfo;
|
||||||
import cn.stylefeng.guns.modular.system.monitor.service.MetricService;
|
import cn.stylefeng.guns.modular.system.monitor.service.MetricService;
|
||||||
import cn.stylefeng.guns.modular.system.monitor.warpper.SystemHardwareWrapper;
|
import cn.stylefeng.guns.modular.system.monitor.timer.SystemHardwareInfoHolder;
|
||||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
@ -42,6 +42,9 @@ public class MonitorController {
|
||||||
@Resource
|
@Resource
|
||||||
private MetricService service;
|
private MetricService service;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SystemHardwareInfoHolder systemHardwareInfoHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统硬件信息页面
|
* 系统硬件信息页面
|
||||||
*
|
*
|
||||||
|
@ -50,9 +53,7 @@ public class MonitorController {
|
||||||
*/
|
*/
|
||||||
@GetResource(name = "服务器监控", path = "/view/monitor/systemInfo")
|
@GetResource(name = "服务器监控", path = "/view/monitor/systemInfo")
|
||||||
public String systemInfo(Model model) {
|
public String systemInfo(Model model) {
|
||||||
SystemHardwareWrapper systemHardwareWrapper = new SystemHardwareWrapper();
|
model.addAttribute("server", systemHardwareInfoHolder.getSystemHardwareInfo());
|
||||||
systemHardwareWrapper.copyTo();
|
|
||||||
model.addAttribute("server", systemHardwareWrapper);
|
|
||||||
return "/modular/system/monitor/systemInfo.html";
|
return "/modular/system/monitor/systemInfo.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package cn.stylefeng.guns.modular.system.monitor.timer;
|
||||||
|
|
||||||
|
import cn.stylefeng.guns.modular.system.monitor.warpper.SystemHardwareWrapper;
|
||||||
|
import cn.stylefeng.roses.kernel.timer.api.TimerAction;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时刷新服务器状态信息
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2021/1/31 21:52
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SystemHardwareInfoHolder implements TimerAction {
|
||||||
|
|
||||||
|
private SystemHardwareWrapper systemHardwareWrapper = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action() {
|
||||||
|
SystemHardwareWrapper newInfo = new SystemHardwareWrapper();
|
||||||
|
newInfo.copyTo();
|
||||||
|
systemHardwareWrapper = newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SystemHardwareWrapper getSystemHardwareInfo() {
|
||||||
|
if (systemHardwareWrapper != null) {
|
||||||
|
return systemHardwareWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
systemHardwareWrapper = new SystemHardwareWrapper();
|
||||||
|
systemHardwareWrapper.copyTo();
|
||||||
|
return systemHardwareWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue