From 118a1bd7f1c3d32eb41646b51d4212248ef427d3 Mon Sep 17 00:00:00 2001 From: gaoxq <376340421@qq.com> Date: Sun, 7 Dec 2025 21:33:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A2=84=E8=AD=A6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jeesite/modules/app/Job/hostJob.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/web-api/src/main/java/com/jeesite/modules/app/Job/hostJob.java b/web-api/src/main/java/com/jeesite/modules/app/Job/hostJob.java index 2d33dca1..52798ba8 100644 --- a/web-api/src/main/java/com/jeesite/modules/app/Job/hostJob.java +++ b/web-api/src/main/java/com/jeesite/modules/app/Job/hostJob.java @@ -1,5 +1,6 @@ package com.jeesite.modules.app.Job; +import com.jeesite.common.config.Global; import com.jeesite.modules.app.dao.info.CpuInfo; import com.jeesite.modules.app.dao.info.DiskInfo; import com.jeesite.modules.app.dao.info.ServerInfo; @@ -34,8 +35,9 @@ public class hostJob { @Resource(name = "hostMonitorExecutor") private ThreadPoolTaskExecutor hostMonitorExecutor; - - + private static final double CPU_RATE = Double.parseDouble(Global.getConfig("biz.host.Cpu", "60")); + private static final double MEM_RATE = Double.parseDouble(Global.getConfig("biz.host.Memory", "60")); + private static final double DISK_RATE = Double.parseDouble(Global.getConfig("biz.host.Disk", "60")); private static final LoggerUtils logger = LoggerUtils.getInstance(); /** @@ -96,12 +98,12 @@ 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"); + if (serverInfo.getCpuUsage() >= CPU_RATE) { + BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "CPU预警", 2, serverInfo.getHostname() + "CPU预警", "当前主机CPU已超过" + CPU_RATE + "%,请及时处理,主机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"); + if (serverInfo.getMemoryUsage() >= MEM_RATE) { + BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "内存预警", 2, serverInfo.getHostname() + "内存预警", "当前主机内存已超过" + MEM_RATE + "%,请及时处理,主机IP:" + serverInfo.getIpAddress(), "业务系统", "0"); bizWarningAlertService.save(warningAlert); } } catch (Exception e) { @@ -130,8 +132,8 @@ 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"); + if (deviceInfo.getUsageRate() >= DISK_RATE) { + BizWarningAlert warningAlert = new BizWarningAlert("ZJ_" + KeyUtil.ObjKey(12, 2), "磁盘预警", 2, host.getHostname() + "磁盘预警", "当前主机磁盘已超过" + DISK_RATE + "%,请及时处理,主机IP:" + host.getIpAddress() + ",设备名称:" + deviceInfo.getDevice() + ",挂载点:" + deviceInfo.getMountPoint() + ",总容量:" + deviceInfo.getTotalSize() + ",已使用容量:" + deviceInfo.getUsedSize() + ",当前使用率:" + deviceInfo.getUsageRate() + "%", "业务系统", "0"); bizWarningAlertService.save(warningAlert); } } catch (Exception e) {