mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-29 18:38:32 +08:00
fix 机器状态新增:资源监控异常(资源监控异常不影响功能使用)
This commit is contained in:
parent
0a7f6e8c62
commit
d6631a1b46
@ -1,5 +1,13 @@
|
||||
# 🚀 版本日志
|
||||
|
||||
## 2.11.1.2-beta
|
||||
|
||||
### 🐞 解决BUG、优化功能
|
||||
|
||||
1. 【all】优化 机器状态新增:资源监控异常(资源监控异常不影响功能使用)
|
||||
|
||||
------
|
||||
|
||||
## 2.11.1.1-beta (2024-01-16)
|
||||
|
||||
### 🐞 解决BUG、优化功能
|
||||
|
@ -42,7 +42,6 @@ import org.dromara.jpom.plugin.PluginFactory;
|
||||
import org.dromara.jpom.service.manage.ProjectInfoService;
|
||||
import org.dromara.jpom.service.script.NodeScriptServer;
|
||||
import org.dromara.jpom.util.JvmUtil;
|
||||
import org.dromara.jpom.util.OshiUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -108,17 +107,22 @@ public class IndexController extends BaseAgentController {
|
||||
@PostMapping(value = "get-stat-info", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public IJsonMessage<JSONObject> getDirectTop() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONObject topInfo = OshiUtils.getSimpleInfo();
|
||||
jsonObject.put("simpleStatus", topInfo);
|
||||
// 系统固定休眠时间
|
||||
jsonObject.put("systemSleep", OshiUtils.NET_STAT_SLEEP + OshiUtils.CPU_STAT_SLEEP);
|
||||
try {
|
||||
JSONObject topInfo = org.dromara.jpom.util.OshiUtils.getSimpleInfo();
|
||||
jsonObject.put("simpleStatus", topInfo);
|
||||
// 系统固定休眠时间
|
||||
jsonObject.put("systemSleep", org.dromara.jpom.util.OshiUtils.NET_STAT_SLEEP + org.dromara.jpom.util.OshiUtils.CPU_STAT_SLEEP);
|
||||
|
||||
JSONObject systemInfo = OshiUtils.getSystemInfo();
|
||||
jsonObject.put("systemInfo", systemInfo);
|
||||
JSONObject systemInfo = org.dromara.jpom.util.OshiUtils.getSystemInfo();
|
||||
jsonObject.put("systemInfo", systemInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("oshi 系统监控异常", e);
|
||||
jsonObject.put("oshiError", e.getMessage());
|
||||
}
|
||||
|
||||
JSONObject jpomInfo = this.getJpomInfo();
|
||||
jsonObject.put("jpomInfo", jpomInfo);
|
||||
return JsonMessage.success("ok", jsonObject);
|
||||
return JsonMessage.success("", jsonObject);
|
||||
}
|
||||
|
||||
private JSONObject getJpomInfo() {
|
||||
@ -166,17 +170,22 @@ public class IndexController extends BaseAgentController {
|
||||
|
||||
@RequestMapping(value = "processList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public IJsonMessage<List<JSONObject>> getProcessList(String processName, Integer count) {
|
||||
processName = StrUtil.emptyToDefault(processName, "java");
|
||||
List<JSONObject> processes = OshiUtils.getProcesses(processName, Convert.toInt(count, 20));
|
||||
processes = processes.stream()
|
||||
.peek(jsonObject -> {
|
||||
int processId = jsonObject.getIntValue("processId");
|
||||
String port = projectCommander.getMainPort(processId);
|
||||
jsonObject.put("port", port);
|
||||
//
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return JsonMessage.success("ok", processes);
|
||||
try {
|
||||
processName = StrUtil.emptyToDefault(processName, "java");
|
||||
List<JSONObject> processes = org.dromara.jpom.util.OshiUtils.getProcesses(processName, Convert.toInt(count, 20));
|
||||
processes = processes.stream()
|
||||
.peek(jsonObject -> {
|
||||
int processId = jsonObject.getIntValue("processId");
|
||||
String port = projectCommander.getMainPort(processId);
|
||||
jsonObject.put("port", port);
|
||||
//
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return JsonMessage.success("", processes);
|
||||
} catch (Exception e) {
|
||||
log.error("oshi 系统进程监控异常", e);
|
||||
throw new IllegalStateException("系统进程监控异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -193,19 +202,34 @@ public class IndexController extends BaseAgentController {
|
||||
|
||||
@PostMapping(value = "disk-info", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public IJsonMessage<List<JSONObject>> diskInfo() {
|
||||
List<JSONObject> list = OshiUtils.fileStores();
|
||||
return JsonMessage.success("", list);
|
||||
try {
|
||||
List<JSONObject> list = org.dromara.jpom.util.OshiUtils.fileStores();
|
||||
return JsonMessage.success("", list);
|
||||
} catch (Exception e) {
|
||||
log.error("oshi 文件系统资源监控异常", e);
|
||||
throw new IllegalStateException("文件系统监控异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "hw-disk--info", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public IJsonMessage<List<JSONObject>> hwDiskInfo() {
|
||||
List<JSONObject> list = OshiUtils.diskStores();
|
||||
return JsonMessage.success("", list);
|
||||
try {
|
||||
List<JSONObject> list = org.dromara.jpom.util.OshiUtils.diskStores();
|
||||
return JsonMessage.success("", list);
|
||||
} catch (Exception e) {
|
||||
log.error("oshi 硬盘资源监控异常", e);
|
||||
throw new IllegalStateException("硬盘资源监控异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "network-interfaces", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public IJsonMessage<List<JSONObject>> networkInterfaces() {
|
||||
List<JSONObject> list = OshiUtils.networkInterfaces();
|
||||
return JsonMessage.success("", list);
|
||||
try {
|
||||
List<JSONObject> list = org.dromara.jpom.util.OshiUtils.networkInterfaces();
|
||||
return JsonMessage.success("", list);
|
||||
} catch (Exception e) {
|
||||
log.error("oshi 网卡资源监控异常", e);
|
||||
throw new IllegalStateException("网卡资源监控异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ package org.dromara.jpom.exception;
|
||||
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.keepbx.jpom.IJsonMessage;
|
||||
import cn.keepbx.jpom.model.JsonMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -77,7 +79,8 @@ public abstract class BaseExceptionHandler {
|
||||
@ResponseBody
|
||||
public IJsonMessage<String> defNullPointerExceptionHandler(HttpServletRequest request, Exception e) {
|
||||
log.error("global NullPointerException: {}", request.getRequestURI(), e);
|
||||
return new JsonMessage<>(500, "程序错误,空指针");
|
||||
String jpomType = SystemUtil.get("JPOM_TYPE", StrUtil.EMPTY);
|
||||
return new JsonMessage<>(500, jpomType + "程序错误,空指针");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +124,7 @@ public class MachineNodeModel extends BaseGroupNameModel implements INodeInfo {
|
||||
/**
|
||||
* 节点连接状态
|
||||
* <p>
|
||||
* 状态{0,无法连接,1 正常, 2 授权信息错误, 3 状态码错误}
|
||||
* 状态{0,无法连接,1 正常, 2 授权信息错误, 3 状态码错误,4 资源监控异常}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
|
@ -274,8 +274,14 @@ public class MachineNodeServer extends BaseDbService<MachineNodeModel> implement
|
||||
private void saveStatInfo(MachineNodeModel machineNode, JSONObject data) {
|
||||
MachineNodeModel machineNodeModel = new MachineNodeModel();
|
||||
machineNodeModel.setId(machineNode.getId());
|
||||
machineNodeModel.setStatus(1);
|
||||
machineNodeModel.setStatusMsg("ok");
|
||||
String oshiError = data.getString("oshiError");
|
||||
if (StrUtil.isEmpty(oshiError)) {
|
||||
machineNodeModel.setStatus(1);
|
||||
machineNodeModel.setStatusMsg("ok");
|
||||
} else {
|
||||
machineNodeModel.setStatus(4);
|
||||
machineNodeModel.setStatusMsg(oshiError);
|
||||
}
|
||||
int networkDelay = data.getIntValue("networkDelay");
|
||||
int systemSleep = data.getIntValue("systemSleep");
|
||||
// 减去系统固定休眠时间
|
||||
|
@ -48,7 +48,8 @@ export const statusMap = {
|
||||
0: '无法连接',
|
||||
1: '正常',
|
||||
2: '授权信息错误',
|
||||
3: '状态码错误'
|
||||
3: '状态码错误',
|
||||
4: '资源监控异常'
|
||||
}
|
||||
|
||||
// 查看机器关联节点
|
||||
|
Loading…
Reference in New Issue
Block a user