Merge remote-tracking branch 'xiaoguangbin/station' into mdc
This commit is contained in:
commit
5e9642de91
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.common.api.dto.message;
|
package org.jeecg.common.api.dto.message;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -11,6 +12,7 @@ import java.util.Map;
|
||||||
* @author: jeecg-boot
|
* @author: jeecg-boot
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class MessageDTO implements Serializable {
|
public class MessageDTO implements Serializable {
|
||||||
private static final long serialVersionUID = -5690444483968058442L;
|
private static final long serialVersionUID = -5690444483968058442L;
|
||||||
|
|
||||||
|
@ -113,6 +115,12 @@ public class MessageDTO implements Serializable {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessageDTO(String title, String template, String toUser) {
|
||||||
|
this.title = title;
|
||||||
|
this.templateCode = template;
|
||||||
|
this.toUser = toUser;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMarkdown() {
|
public boolean isMarkdown() {
|
||||||
return this.isMarkdown;
|
return this.isMarkdown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.common.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.modules.base.dto.ConnR;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||||
|
|
||||||
|
@ -27,6 +28,14 @@ public class JDBCUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JdbcTemplate template(String url, String user, String pass){
|
||||||
|
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
|
dataSource.setUrl(url);
|
||||||
|
dataSource.setUsername(user);
|
||||||
|
dataSource.setPassword(pass);
|
||||||
|
return new JdbcTemplate(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isConnection(String url, String driver, String user, String pass){
|
public static boolean isConnection(String url, String driver, String user, String pass){
|
||||||
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
dataSource.setUrl(url);
|
dataSource.setUrl(url);
|
||||||
|
@ -37,11 +46,25 @@ public class JDBCUtil {
|
||||||
try (Connection connection = dataSource.getConnection()) {
|
try (Connection connection = dataSource.getConnection()) {
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("JDBCUtil.isConnection():数据源["+ url +"]连接失败: {}", e.getMessage());
|
log.error("数据源["+ url +"]连接失败: {}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ConnR isConnection(String url, String user, String pass){
|
||||||
|
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
|
dataSource.setUrl(url);
|
||||||
|
dataSource.setUsername(user);
|
||||||
|
dataSource.setPassword(pass);
|
||||||
|
// try-with-resources 无须显式关闭Connection资源
|
||||||
|
try (Connection connection = dataSource.getConnection()) {
|
||||||
|
return new ConnR().setConn(true);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// String message = String.format("[xxx数据源]连接失败: %s", e.getMessage());
|
||||||
|
return new ConnR().setInfo(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isConnection(DriverManagerDataSource dataSource){
|
public static boolean isConnection(DriverManagerDataSource dataSource){
|
||||||
// try-with-resources 无须显式关闭Connection资源
|
// try-with-resources 无须显式关闭Connection资源
|
||||||
try (Connection connection = dataSource.getConnection()) {
|
try (Connection connection = dataSource.getConnection()) {
|
||||||
|
@ -49,7 +72,7 @@ public class JDBCUtil {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String url = "--";
|
String url = "--";
|
||||||
if (ObjectUtil.isNotNull(dataSource)) url = dataSource.getUrl();
|
if (ObjectUtil.isNotNull(dataSource)) url = dataSource.getUrl();
|
||||||
log.error("JDBCUtil.isConnection():数据源["+ url +"]连接失败: {}", e.getMessage());
|
log.error("数据源["+ url +"]连接失败: {}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.jeecg.modules.base.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class ConnR {
|
||||||
|
|
||||||
|
private boolean isConn;
|
||||||
|
|
||||||
|
private String info;
|
||||||
|
}
|
|
@ -1,58 +0,0 @@
|
||||||
package org.jeecg.modules;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.jeecg.common.constant.RedisConstant;
|
|
||||||
import org.jeecg.common.util.JDBCUtil;
|
|
||||||
import org.jeecg.common.util.RedisUtil;
|
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
|
||||||
import org.jeecg.modules.base.entity.postgre.SysDatabase;
|
|
||||||
import org.jeecg.modules.service.ISysDatabaseService;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class DatabaseStatusManager {
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
DbStatusThread dbStatusThread = new DbStatusThread();
|
|
||||||
dbStatusThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DbStatusThread extends Thread{
|
|
||||||
|
|
||||||
private long sleepTime;
|
|
||||||
|
|
||||||
private ISysDatabaseService databaseService;
|
|
||||||
|
|
||||||
private DbStatusThread(){
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
databaseService.status2Redis();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("DatabaseStatusManager.run()异常: {}", e.getMessage());
|
|
||||||
}finally {
|
|
||||||
try {
|
|
||||||
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error("DatabaseStatusManager.sleep()异常: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(){
|
|
||||||
sleepTime = 5 * 1000; // 睡眠时间5s
|
|
||||||
databaseService = SpringContextUtils.getBean(ISysDatabaseService.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,36 +17,10 @@ import java.util.concurrent.*;
|
||||||
public class Demo {
|
public class Demo {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
EmailServiceManager manager = EmailServiceManager.getInstance();
|
Executor executor = Executors.newFixedThreadPool(3);
|
||||||
SysEmail email = new SysEmail();
|
for (int i = 0; i < 3; i++) {
|
||||||
// Get
|
CompletableFuture.runAsync(Demo::test2, executor);
|
||||||
email.setEmailServerAddress("imap.qiye.163.com");
|
}
|
||||||
email.setUsername("cnndc.rn.ng@ndc.org.cn");
|
|
||||||
email.setPassword("cnndc66367220");
|
|
||||||
email.setPort(993);
|
|
||||||
|
|
||||||
/*email.setEmailServerAddress("imap.exmail.qq.com");
|
|
||||||
email.setUsername("xiaoguangbin@hivekion.com");
|
|
||||||
email.setPassword("Ans9sLY4kVnux7ai");
|
|
||||||
email.setPort(143);
|
|
||||||
|
|
||||||
// Send
|
|
||||||
email.setEmailServerAddress("smtphz.qiye.163.com");
|
|
||||||
email.setUsername("cnndc.rn.ng@ndc.org.cn");
|
|
||||||
email.setPassword("cnndc66367220");
|
|
||||||
email.setPort(465);
|
|
||||||
|
|
||||||
email.setEmailServerAddress("smtp.163.com");
|
|
||||||
email.setUsername("armd_auto@163.com");
|
|
||||||
email.setPassword("NVOWHFOGWVOFILVV");
|
|
||||||
email.setPort(25);*/
|
|
||||||
|
|
||||||
/*manager.init(email);
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
System.out.println(manager.canReceiveSSL() || manager.canReceive());
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
System.out.println("连接耗时: " + (end - start) / 1000 + "s");*/
|
|
||||||
test();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void test(){
|
public static void test(){
|
||||||
|
@ -86,4 +60,8 @@ public class Demo {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void test2(){
|
||||||
|
throw new RuntimeException("测试异常");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
package org.jeecg.modules;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.jeecg.common.constant.RedisConstant;
|
|
||||||
import org.jeecg.common.util.EmailUtil;
|
|
||||||
import org.jeecg.common.util.JDBCUtil;
|
|
||||||
import org.jeecg.common.util.RedisUtil;
|
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
|
||||||
import org.jeecg.modules.base.entity.postgre.SysDatabase;
|
|
||||||
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
|
||||||
import org.jeecg.modules.service.ISysDatabaseService;
|
|
||||||
import org.jeecg.modules.service.ISysEmailService;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class EmailStatusManager {
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
EmailStatusThread emailStatusThread = new EmailStatusThread();
|
|
||||||
emailStatusThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class EmailStatusThread extends Thread{
|
|
||||||
|
|
||||||
private long sleepTime;
|
|
||||||
|
|
||||||
private ISysEmailService emailService;
|
|
||||||
|
|
||||||
private EmailStatusThread(){
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (true){
|
|
||||||
try {
|
|
||||||
emailService.status2Redis();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("EmailStatusManager.run()异常: {}", e.getMessage());
|
|
||||||
}finally {
|
|
||||||
try {
|
|
||||||
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error("EmailStatusManager.sleep()异常: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(){
|
|
||||||
sleepTime = 5 * 60 * 1000; // 睡眠时间5min
|
|
||||||
emailService = SpringContextUtils.getBean(ISysEmailService.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package org.jeecg.modules;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
|
||||||
import org.jeecg.modules.service.ISysDatabaseService;
|
|
||||||
import org.jeecg.modules.service.ISysServerService;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class ServerStatusManager {
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
ServerStatusThread serverStatusThread = new ServerStatusThread();
|
|
||||||
serverStatusThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ServerStatusThread extends Thread{
|
|
||||||
|
|
||||||
private long sleepTime;
|
|
||||||
|
|
||||||
private ISysServerService serverService;
|
|
||||||
|
|
||||||
private ServerStatusThread(){
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
serverService.status2Redis();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("ServerStatusManager.run()异常: {}", e.getMessage());
|
|
||||||
}finally {
|
|
||||||
try {
|
|
||||||
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error("ServerStatusManager.sleep()异常: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(){
|
|
||||||
sleepTime = 5 * 1000; // 睡眠时间5s
|
|
||||||
serverService = SpringContextUtils.getBean(ISysServerService.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,9 +28,12 @@ import org.jeecg.modules.qiyeEmail.base.InstanceSDK;
|
||||||
import org.jeecg.modules.qiyeEmail.base.RParam;
|
import org.jeecg.modules.qiyeEmail.base.RParam;
|
||||||
import org.jeecg.modules.qiyeEmail.base.dto.AccountInfo;
|
import org.jeecg.modules.qiyeEmail.base.dto.AccountInfo;
|
||||||
import org.jeecg.modules.qiyeEmail.service.Account;
|
import org.jeecg.modules.qiyeEmail.service.Account;
|
||||||
|
import org.jeecg.modules.service.IAlarmRuleService;
|
||||||
|
import org.jeecg.modules.service.ISysDatabaseService;
|
||||||
import org.jeecg.modules.service.ISysEmailService;
|
import org.jeecg.modules.service.ISysEmailService;
|
||||||
import org.jeecg.modules.service.ISysServerService;
|
import org.jeecg.modules.service.ISysServerService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -55,16 +58,21 @@ public class StatusAspect {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysServerService serverService;
|
private ISysServerService serverService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDatabaseService databaseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAlarmRuleService alarmRuleService;
|
||||||
|
|
||||||
// 新增|修改邮箱服务器信息后 异步更新其状态信息
|
// 新增|修改邮箱服务器信息后 异步更新其状态信息
|
||||||
@Async
|
@Async
|
||||||
@AfterReturning("execution(* org.jeecg.modules.service.impl.SysEmailServiceImpl.update(..)) || " +
|
@AfterReturning("execution(* org.jeecg.modules.service.impl.SysEmailServiceImpl.update(..)) || " +
|
||||||
"execution(* org.jeecg.modules.service.impl.SysEmailServiceImpl.create(..))")
|
"execution(* org.jeecg.modules.service.impl.SysEmailServiceImpl.create(..))")
|
||||||
public void updateEamilStatus(JoinPoint point){
|
public void updateEamilStatus(JoinPoint point){
|
||||||
Object[] args = point.getArgs();
|
Object[] args = point.getArgs();
|
||||||
if (ArrayUtil.length(args) > 0){
|
if (ArrayUtil.length(args) == 0) return;
|
||||||
SysEmail email = (SysEmail) args[0];
|
SysEmail email = (SysEmail) args[0];
|
||||||
emailService.status2Redis(email);
|
emailService.status2Redis(email);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -75,18 +83,9 @@ public class StatusAspect {
|
||||||
"execution(* org.jeecg.modules.service.impl.SysDatabaseServiceImpl.create(..))")
|
"execution(* org.jeecg.modules.service.impl.SysDatabaseServiceImpl.create(..))")
|
||||||
public void updateDatabaseStatus(JoinPoint point){
|
public void updateDatabaseStatus(JoinPoint point){
|
||||||
Object[] args = point.getArgs();
|
Object[] args = point.getArgs();
|
||||||
if (ArrayUtil.length(args) > 0) {
|
if (ArrayUtil.length(args) == 0) return;
|
||||||
SysDatabase database = (SysDatabase) args[0];
|
SysDatabase database = (SysDatabase) args[0];
|
||||||
String id = database.getId();
|
databaseService.status2Redis(database);
|
||||||
String name = database.getName();
|
|
||||||
String dbUrl = database.getDbUrl();
|
|
||||||
String dbDriver = database.getDbDriver();
|
|
||||||
String dbUsername = database.getDbUsername();
|
|
||||||
String dbPassword = database.getDbPassword();
|
|
||||||
boolean isConn = JDBCUtil.isConnection(dbUrl, dbDriver, dbUsername, dbPassword);
|
|
||||||
String statusKey = RedisConstant.DATABASE_STATUS;
|
|
||||||
redisUtil.hset(statusKey, id, new NameValue(name, isConn));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,35 +97,47 @@ public class StatusAspect {
|
||||||
"execution(* org.jeecg.modules.service.impl.SysServerServiceImpl.create(..))")
|
"execution(* org.jeecg.modules.service.impl.SysServerServiceImpl.create(..))")
|
||||||
public void updateServerStatus(JoinPoint point){
|
public void updateServerStatus(JoinPoint point){
|
||||||
Object[] args = point.getArgs();
|
Object[] args = point.getArgs();
|
||||||
if (ArrayUtil.length(args) > 0) {
|
if (ArrayUtil.length(args) == 0) return;
|
||||||
String key = RedisConstant.SERVER_STATUS;
|
String key = RedisConstant.SERVER_STATUS;
|
||||||
String status = ServerStatus.UNKNOWN.getValue(); // 初始值为-1
|
String status = ServerStatus.UNKNOWN.getValue(); // 初始值为-1
|
||||||
SysServer server = (SysServer) args[0];
|
SysServer server = (SysServer) args[0];
|
||||||
String id = server.getId();
|
String id = server.getId();
|
||||||
String name = server.getName();
|
String name = server.getName();
|
||||||
String ipAddress = server.getIpAddress();
|
String ipAddress = server.getIpAddress();
|
||||||
try {
|
try {
|
||||||
String token = ManageUtil.getToken();
|
String token = ManageUtil.getToken();
|
||||||
Servers servers = monitorAlarm.listApp(ipAddress, MonitorConstant.SERVER_APP, token).getResult();
|
Servers servers = monitorAlarm.listApp(ipAddress, MonitorConstant.SERVER_APP, token).getResult();
|
||||||
// 获取所有监控主机信息
|
// 获取所有监控主机信息
|
||||||
List<Host> hosts = servers.getRecords();
|
List<Host> hosts = servers.getRecords();
|
||||||
for (Host host : hosts) {
|
for (Host host : hosts) {
|
||||||
String code = host.getCode();
|
String code = host.getCode();
|
||||||
if (!StrUtil.equals(ipAddress, code))
|
if (!StrUtil.equals(ipAddress, code))
|
||||||
continue;
|
continue;
|
||||||
server.setHostId(host.getHostId());
|
server.setHostId(host.getHostId());
|
||||||
status = host.getStatus();
|
status = host.getStatus();
|
||||||
}
|
|
||||||
// 更新该服务器状态信息
|
|
||||||
redisUtil.hset(key, id, new NameValue(name, status));
|
|
||||||
// 更新该服务器的HostId
|
|
||||||
serverService.updateById(server);
|
|
||||||
}catch (FeignException.Unauthorized e){
|
|
||||||
ManageUtil.refreshToken();
|
|
||||||
log.warn("向运管系统查询Hosts信息异常: Token失效,已刷新Token");
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error("向运管系统查询Hosts信息异常: {}", e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
// 更新该服务器状态信息
|
||||||
|
redisUtil.hset(key, id, new NameValue(name, status));
|
||||||
|
// 更新该服务器的HostId
|
||||||
|
serverService.updateById(server);
|
||||||
|
}catch (FeignException.Unauthorized e){
|
||||||
|
ManageUtil.refreshToken();
|
||||||
|
log.warn("向运管系统查询Hosts信息异常: Token失效,已刷新Token");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("向运管系统查询Hosts信息异常: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 删除Email|Database|Server时 同步删除Redis和数据库中相关联的预警规则
|
||||||
|
* */
|
||||||
|
@Async
|
||||||
|
@AfterReturning("execution(* org.jeecg.modules.service.impl.SysServerServiceImpl.deleteById(..)) ||" +
|
||||||
|
"execution(* org.jeecg.modules.service.impl.SysEmailServiceImpl.deleteById(..)) || " +
|
||||||
|
"execution(* org.jeecg.modules.service.impl.SysDatabaseServiceImpl.deleteById(..))")
|
||||||
|
public void deleteRules(JoinPoint point){
|
||||||
|
Object[] args = point.getArgs();
|
||||||
|
if (ArrayUtil.length(args) > 0)
|
||||||
|
alarmRuleService.deleteBySourceId((String) args[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package org.jeecg.modules.feignclient;
|
package org.jeecg.modules.feignclient;
|
||||||
|
|
||||||
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.vo.DictModel;
|
import org.jeecg.common.system.vo.DictModel;
|
||||||
import org.jeecg.modules.base.entity.postgre.SysUser;
|
import org.jeecg.modules.base.entity.postgre.SysUser;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -26,6 +25,9 @@ public interface SystemClient {
|
||||||
@RequestParam String groupId,
|
@RequestParam String groupId,
|
||||||
@RequestParam String notific);
|
@RequestParam String notific);
|
||||||
|
|
||||||
|
@PostMapping("/sys/sendMessage/sendTo")
|
||||||
|
void sendTo(@RequestBody MessageDTO messageDTO);
|
||||||
|
|
||||||
/* SysDictController下相关接口 */
|
/* SysDictController下相关接口 */
|
||||||
@GetMapping("/sys/dict/getItems")
|
@GetMapping("/sys/dict/getItems")
|
||||||
List<DictModel> getItems(@RequestParam String dictCode);
|
List<DictModel> getItems(@RequestParam String dictCode);
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
package org.jeecg.modules.idc;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
|
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||||
|
import org.jeecg.common.constant.enums.MessageTypeEnum;
|
||||||
|
import org.jeecg.common.util.JDBCUtil;
|
||||||
|
import org.jeecg.modules.base.dto.ConnR;
|
||||||
|
import org.jeecg.modules.feignclient.SystemClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class IDCDataFetch {
|
||||||
|
|
||||||
|
@Value("${inland.url}")
|
||||||
|
private String urlM; // 本地数据源url,即为主数据源
|
||||||
|
|
||||||
|
@Value("${inland.username}")
|
||||||
|
private String usernameM;
|
||||||
|
|
||||||
|
@Value("${inland.password}")
|
||||||
|
private String passwordM;
|
||||||
|
|
||||||
|
@Value("${oversea.url}")
|
||||||
|
private String urlS; // 国外数据源url,即为从数据源
|
||||||
|
|
||||||
|
@Value("${oversea.username}")
|
||||||
|
private String usernameS;
|
||||||
|
|
||||||
|
@Value("${oversea.password}")
|
||||||
|
private String passwordS;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemClient systemClient;
|
||||||
|
|
||||||
|
// 定时拾取IDC数据
|
||||||
|
@Scheduled(fixedDelayString = "${request-interval}", timeUnit = TimeUnit.SECONDS)
|
||||||
|
public void fetch() {
|
||||||
|
JdbcTemplate template;
|
||||||
|
MessageDTO messageDTO = new MessageDTO("IDC数据源异常", "IDC_Datasource_Status", "admin");
|
||||||
|
messageDTO.setType(MessageTypeEnum.XT.getType());
|
||||||
|
ConnR connR = JDBCUtil.isConnection(urlM, usernameM, passwordM);
|
||||||
|
if (connR.isConn()) {
|
||||||
|
try {
|
||||||
|
template = JDBCUtil.template(urlM, usernameM, passwordM);
|
||||||
|
// 查询IDC Data
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[inland数据源]IDC数据处理异常: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UserTokenContext.setToken(getTempToken());
|
||||||
|
// 对发送警告消息时可能出现的异常进行捕获(503) 防止影响后续代码执行
|
||||||
|
try {
|
||||||
|
// 给管理员发送预警信息
|
||||||
|
/*String message = StrUtil.replace(connR.getInfo(), "xxx", "inland");
|
||||||
|
messageDTO.setContent(message);*/
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put("datasource", "inland(测试)");
|
||||||
|
data.put("info", connR.getInfo());
|
||||||
|
messageDTO.setData(data);
|
||||||
|
systemClient.sendTo(messageDTO);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("发送inland数据源异常信息失败: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
// 使用备用数据源
|
||||||
|
connR = JDBCUtil.isConnection(urlS, usernameS, passwordS);
|
||||||
|
if (connR.isConn()) {
|
||||||
|
try {
|
||||||
|
template = JDBCUtil.template(urlS, usernameS, passwordS);
|
||||||
|
// 查询IDC Data
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[oversea数据源]IDC数据处理异常: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 给管理员发送预警信息
|
||||||
|
String message = StrUtil.replace(connR.getInfo(), "xxx", "oversea");
|
||||||
|
messageDTO.setContent(message);
|
||||||
|
systemClient.sendTo(messageDTO);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("发送oversea数据源异常信息失败: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
UserTokenContext.remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,5 +35,7 @@ public interface ISysDatabaseService extends IService<SysDatabase> {
|
||||||
|
|
||||||
void status2Redis();
|
void status2Redis();
|
||||||
|
|
||||||
|
void status2Redis(SysDatabase database);
|
||||||
|
|
||||||
String getNameById(String id);
|
String getNameById(String id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,14 @@ import org.jeecg.modules.service.ISysDatabaseService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.jeecg.common.constant.enums.DbType.*;
|
import static org.jeecg.common.constant.enums.DbType.*;
|
||||||
|
@ -181,9 +183,6 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
||||||
boolean success = removeById(id);
|
boolean success = removeById(id);
|
||||||
if(success) {
|
if(success) {
|
||||||
delStatus(id);
|
delStatus(id);
|
||||||
// 同步删除Redis和数据库中的预警规则
|
|
||||||
IAlarmRuleService alarmRuleService = SpringContextUtils.getBean(IAlarmRuleService.class);
|
|
||||||
alarmRuleService.deleteBySourceId(id);
|
|
||||||
return Result.OK(Prompt.DELETE_SUCC);
|
return Result.OK(Prompt.DELETE_SUCC);
|
||||||
}
|
}
|
||||||
return Result.error(Prompt.DELETE_ERR);
|
return Result.error(Prompt.DELETE_ERR);
|
||||||
|
@ -311,23 +310,26 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Scheduled(fixedDelay = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
public void status2Redis() {
|
public void status2Redis() {
|
||||||
// 获取所有配置的数据源
|
// 获取所有配置的数据源
|
||||||
List<SysDatabase> databases = list();
|
List<SysDatabase> databases = list();
|
||||||
Map<String, Object> statusMap = new HashMap<>();
|
|
||||||
for (SysDatabase database : databases) {
|
for (SysDatabase database : databases) {
|
||||||
String id = database.getId();
|
this.status2Redis(database);
|
||||||
String name = database.getName();
|
|
||||||
String dbUrl = database.getDbUrl();
|
|
||||||
String dbDriver = database.getDbDriver();
|
|
||||||
String dbUsername = database.getDbUsername();
|
|
||||||
String dbPassword = database.getDbPassword();
|
|
||||||
boolean isConn = JDBCUtil.isConnection(dbUrl, dbDriver, dbUsername, dbPassword);
|
|
||||||
statusMap.put(id, new NameValue(name, isConn));
|
|
||||||
}
|
}
|
||||||
// 将数据源连接状态更新到reids
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void status2Redis(SysDatabase database) {
|
||||||
String statusKey = RedisConstant.DATABASE_STATUS;
|
String statusKey = RedisConstant.DATABASE_STATUS;
|
||||||
redisUtil.hmset(statusKey, statusMap);
|
String id = database.getId();
|
||||||
|
String name = database.getName();
|
||||||
|
String dbUrl = database.getDbUrl();
|
||||||
|
String dbDriver = database.getDbDriver();
|
||||||
|
String dbUsername = database.getDbUsername();
|
||||||
|
String dbPassword = database.getDbPassword();
|
||||||
|
boolean isConn = JDBCUtil.isConnection(dbUrl, dbDriver, dbUsername, dbPassword);
|
||||||
|
redisUtil.hset(statusKey, id, new NameValue(name, isConn));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.jeecg.modules.service.IAlarmRuleService;
|
||||||
import org.jeecg.modules.service.ISysEmailService;
|
import org.jeecg.modules.service.ISysEmailService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.jeecg.modules.base.enums.Enabled.ENABLED;
|
import static org.jeecg.modules.base.enums.Enabled.ENABLED;
|
||||||
|
@ -164,9 +166,6 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
||||||
boolean success = this.removeById(id);
|
boolean success = this.removeById(id);
|
||||||
if (success){
|
if (success){
|
||||||
delStatus(id);
|
delStatus(id);
|
||||||
// 同步删除Redis和数据库中的预警规则
|
|
||||||
IAlarmRuleService alarmRuleService = SpringContextUtils.getBean(IAlarmRuleService.class);
|
|
||||||
alarmRuleService.deleteBySourceId(id);
|
|
||||||
return Result.OK(Prompt.DELETE_SUCC);
|
return Result.OK(Prompt.DELETE_SUCC);
|
||||||
}
|
}
|
||||||
return Result.error(Prompt.DELETE_ERR);
|
return Result.error(Prompt.DELETE_ERR);
|
||||||
|
@ -218,12 +217,13 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Scheduled(fixedDelay = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
public void status2Redis() {
|
public void status2Redis() {
|
||||||
// 获取所有配置的邮箱服务器
|
// 获取所有配置的邮箱服务器
|
||||||
List<SysEmail> emails = list();
|
List<SysEmail> emails = list();
|
||||||
// 使用并发 更新邮箱状态及用量
|
// 使用并发 更新邮箱状态及用量
|
||||||
for (SysEmail email : emails) {
|
for (SysEmail email : emails) {
|
||||||
CompletableFuture.runAsync(() -> status2Redis(email));
|
CompletableFuture.runAsync(() -> this.status2Redis(email));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.jeecg.common.util.NumUtil;
|
||||||
import org.jeecg.common.util.PageUtil;
|
import org.jeecg.common.util.PageUtil;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
import org.jeecg.common.util.RedisUtil;
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.modules.ServerStatusManager;
|
|
||||||
import org.jeecg.modules.base.dto.*;
|
import org.jeecg.modules.base.dto.*;
|
||||||
import org.jeecg.modules.base.entity.monitor.Host;
|
import org.jeecg.modules.base.entity.monitor.Host;
|
||||||
import org.jeecg.modules.base.entity.monitor.Item;
|
import org.jeecg.modules.base.entity.monitor.Item;
|
||||||
|
@ -38,6 +37,7 @@ import org.jeecg.modules.mapper.SysServerMapper;
|
||||||
import org.jeecg.modules.service.IAlarmRuleService;
|
import org.jeecg.modules.service.IAlarmRuleService;
|
||||||
import org.jeecg.modules.service.ISysServerService;
|
import org.jeecg.modules.service.ISysServerService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -188,9 +188,6 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
||||||
boolean success = removeById(id);
|
boolean success = removeById(id);
|
||||||
if(success) {
|
if(success) {
|
||||||
delStatus(id);
|
delStatus(id);
|
||||||
// 同步删除Redis和数据库中的预警规则
|
|
||||||
IAlarmRuleService alarmRuleService = SpringContextUtils.getBean(IAlarmRuleService.class);
|
|
||||||
alarmRuleService.deleteBySourceId(id);
|
|
||||||
return Result.OK(Prompt.DELETE_SUCC);
|
return Result.OK(Prompt.DELETE_SUCC);
|
||||||
}
|
}
|
||||||
return Result.error(Prompt.DELETE_ERR);
|
return Result.error(Prompt.DELETE_ERR);
|
||||||
|
@ -265,31 +262,59 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
||||||
String status = host.getStatus();
|
String status = host.getStatus();
|
||||||
boolean online = StrUtil.equals(status, ServerStatus.ON.getValue());
|
boolean online = StrUtil.equals(status, ServerStatus.ON.getValue());
|
||||||
Map<String, Item> items = host.getItems();
|
Map<String, Item> items = host.getItems();
|
||||||
String runTime = items.get(MonitorConstant.ITEM_RUNTIME).getLastValue();
|
Item empty;
|
||||||
runTime = StrUtil.isBlank(runTime) ? "--" :
|
empty = items.get(MonitorConstant.ITEM_RUNTIME);
|
||||||
NumUtil.keepStr(Long.parseLong(runTime) / 3600.0, 1) + "h";
|
String runTime = ObjectUtil.isNull(empty) ? "--" :
|
||||||
String ramSize = items.get(MonitorConstant.ITEM_RAMSIZE).getLastValue();
|
NumUtil.keepStr(Long.parseLong(empty.getLastValue()) / 3600.0, 1) + "h";
|
||||||
ramSize = StrUtil.isBlank(ramSize) ? "--" :
|
|
||||||
NumUtil.keepStr(Double.parseDouble(ramSize.replace("MB", "")) / 1024, 1) + "GB";
|
empty = items.get(MonitorConstant.ITEM_RAMSIZE);
|
||||||
String cpuCores = items.get(MonitorConstant.ITEM_CPUCORES).getLastValue();
|
String ramSize = ObjectUtil.isNull(empty) ? "--" :
|
||||||
String totalDiskPar = items.get(MonitorConstant.ITEM_TOTALSIDKPAR).getLastValue();
|
NumUtil.keepStr(Double.parseDouble(empty.getLastValue().replace("MB", "")) / 1024, 1) + "GB";
|
||||||
String hostName = items.get(MonitorConstant.ITEM_HOSTNAME).getLastValue();
|
|
||||||
String osVersion = items.get(MonitorConstant.ITEM_OSVERSION).getLastValue();
|
empty = items.get(MonitorConstant.ITEM_CPUCORES);
|
||||||
String netWork = items.get(MonitorConstant.ITEM_NETWORK).getLastValue();
|
String cpuCores = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
String location = items.get(MonitorConstant.ITEM_LOCATION).getLastValue();
|
|
||||||
String ip = items.get(MonitorConstant.ITEM_IP).getLastValue();
|
empty = items.get(MonitorConstant.ITEM_TOTALSIDKPAR);
|
||||||
String zone = items.get(MonitorConstant.ITEM_ZONE).getLastValue();
|
String totalDiskPar = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
String osName = items.get(MonitorConstant.ITEM_OSNAME).getLastValue();
|
|
||||||
String startTime = items.get(MonitorConstant.ITEM_STARTTIME).getLastValue();
|
empty = items.get(MonitorConstant.ITEM_HOSTNAME);
|
||||||
String cpuType = items.get(MonitorConstant.ITEM_CPUTYPE).getLastValue();
|
String hostName = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_OSVERSION);
|
||||||
|
String osVersion = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_NETWORK);
|
||||||
|
String netWork = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_LOCATION);
|
||||||
|
String location = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_IP);
|
||||||
|
String ip = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_ZONE);
|
||||||
|
String zone = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_OSNAME);
|
||||||
|
String osName = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_STARTTIME);
|
||||||
|
String startTime = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_CPUTYPE);
|
||||||
|
String cpuType = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||||
|
|
||||||
/* CPU MEMORY LOADS DISK */
|
/* CPU MEMORY LOADS DISK */
|
||||||
String cpuUsed = items.get(MonitorConstant.ITEM_CPUUSED).getLastValue(); // 0.24
|
empty = items.get(MonitorConstant.ITEM_CPUUSED);
|
||||||
|
String cpuUsed = ObjectUtil.isNull(empty) ? null : empty.getLastValue(); // 0.24
|
||||||
Double cpuUsedValue = NumUtil.keep(cpuUsed, 3);
|
Double cpuUsedValue = NumUtil.keep(cpuUsed, 3);
|
||||||
cpuUsedValue = ObjectUtil.isNull(cpuUsedValue) ? 0 : cpuUsedValue * 100;
|
cpuUsedValue = ObjectUtil.isNull(cpuUsedValue) ? 0 : cpuUsedValue * 100;
|
||||||
String memoryUsed = items.get(MonitorConstant.ITEM_MEMORYUSED).getLastValue(); // 16.64927
|
|
||||||
|
empty = items.get(MonitorConstant.ITEM_MEMORYUSED);
|
||||||
|
String memoryUsed = ObjectUtil.isNull(empty) ? null : empty.getLastValue(); // 16.64927
|
||||||
Double memoryUsedValue = NumUtil.keep(memoryUsed, 1);
|
Double memoryUsedValue = NumUtil.keep(memoryUsed, 1);
|
||||||
memoryUsedValue = ObjectUtil.isNull(memoryUsedValue) ? 0 : memoryUsedValue;
|
memoryUsedValue = ObjectUtil.isNull(memoryUsedValue) ? 0 : memoryUsedValue;
|
||||||
|
|
||||||
Map<String, String> diskUsedMap = items.entrySet().stream() // 6.540206
|
Map<String, String> diskUsedMap = items.entrySet().stream() // 6.540206
|
||||||
.filter(entry -> entry.getKey().contains(MonitorConstant.PRIFIX_DISKUSED))
|
.filter(entry -> entry.getKey().contains(MonitorConstant.PRIFIX_DISKUSED))
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey, item -> item.getValue().getLastValue()));
|
.collect(Collectors.toMap(Map.Entry::getKey, item -> item.getValue().getLastValue()));
|
||||||
|
@ -320,6 +345,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Scheduled(fixedDelay = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
public void status2Redis() {
|
public void status2Redis() {
|
||||||
List<SysServer> sysServers = this.list();
|
List<SysServer> sysServers = this.list();
|
||||||
String key = RedisConstant.SERVER_STATUS;
|
String key = RedisConstant.SERVER_STATUS;
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package org.jeecg.modules.message.controller;
|
package org.jeecg.modules.message.controller;
|
||||||
|
|
||||||
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||||
import org.jeecg.modules.message.SendMessage;
|
import org.jeecg.modules.message.SendMessage;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("sys/sendMessage")
|
@RequestMapping("sys/sendMessage")
|
||||||
|
@ -14,6 +13,9 @@ public class SendMessageController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SendMessage sendMessage;
|
private SendMessage sendMessage;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysBaseAPI sysBaseAPI;
|
||||||
|
|
||||||
@GetMapping("send")
|
@GetMapping("send")
|
||||||
public void sendMessage(@RequestParam String title,
|
public void sendMessage(@RequestParam String title,
|
||||||
@RequestParam String message,
|
@RequestParam String message,
|
||||||
|
@ -22,4 +24,8 @@ public class SendMessageController {
|
||||||
sendMessage.send(title, message, groupId, notific);
|
sendMessage.send(title, message, groupId, notific);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("sendTo")
|
||||||
|
public void sendTo(@RequestBody MessageDTO messageDTO){
|
||||||
|
sysBaseAPI.sendTemplateMessage(messageDTO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class LoginController {
|
||||||
|
|
||||||
//update-begin-author:taoyan date:20190828 for:校验验证码
|
//update-begin-author:taoyan date:20190828 for:校验验证码
|
||||||
|
|
||||||
String captcha = sysLoginModel.getCaptcha();
|
/*String captcha = sysLoginModel.getCaptcha();
|
||||||
if(captcha==null){
|
if(captcha==null){
|
||||||
result.error500("验证码无效");
|
result.error500("验证码无效");
|
||||||
return result;
|
return result;
|
||||||
|
@ -107,7 +107,7 @@ public class LoginController {
|
||||||
// 改成特殊的code 便于前端判断
|
// 改成特殊的code 便于前端判断
|
||||||
result.setCode(HttpStatus.PRECONDITION_FAILED.value());
|
result.setCode(HttpStatus.PRECONDITION_FAILED.value());
|
||||||
return result;
|
return result;
|
||||||
}
|
}*/
|
||||||
//update-end-author:taoyan date:20190828 for:校验验证码
|
//update-end-author:taoyan date:20190828 for:校验验证码
|
||||||
|
|
||||||
//1. 校验用户是否有效
|
//1. 校验用户是否有效
|
||||||
|
|
|
@ -3,9 +3,6 @@ package org.jeecg;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
import org.jeecg.modules.DatabaseStatusManager;
|
|
||||||
import org.jeecg.modules.EmailStatusManager;
|
|
||||||
import org.jeecg.modules.ServerStatusManager;
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -28,12 +25,6 @@ import java.net.UnknownHostException;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class JeecgAbnormalAlarmApplication extends SpringBootServletInitializer implements CommandLineRunner {
|
public class JeecgAbnormalAlarmApplication extends SpringBootServletInitializer implements CommandLineRunner {
|
||||||
|
|
||||||
private final ServerStatusManager serverStatusManager;
|
|
||||||
|
|
||||||
private final EmailStatusManager emailStatusManager;
|
|
||||||
|
|
||||||
private final DatabaseStatusManager databaseStatusManager;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||||
return application.sources(JeecgAbnormalAlarmApplication.class);
|
return application.sources(JeecgAbnormalAlarmApplication.class);
|
||||||
|
@ -54,12 +45,5 @@ public class JeecgAbnormalAlarmApplication extends SpringBootServletInitializer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {}
|
||||||
// 启动监测数据库连接状态的线程
|
|
||||||
databaseStatusManager.start();
|
|
||||||
// 启动监测邮箱服务器连接状态的线程
|
|
||||||
emailStatusManager.start();
|
|
||||||
// 启动监测服务器连接状态的线程
|
|
||||||
serverStatusManager.start();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -15,4 +15,5 @@ spring:
|
||||||
config:
|
config:
|
||||||
import:
|
import:
|
||||||
- optional:nacos:armd.yaml
|
- optional:nacos:armd.yaml
|
||||||
|
- optional:nacos:IDC-Data.yaml
|
||||||
- optional:nacos:armd-@profile.name@.yaml
|
- optional:nacos:armd-@profile.name@.yaml
|
Loading…
Reference in New Issue
Block a user