use of io.jpom.model.log.SystemMonitorLog in project Jpom by dromara.
the class NodeWelcomeController method getList.
private List<SystemMonitorLog> getList() {
NodeModel node = getNode();
String startDateStr = getParameter("time[0]");
String endDateStr = getParameter("time[1]");
if (StrUtil.hasEmpty(startDateStr, endDateStr)) {
SystemMonitorLog systemMonitorLog = new SystemMonitorLog();
systemMonitorLog.setNodeId(node.getId());
return dbSystemMonitorLogService.queryList(systemMonitorLog, 500, new Order("monitorTime", Direction.DESC));
}
// 处理时间
DateTime startDate = DateUtil.parse(startDateStr);
long startTime = startDate.getTime();
DateTime endDate = DateUtil.parse(endDateStr);
if (startDate.equals(endDate)) {
// 时间相等
endDate = DateUtil.endOfDay(endDate);
}
long endTime = endDate.getTime();
// 开启了节点信息采集
Page pageObj = new Page(1, 5000);
pageObj.addOrder(new Order("monitorTime", Direction.DESC));
Entity entity = Entity.create();
entity.set("nodeId", node.getId());
entity.set(" MONITORTIME", ">= " + startTime);
entity.set("MONITORTIME", "<= " + endTime);
return dbSystemMonitorLogService.listPageOnlyResult(entity, pageObj);
}
use of io.jpom.model.log.SystemMonitorLog in project Jpom by dromara.
the class NodeStatService method saveSystemMonitor.
private void saveSystemMonitor(List<NodeModel> modelList, JSONObject systemMonitor) {
if (systemMonitor != null) {
List<SystemMonitorLog> monitorLogs = modelList.stream().map(nodeModel -> {
SystemMonitorLog log = new SystemMonitorLog();
log.setOccupyMemory(systemMonitor.getDouble("memory"));
log.setOccupyMemoryUsed(systemMonitor.getDouble("memoryUsed"));
log.setOccupyDisk(systemMonitor.getDouble("disk"));
log.setOccupyCpu(systemMonitor.getDouble("cpu"));
log.setMonitorTime(systemMonitor.getLongValue("time"));
log.setNetworkTime(systemMonitor.getIntValue("networkTime"));
log.setNodeId(nodeModel.getId());
return log;
}).collect(Collectors.toList());
//
dbSystemMonitorLogService.insert(monitorLogs);
}
}
Aggregations