use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class CheckMonitor method init.
@PreLoadMethod
private static void init() {
// 缓存检测调度
CronUtils.upsert("cache_manger_schedule", "0 0/10 * * * ?", () -> {
BuildUtil.reloadCacheSize();
ConfigBean.getInstance().dataSize();
});
// 开启版本检测调度
CronUtils.upsert("system_monitor", "0 0 0,12 * * ?", () -> {
try {
BackupInfoService backupInfoService = SpringUtil.getBean(BackupInfoService.class);
backupInfoService.checkAutoBackup();
//
RemoteVersion.loadRemoteInfo();
} catch (Exception e) {
DefaultSystemLog.getLog().error("系统调度执行出现错误", e);
}
});
// 拉取 脚本模版日志
CronUtils.upsert("pull_script_log", "0 0/1 * * * ?", () -> {
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeScriptServer nodeScriptServer = SpringUtil.getBean(NodeScriptServer.class);
List<String> nodeIds = nodeScriptServer.hasScriptNode();
if (nodeIds == null) {
return;
}
for (String nodeId : nodeIds) {
NodeModel nodeModel = nodeService.getByKey(nodeId);
if (nodeModel == null) {
continue;
}
ThreadUtil.execute(() -> CheckMonitor.pullScriptLogItem(nodeModel));
}
});
// 异步加载
CheckMonitor.asyncLoad();
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class BaseHandler method logOpt.
/**
* 操作 websocket 日志
*
* @param cls class
* @param attributes 属性
* @param reqData 请求数据
*/
protected void logOpt(Class<?> cls, Map<String, Object> attributes, Object reqData) {
String ip = (String) attributes.get("ip");
NodeModel nodeModel = (NodeModel) attributes.get("nodeInfo");
// 记录操作日志
UserModel userInfo = (UserModel) attributes.get("userInfo");
String workspaceId = (String) attributes.get("workspaceId");
OperateLogController.CacheInfo cacheInfo = new OperateLogController.CacheInfo();
cacheInfo.setIp(ip);
Feature feature = cls.getAnnotation(Feature.class);
MethodFeature method = feature.method();
// Assert.state(feature != null && feature, "权限功能没有配置正确");
cacheInfo.setClassFeature(feature.cls());
cacheInfo.setWorkspaceId(workspaceId);
cacheInfo.setMethodFeature(method);
cacheInfo.setNodeModel(nodeModel);
cacheInfo.setDataId(null);
String userAgent = (String) attributes.get(HttpHeaders.USER_AGENT);
cacheInfo.setUserAgent(userAgent);
cacheInfo.setReqData(JSONObject.toJSONString(reqData));
// cacheInfo.setMethodFeature(execute);
Object proxySession = attributes.get("proxySession");
try {
attributes.remove("proxySession");
attributes.put("use_type", "WebSocket");
attributes.put("class_type", cls.getName());
OperateLogController operateLogController = SpringUtil.getBean(OperateLogController.class);
operateLogController.log(userInfo, JSONObject.toJSONString(attributes), cacheInfo);
} catch (Exception e) {
DefaultSystemLog.getLog().error("记录操作日志异常", e);
} finally {
if (proxySession != null) {
attributes.put("proxySession", proxySession);
}
}
}
use of io.jpom.model.data.NodeModel 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);
}
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class NodeStatService method save.
/**
* 更新状态 和错误信息
*
* @param modelList 节点
* @param satus 状态
* @param msg 错误消息
*/
private void save(List<NodeModel> modelList, int satus, String msg) {
for (NodeModel nodeModel : modelList) {
NodeStatModel nodeStatModel = this.create(nodeModel);
nodeStatModel.setFailureMsg(msg);
nodeStatModel.setStatus(satus);
this.upsert(nodeStatModel);
}
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class NodeStatService method getListByUrl.
private List<NodeModel> getListByUrl(String url) {
NodeModel nodeModel = new NodeModel();
nodeModel.setUrl(url);
return nodeService.listByBean(nodeModel);
}
Aggregations