This commit is contained in:
2025-12-07 18:58:41 +08:00
parent 221ecbf05a
commit e388613fc8
26 changed files with 3368 additions and 722 deletions

View File

@@ -3,18 +3,9 @@ package com.jeesite.modules.app.Job;
import com.jeesite.modules.app.dao.info.CpuInfo;
import com.jeesite.modules.app.dao.info.DiskInfo;
import com.jeesite.modules.app.dao.info.ServerInfo;
import com.jeesite.modules.app.utils.SystemUtil;
import com.jeesite.modules.app.utils.vo;
import com.jeesite.modules.biz.entity.BizDeviceInfo;
import com.jeesite.modules.biz.entity.BizMonitorAccount;
import com.jeesite.modules.biz.entity.BizMonitorHost;
import com.jeesite.modules.biz.entity.BizServerInfo;
import com.jeesite.modules.biz.service.BizDeviceInfoService;
import com.jeesite.modules.biz.service.BizMonitorAccountService;
import com.jeesite.modules.biz.service.BizMonitorHostService;
import com.jeesite.modules.app.utils.LoggerUtils;
import com.jeesite.modules.app.utils.NetworkUtils;
import com.jeesite.modules.biz.service.BizServerInfoService;
import com.jeesite.modules.app.utils.*;
import com.jeesite.modules.biz.entity.*;
import com.jeesite.modules.biz.service.*;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -38,6 +29,9 @@ public class hostJob {
@Resource
private BizDeviceInfoService deviceInfoService;
@Resource
private BizWarningAlertService bizWarningAlertService;
@Resource(name = "hostMonitorExecutor")
private ThreadPoolTaskExecutor hostMonitorExecutor;
@@ -102,6 +96,14 @@ public class hostJob {
serverInfo.setLastOnlineTime(new Date());
serverInfo.setHostId(host.getHostId());
serverInfoService.save(serverInfo);
if (serverInfo.getCpuUsage() >= 60) {
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "CPU预警", 2, serverInfo.getHostname() + "CPU预警", "当前主机CPU已超过60%,请及时处理,主机IP" + serverInfo.getIpAddress(), "业务系统", "0");
bizWarningAlertService.save(warningAlert);
}
if (serverInfo.getMemoryUsage() >= 60) {
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "内存预警", 2, serverInfo.getHostname() + "内存预警", "当前主机内存已超过60%,请及时处理,主机IP" + serverInfo.getIpAddress(), "业务系统", "0");
bizWarningAlertService.save(warningAlert);
}
} catch (Exception e) {
logger.error(e.getMessage());
}
@@ -128,6 +130,10 @@ public class hostJob {
deviceInfo.setUsageRate(diskInfo.getUsageRate());
deviceInfo.setLastOnlineTime(new Date());
deviceInfoService.save(deviceInfo);
if (deviceInfo.getUsageRate() >= 60) {
BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "磁盘预警", 2, host.getHostname() + "磁盘预警", "当前主机磁盘已超过60%,请及时处理,主机IP" + host.getIpAddress() + ",设备名称:" + deviceInfo.getDevice() + ",挂载点:" + deviceInfo.getMountPoint() + ",总容量:" + deviceInfo.getTotalSize() + ",已使用容量:" + deviceInfo.getUsedSize() + ",当前使用率:" + deviceInfo.getUsageRate() + "%", "业务系统", "0");
bizWarningAlertService.save(warningAlert);
}
} catch (Exception e) {
logger.error(e.getMessage());
}