修改页面弹窗全屏
This commit is contained in:
@@ -34,6 +34,10 @@ public class hostJob {
|
|||||||
@Resource
|
@Resource
|
||||||
private BizWarningAlertService bizWarningAlertService;
|
private BizWarningAlertService bizWarningAlertService;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BizResourceMonitorService resourceMonitorService;
|
||||||
|
|
||||||
@Resource(name = "hostMonitorExecutor")
|
@Resource(name = "hostMonitorExecutor")
|
||||||
private ThreadPoolTaskExecutor hostMonitorExecutor;
|
private ThreadPoolTaskExecutor hostMonitorExecutor;
|
||||||
private static final double CPU_RATE = Double.parseDouble(Global.getConfig("biz.host.Cpu", "60"));
|
private static final double CPU_RATE = Double.parseDouble(Global.getConfig("biz.host.Cpu", "60"));
|
||||||
@@ -96,6 +100,15 @@ public class hostJob {
|
|||||||
syncDeviceInfo(host, diskInfos);
|
syncDeviceInfo(host, diskInfos);
|
||||||
BizServerInfo bizServerInfo = new BizServerInfo();
|
BizServerInfo bizServerInfo = new BizServerInfo();
|
||||||
bizServerInfo.setHostId(host.getHostId());
|
bizServerInfo.setHostId(host.getHostId());
|
||||||
|
// 新增主机监控
|
||||||
|
BizResourceMonitor resourceMonitor = new BizResourceMonitor();
|
||||||
|
resourceMonitor.setHostName(host.getHostname());
|
||||||
|
resourceMonitor.setCpuUsage(cpuInfo.getCpuUsage());
|
||||||
|
resourceMonitor.setMemoryUsage(cpuInfo.getMemoryUsage());
|
||||||
|
resourceMonitor.setMemoryTotal(info.getMemoryTotal());
|
||||||
|
resourceMonitor.setHostId(host.getHostId());
|
||||||
|
resourceMonitorService.save(resourceMonitor);
|
||||||
|
// 更新主机监控
|
||||||
List<BizServerInfo> serverInfoList = serverInfoService.findList(bizServerInfo);
|
List<BizServerInfo> serverInfoList = serverInfoService.findList(bizServerInfo);
|
||||||
BizServerInfo serverInfo = serverInfoList.isEmpty() ? new BizServerInfo() : serverInfoList.get(0);
|
BizServerInfo serverInfo = serverInfoList.isEmpty() ? new BizServerInfo() : serverInfoList.get(0);
|
||||||
serverInfo.setUptime(info.getUptime());
|
serverInfo.setUptime(info.getUptime());
|
||||||
|
|||||||
@@ -69,14 +69,14 @@ public class MailReceiveUtils {
|
|||||||
mailAccount.getUsername(), mailAccount.getPassword());
|
mailAccount.getUsername(), mailAccount.getPassword());
|
||||||
isConnected = store.isConnected();
|
isConnected = store.isConnected();
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
logger.info("第" + (retryCount + 1) + "次连接IMAP成功:" + mailAccount.getHost());
|
logger.info("第" + (retryCount + 1) + "次连接IMAP成功:" + mailAccount.getHost(), mailAccount.getAccountName());
|
||||||
}
|
}
|
||||||
} catch (AuthenticationFailedException e) {
|
} catch (AuthenticationFailedException e) {
|
||||||
logger.error("账号/密码错误,直接返回", e);
|
logger.error("账号/密码错误,直接返回", e);
|
||||||
return receivedMailList;
|
return receivedMailList;
|
||||||
} catch (MessagingException e) {
|
} catch (MessagingException e) {
|
||||||
retryCount++;
|
retryCount++;
|
||||||
logger.error("第" + retryCount + "次连接失败:" + e.getMessage());
|
logger.error("第" + retryCount + "次连接失败:" + e.getMessage(), mailAccount.getAccountName());
|
||||||
if (retryCount >= CONNECT_RETRY_TIMES) {
|
if (retryCount >= CONNECT_RETRY_TIMES) {
|
||||||
throw new IllegalStateException("IMAP连接失败(重试3次)", e);
|
throw new IllegalStateException("IMAP连接失败(重试3次)", e);
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public class MailReceiveUtils {
|
|||||||
// 3. 筛选未读邮件
|
// 3. 筛选未读邮件
|
||||||
Message[] unreadMessages = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
|
Message[] unreadMessages = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
|
||||||
if (unreadMessages == null || unreadMessages.length == 0) {
|
if (unreadMessages == null || unreadMessages.length == 0) {
|
||||||
logger.warn("无未读邮件");
|
logger.warn("无未读邮件", mailAccount.getAccountName());
|
||||||
return receivedMailList;
|
return receivedMailList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -161,4 +162,11 @@ public class vDate {
|
|||||||
int quarter = (month - 1) / 3 + 1;
|
int quarter = (month - 1) / 3 + 1;
|
||||||
return String.format("%d-Q%d", date.getYear(), quarter);
|
return String.format("%d-Q%d", date.getYear(), quarter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Date get24Hours() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.HOUR_OF_DAY, -24);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.jeesite.modules.biz.dao;
|
||||||
|
|
||||||
|
import com.jeesite.common.dao.CrudDao;
|
||||||
|
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
||||||
|
import com.jeesite.modules.biz.entity.BizResourceMonitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器CPU和内存使用率监控表DAO接口
|
||||||
|
* @author gaoxq
|
||||||
|
* @version 2026-02-08
|
||||||
|
*/
|
||||||
|
@MyBatisDao(dataSourceName="work")
|
||||||
|
public interface BizResourceMonitorDao extends CrudDao<BizResourceMonitor> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.jeesite.modules.biz.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.jeesite.common.mybatis.annotation.JoinTable;
|
||||||
|
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
|
import com.jeesite.common.entity.DataEntity;
|
||||||
|
import com.jeesite.common.mybatis.annotation.Column;
|
||||||
|
import com.jeesite.common.mybatis.annotation.Table;
|
||||||
|
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器CPU和内存使用率监控表Entity
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @version 2026-02-08
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Table(name = "biz_resource_monitor", alias = "a", label = "服务器CPU和内存使用率监控表信息", columns = {
|
||||||
|
@Column(name = "create_time", attrName = "createTime", label = "数据采集时间", queryType = QueryType.GTE),
|
||||||
|
@Column(name = "id", attrName = "id", label = "主键ID", isPK = true),
|
||||||
|
@Column(name = "host_name", attrName = "hostName", label = "服务器主机名/IP地址", isUpdate = false, isQuery = false),
|
||||||
|
@Column(name = "cpu_usage", attrName = "cpuUsage", label = "CPU使用率", comment = "CPU使用率(%),取值0-100", isUpdate = false, isQuery = false, isUpdateForce = true),
|
||||||
|
@Column(name = "memory_usage", attrName = "memoryUsage", label = "内存使用率", comment = "内存使用率(%),取值0-100", isUpdate = false, isQuery = false, isUpdateForce = true),
|
||||||
|
@Column(name = "memory_total", attrName = "memoryTotal", label = "服务器总内存大小", comment = "服务器总内存大小(字节)", isUpdate = false, isQuery = false, isUpdateForce = true),
|
||||||
|
@Column(name = "hour_time", attrName = "hourTime", label = "时间", comment = "时间", isUpdate = false, isQuery = false, isUpdateForce = true),
|
||||||
|
@Column(name = "host_id", attrName = "hostId", label = "host_id", isUpdate = false),
|
||||||
|
}, orderBy = "a.create_time ASC"
|
||||||
|
)
|
||||||
|
@Data
|
||||||
|
public class BizResourceMonitor extends DataEntity<BizResourceMonitor> implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private Date createTime; // 数据采集时间
|
||||||
|
private String id; // 主键ID
|
||||||
|
private String hostName; // 服务器主机名/IP地址
|
||||||
|
private Double cpuUsage; // CPU使用率(%),取值0-100
|
||||||
|
private Double memoryUsage; // 内存使用率(%),取值0-100
|
||||||
|
private String memoryTotal; // 服务器总内存大小(字节)
|
||||||
|
private String hostId; // host_id
|
||||||
|
private String hourTime;
|
||||||
|
|
||||||
|
public BizResourceMonitor() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizResourceMonitor(String id) {
|
||||||
|
super(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package com.jeesite.modules.biz.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.jeesite.common.entity.Page;
|
||||||
|
import com.jeesite.common.service.CrudService;
|
||||||
|
import com.jeesite.modules.biz.entity.BizResourceMonitor;
|
||||||
|
import com.jeesite.modules.biz.dao.BizResourceMonitorDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器CPU和内存使用率监控表Service
|
||||||
|
* @author gaoxq
|
||||||
|
* @version 2026-02-08
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BizResourceMonitorService extends CrudService<BizResourceMonitorDao, BizResourceMonitor> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单条数据
|
||||||
|
* @param bizResourceMonitor 主键
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BizResourceMonitor get(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
return super.get(bizResourceMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询分页数据
|
||||||
|
* @param bizResourceMonitor 查询条件
|
||||||
|
* @param bizResourceMonitor page 分页对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Page<BizResourceMonitor> findPage(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
return super.findPage(bizResourceMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表数据
|
||||||
|
* @param bizResourceMonitor 查询条件
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BizResourceMonitor> findList(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
return super.findList(bizResourceMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存数据(插入或更新)
|
||||||
|
* @param bizResourceMonitor 数据对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void save(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
super.save(bizResourceMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新状态
|
||||||
|
* @param bizResourceMonitor 数据对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateStatus(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
super.updateStatus(bizResourceMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
* @param bizResourceMonitor 数据对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void delete(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
super.delete(bizResourceMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package com.jeesite.modules.biz.web;
|
||||||
|
|
||||||
|
import com.jeesite.modules.app.utils.vDate;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.jeesite.common.config.Global;
|
||||||
|
import com.jeesite.common.entity.Page;
|
||||||
|
import com.jeesite.common.web.BaseController;
|
||||||
|
import com.jeesite.modules.biz.entity.BizResourceMonitor;
|
||||||
|
import com.jeesite.modules.biz.service.BizResourceMonitorService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器CPU和内存使用率监控表Controller
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @version 2026-02-08
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "${adminPath}/biz/resourceMonitor")
|
||||||
|
public class BizResourceMonitorController extends BaseController {
|
||||||
|
|
||||||
|
private final BizResourceMonitorService bizResourceMonitorService;
|
||||||
|
|
||||||
|
public BizResourceMonitorController(BizResourceMonitorService bizResourceMonitorService) {
|
||||||
|
this.bizResourceMonitorService = bizResourceMonitorService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据
|
||||||
|
*/
|
||||||
|
@ModelAttribute
|
||||||
|
public BizResourceMonitor get(Long tid, boolean isNewRecord) {
|
||||||
|
return bizResourceMonitorService.get(tid, isNewRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("biz:resourceMonitor:view")
|
||||||
|
@RequestMapping(value = {"list", ""})
|
||||||
|
public String list(BizResourceMonitor bizResourceMonitor, Model model) {
|
||||||
|
model.addAttribute("bizResourceMonitor", bizResourceMonitor);
|
||||||
|
return "modules/biz/bizResourceMonitorList";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("biz:resourceMonitor:view")
|
||||||
|
@RequestMapping(value = "listData")
|
||||||
|
@ResponseBody
|
||||||
|
public Page<BizResourceMonitor> listData(BizResourceMonitor bizResourceMonitor, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
bizResourceMonitor.setPage(new Page<>(request, response));
|
||||||
|
Page<BizResourceMonitor> page = bizResourceMonitorService.findPage(bizResourceMonitor);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看编辑表单
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("biz:resourceMonitor:view")
|
||||||
|
@RequestMapping(value = "form")
|
||||||
|
public String form(BizResourceMonitor bizResourceMonitor, Model model) {
|
||||||
|
model.addAttribute("bizResourceMonitor", bizResourceMonitor);
|
||||||
|
return "modules/biz/bizResourceMonitorForm";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("biz:resourceMonitor:edit")
|
||||||
|
@PostMapping(value = "save")
|
||||||
|
@ResponseBody
|
||||||
|
public String save(@Validated BizResourceMonitor bizResourceMonitor) {
|
||||||
|
bizResourceMonitorService.save(bizResourceMonitor);
|
||||||
|
return renderResult(Global.TRUE, text("保存服务器CPU和内存使用率监控表成功!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("biz:resourceMonitor:edit")
|
||||||
|
@RequestMapping(value = "delete")
|
||||||
|
@ResponseBody
|
||||||
|
public String delete(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
bizResourceMonitorService.delete(bizResourceMonitor);
|
||||||
|
return renderResult(Global.TRUE, text("删除服务器CPU和内存使用率监控表成功!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "listAll")
|
||||||
|
@ResponseBody
|
||||||
|
public List<BizResourceMonitor> listAll(BizResourceMonitor bizResourceMonitor) {
|
||||||
|
bizResourceMonitor.setCreateTime(vDate.get24Hours());
|
||||||
|
return bizResourceMonitorService.findList(bizResourceMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user