采集业务细节优化

This commit is contained in:
qiminbao
2025-09-12 14:34:43 +08:00
parent 2c29156748
commit 71ad483c26
11 changed files with 451 additions and 169 deletions
@@ -4,7 +4,6 @@ import com.tongran.agent.client.core.config.GlobalConfig;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.time.LocalDateTime;
@SpringBootApplication @SpringBootApplication
public class TrAgentClientApplication { public class TrAgentClientApplication {
@@ -40,21 +40,21 @@ public enum MsgEnum {
告警上报("ALARM"), 告警上报("ALARM"),
开启系统采集("SYSTEM_COLLECT_START"), 开启或更新系统采集("SYSTEM_COLLECT_START"),
开启系统采集应答("SYSTEM_COLLECT_START_RSP"), 开启或更新系统采集应答("SYSTEM_COLLECT_START_RSP"),
关闭系统采集("SYSTEM_COLLECT_STOP"), 关闭所有系统采集("SYSTEM_COLLECT_STOP"),
关闭系统采集应答("SYSTEM_COLLECT_STOP_RSP"), 关闭所有系统采集应答("SYSTEM_COLLECT_STOP_RSP"),
开启交换机采集("SWITCH_COLLECT_START"), 开启或更新交换机采集("SWITCH_COLLECT_START"),
开启交换机采集应答("SWITCH_COLLECT_START_RSP"), 开启或更新交换机采集应答("SWITCH_COLLECT_START_RSP"),
关闭交换机采集("SWITCH_COLLECT_STOP"), 关闭所有交换机采集("SWITCH_COLLECT_STOP"),
关闭交换机采集应答("SWITCH_COLLECT_STOP_RSP"), 关闭所有交换机采集应答("SWITCH_COLLECT_STOP_RSP"),
告警设置("ALARM_SET"), 告警设置("ALARM_SET"),
@@ -119,11 +119,7 @@ public class AgentEndpoint {
//更改全局变量 //更改全局变量
GlobalConfig.isCollect = false; GlobalConfig.isCollect = false;
//调用采集任务 //调用采集任务
try { agentService.cancelCollect();
appInitializer.run();
} catch (Exception e) {
e.printStackTrace();
}
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
timestamp = Math.round(timestamp / 1000.0); timestamp = Math.round(timestamp / 1000.0);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
@@ -135,7 +131,7 @@ public class AgentEndpoint {
} }
} }
@AgentDispatcher(msgId = MsgEnum.开启系统采集) @AgentDispatcher(msgId = MsgEnum.开启或更新系统采集)
public class SysCollectStartHandler implements AgentHandler { public class SysCollectStartHandler implements AgentHandler {
@Override @Override
public UpMsgResponse upHandle(String data, String clientId) { public UpMsgResponse upHandle(String data, String clientId) {
@@ -147,11 +143,11 @@ public class AgentEndpoint {
json.put("resCode",1); json.put("resCode",1);
json.put("resMag",""); json.put("resMag","");
json.put("timestamp",timestamp); json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.开启系统采集应答.getValue()).content(json.toString()).build(); return UpMsgResponse.builder().dataType(MsgEnum.开启或更新系统采集应答.getValue()).content(json.toString()).build();
} }
} }
@AgentDispatcher(msgId = MsgEnum.关闭系统采集) @AgentDispatcher(msgId = MsgEnum.关闭所有系统采集)
public class SysCollectStopHandler implements AgentHandler { public class SysCollectStopHandler implements AgentHandler {
@Override @Override
public UpMsgResponse upHandle(String data, String clientId) { public UpMsgResponse upHandle(String data, String clientId) {
@@ -163,11 +159,11 @@ public class AgentEndpoint {
json.put("resCode",1); json.put("resCode",1);
json.put("resMag",""); json.put("resMag","");
json.put("timestamp",timestamp); json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.关闭系统采集应答.getValue()).content(json.toString()).build(); return UpMsgResponse.builder().dataType(MsgEnum.关闭所有系统采集应答.getValue()).content(json.toString()).build();
} }
} }
@AgentDispatcher(msgId = MsgEnum.开启交换机采集) @AgentDispatcher(msgId = MsgEnum.开启或更新交换机采集)
public class SwitchCollectStartHandler implements AgentHandler { public class SwitchCollectStartHandler implements AgentHandler {
@Override @Override
public UpMsgResponse upHandle(String data, String clientId) { public UpMsgResponse upHandle(String data, String clientId) {
@@ -179,11 +175,11 @@ public class AgentEndpoint {
json.put("resCode",1); json.put("resCode",1);
json.put("resMag",""); json.put("resMag","");
json.put("timestamp",timestamp); json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.开启交换机采集应答.getValue()).content(json.toString()).build(); return UpMsgResponse.builder().dataType(MsgEnum.开启或更新交换机采集应答.getValue()).content(json.toString()).build();
} }
} }
@AgentDispatcher(msgId = MsgEnum.关闭交换机采集) @AgentDispatcher(msgId = MsgEnum.关闭所有交换机采集)
public class SwitchCollectStopHandler implements AgentHandler { public class SwitchCollectStopHandler implements AgentHandler {
@Override @Override
public UpMsgResponse upHandle(String data, String clientId) { public UpMsgResponse upHandle(String data, String clientId) {
@@ -195,7 +191,7 @@ public class AgentEndpoint {
json.put("resCode",1); json.put("resCode",1);
json.put("resMag",""); json.put("resMag","");
json.put("timestamp",timestamp); json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.关闭交换机采集应答.getValue()).content(json.toString()).build(); return UpMsgResponse.builder().dataType(MsgEnum.关闭所有交换机采集应答.getValue()).content(json.toString()).build();
} }
} }
@@ -28,7 +28,7 @@ public class SchedulerConfig {
@Bean("taskExecutor") @Bean("taskExecutor")
public ThreadPoolTaskScheduler taskExecutor() { public ThreadPoolTaskScheduler taskExecutor() {
ThreadPoolTaskScheduler executor = new ThreadPoolTaskScheduler(); ThreadPoolTaskScheduler executor = new ThreadPoolTaskScheduler();
executor.setPoolSize(10); // 工作线程数 executor.setPoolSize(11); // 工作线程数
executor.setThreadNamePrefix("task-worker-"); executor.setThreadNamePrefix("task-worker-");
executor.setAwaitTerminationSeconds(30); executor.setAwaitTerminationSeconds(30);
executor.setWaitForTasksToCompleteOnShutdown(true); executor.setWaitForTasksToCompleteOnShutdown(true);
@@ -22,21 +22,18 @@ public class AppInitializer implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
System.out.println("应用启动完成,开始初始化定时任务..."); System.out.println("应用启动完成,开始初始化定时任务...");
if(!GlobalConfig.isCollect){ if(GlobalConfig.isCollect){
// 开启定时任务 // 开启定时任务
initScheduledTasks(); initScheduledTasks();
}else{
// 关闭定时任务
cancelTasks();
} }
System.out.println("定时任务初始化完成"); System.out.println("定时任务初始化完成");
} }
private void initScheduledTasks() { private void initScheduledTasks() {
// 每30秒执行心跳任务 // 每30秒执行心跳任务
AssertLog.info("初始化启动心跳定时任务 - 延迟: {}ms, 间隔: {}ms", 5000, 30000); AssertLog.info("初始化启动心跳定时任务 - 延迟: {}ms, 间隔: {}ms", 15000, 30000);
dynamicTaskService.scheduleTask("heartbeat", dynamicTaskService.scheduleTask("heartbeat",
businessTasks::heartbeatTask, 5000, 30000); businessTasks::heartbeatTask, 15000, 30000);
// long milli = AgentUtil.getMillisToNextMinute() + 60000; // long milli = AgentUtil.getMillisToNextMinute() + 60000;
// // 每300秒执行CPU信息采集任务 // // 每300秒执行CPU信息采集任务
@@ -84,15 +81,4 @@ public class AppInitializer implements CommandLineRunner {
} }
private void cancelTasks() {
dynamicTaskService.cancelTask("heartbeat");
// dynamicTaskService.cancelTask("cpu");
// dynamicTaskService.cancelTask("disk");
// dynamicTaskService.cancelTask("system");
// dynamicTaskService.cancelTask("docker");
// dynamicTaskService.cancelTask("memory");
// dynamicTaskService.cancelTask("net");
// dynamicTaskService.cancelTask("point");
// dynamicTaskService.cancelTask("switchBoard");
}
} }
@@ -99,6 +99,7 @@ public class BusinessTasks {
object.put("timestamp",timestamp); object.put("timestamp",timestamp);
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.心跳上报.getValue()).data(object.toString()).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.心跳上报.getValue()).data(object.toString()).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送心跳包={}",JSON.toJSONString(message));
} }
AssertLog.info("心跳定时任务执行 - task #{} completed", count); AssertLog.info("心跳定时任务执行 - task #{} completed", count);
} }
@@ -120,6 +121,7 @@ public class BusinessTasks {
String data = JSON.toJSONString(cpuVO); String data = JSON.toJSONString(cpuVO);
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.CPU上报.getValue()).data(data).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.CPU上报.getValue()).data(data).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送CPU信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("CPU信息采集定时任务执行 - task #{} completed", count); AssertLog.info("CPU信息采集定时任务执行 - task #{} completed", count);
} }
@@ -143,6 +145,7 @@ public class BusinessTasks {
} }
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.磁盘上报.getValue()).data(data).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.磁盘上报.getValue()).data(data).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送磁盘信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("磁盘信息采集定时任务执行 - task #{} completed", count); AssertLog.info("磁盘信息采集定时任务执行 - task #{} completed", count);
} }
@@ -166,6 +169,7 @@ public class BusinessTasks {
} }
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.容器上报.getValue()).data(data).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.容器上报.getValue()).data(data).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送容器信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("容器信息采集定时任务执行 - task #{} completed", count); AssertLog.info("容器信息采集定时任务执行 - task #{} completed", count);
} }
@@ -187,6 +191,7 @@ public class BusinessTasks {
String data = JSON.toJSONString(memoryVO); String data = JSON.toJSONString(memoryVO);
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.内存上报.getValue()).data(data).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.内存上报.getValue()).data(data).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送内存信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("内存信息采集定时任务执行 - task #{} completed", count); AssertLog.info("内存信息采集定时任务执行 - task #{} completed", count);
} }
@@ -209,6 +214,7 @@ public class BusinessTasks {
} }
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.网络上报.getValue()).data(data).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.网络上报.getValue()).data(data).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送网络信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("网络信息采集定时任务执行 - task #{} completed", count); AssertLog.info("网络信息采集定时任务执行 - task #{} completed", count);
} }
@@ -232,6 +238,7 @@ public class BusinessTasks {
} }
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.挂载上报.getValue()).data(data).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.挂载上报.getValue()).data(data).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送挂载信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("挂载点信息采集定时任务执行 - task #{} completed", count); AssertLog.info("挂载点信息采集定时任务执行 - task #{} completed", count);
} }
@@ -259,6 +266,7 @@ public class BusinessTasks {
jsonObject.put("timestamp", timestamp); jsonObject.put("timestamp", timestamp);
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.交换机上报.getValue()).data(jsonObject.toString()).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.交换机上报.getValue()).data(jsonObject.toString()).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送交换机信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("交换机信息采集定时任务执行 - task #{} completed", count); AssertLog.info("交换机信息采集定时任务执行 - task #{} completed", count);
} }
@@ -287,6 +295,7 @@ public class BusinessTasks {
jsonObject.put("timestamp", timestamp); jsonObject.put("timestamp", timestamp);
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.系统其他上报.getValue()).data(jsonObject.toString()).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.系统其他上报.getValue()).data(jsonObject.toString()).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送系统信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("系统信息采集定时任务执行 - task #{} completed", count); AssertLog.info("系统信息采集定时任务执行 - task #{} completed", count);
} }
@@ -309,6 +318,7 @@ public class BusinessTasks {
} }
Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.告警上报.getValue()).data(data).build(); Message message = Message.builder().clientId(GlobalConfig.CLIENT_ID).dataType(MsgEnum.告警上报.getValue()).data(data).build();
sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message); sessionManager.writeAndFlush(sessionManager.getSessionById(GlobalConfig.CLIENT_ID).getChannel(), message);
AssertLog.info("发送告警监控信息包={}",JSON.toJSONString(message));
} }
AssertLog.info("告警监控定时任务执行 - task #{} completed", count); AssertLog.info("告警监控定时任务执行 - task #{} completed", count);
} }
@@ -1,6 +1,8 @@
package com.tongran.agent.client.service; package com.tongran.agent.client.service;
public interface AgentService { public interface AgentService {
void cancelCollect();
void systemCollectStart(String data); void systemCollectStart(String data);
void systemCollectStop(); void systemCollectStop();
@@ -31,6 +31,13 @@ public class AgentServiceImpl implements AgentService {
this.businessTasks = businessTasks; this.businessTasks = businessTasks;
} }
@Override
public void cancelCollect() {
systemCollectStop();
switchCollectStop();
dynamicTaskService.cancelTask("heartbeat");
}
@Override @Override
public void systemCollectStart(String data) { public void systemCollectStart(String data) {
//更改全局变量 //更改全局变量
@@ -43,122 +50,257 @@ public class AgentServiceImpl implements AgentService {
boolean collect = c.isCollect(); boolean collect = c.isCollect();
switch(type) { switch(type) {
case "cpuCollect": //cpu采集 case "cpuCollect": //cpu采集
GlobalConfig.cpuCollect = collect; //判断与上次有无变化
GlobalConfig.cpuInterval = c.getInterval(); if(GlobalConfig.cpuCollect != collect || GlobalConfig.cpuInterval != c.getInterval()){
if(collect){ GlobalConfig.cpuCollect = collect;
long milli = AgentUtil.getMillisToNextMinute() + 60000; if(collect){
dynamicTaskService.scheduleTask(c.getType(), GlobalConfig.cpuInterval = c.getInterval();
businessTasks::cpuTask, milli, GlobalConfig.cpuInterval*1000L); long milli = AgentUtil.getMillisToNextMinute() + 60000;
dynamicTaskService.scheduleTask(type,
businessTasks::cpuTask, milli, GlobalConfig.cpuInterval*1000L);
}else{
dynamicTaskService.cancelTask(type);
GlobalConfig.cpuInterval = 300;
}
} }
break; break;
case "vfsCollect": //挂载采集 case "vfsCollect": //挂载采集
GlobalConfig.vfsCollect = collect; if(GlobalConfig.vfsCollect != collect || GlobalConfig.vfsInterval != c.getInterval()){
GlobalConfig.vfsInterval = c.getInterval(); GlobalConfig.vfsCollect = collect;
if(collect){ if(collect){
long milli = AgentUtil.getMillisToNextMinute() + 60000; GlobalConfig.vfsInterval = c.getInterval();
dynamicTaskService.scheduleTask(c.getType(), long milli = AgentUtil.getMillisToNextMinute() + 60000;
businessTasks::pointTask, milli, GlobalConfig.vfsInterval*1000L); dynamicTaskService.scheduleTask(type,
businessTasks::pointTask, milli, GlobalConfig.vfsInterval*1000L);
}else{
dynamicTaskService.cancelTask(type);
GlobalConfig.vfsInterval = 300;
}
} }
break; break;
case "netCollect": //网络采集 case "netCollect": //网络采集
GlobalConfig.netCollect = collect; if(GlobalConfig.netCollect != collect || GlobalConfig.netInterval != c.getInterval()){
GlobalConfig.netInterval = c.getInterval(); GlobalConfig.netCollect = collect;
if(collect){ if(collect){
long milli = AgentUtil.millisecondsToNext5Minute(); GlobalConfig.netInterval = c.getInterval();
dynamicTaskService.scheduleTask(c.getType(), long milli = AgentUtil.millisecondsToNext5Minute();
businessTasks::netTask, milli, GlobalConfig.netInterval*1000L); dynamicTaskService.scheduleTask(type,
businessTasks::netTask, milli, GlobalConfig.netInterval*1000L);
}else{
dynamicTaskService.cancelTask(type);
GlobalConfig.netInterval = 300;
}
} }
break; break;
case "diskCollect": //磁盘采集 case "diskCollect": //磁盘采集
GlobalConfig.diskCollect = collect; if(GlobalConfig.diskCollect != collect || GlobalConfig.diskInterval != c.getInterval()){
GlobalConfig.diskInterval = c.getInterval(); GlobalConfig.diskCollect = collect;
if(collect){ if(collect){
long milli = AgentUtil.getMillisToNextMinute() + 60000; GlobalConfig.diskInterval = c.getInterval();
dynamicTaskService.scheduleTask(c.getType(), long milli = AgentUtil.getMillisToNextMinute() + 60000;
businessTasks::diskTask, milli, GlobalConfig.diskInterval*1000L); dynamicTaskService.scheduleTask(type,
businessTasks::diskTask, milli, GlobalConfig.diskInterval*1000L);
}else{
dynamicTaskService.cancelTask(type);
GlobalConfig.diskInterval = 300;
}
} }
break; break;
case "dockerCollect": //docker采集 case "dockerCollect": //docker采集
GlobalConfig.dockerCollect = collect; if(GlobalConfig.dockerCollect != collect || GlobalConfig.dockerInterval != c.getInterval()){
GlobalConfig.dockerInterval = c.getInterval(); GlobalConfig.dockerCollect = collect;
if(collect){ if(collect){
long milli = AgentUtil.getMillisToNextMinute() + 60000; GlobalConfig.dockerInterval = c.getInterval();
dynamicTaskService.scheduleTask(c.getType(), long milli = AgentUtil.getMillisToNextMinute() + 60000;
businessTasks::dockerTask, milli, GlobalConfig.dockerInterval*1000L); dynamicTaskService.scheduleTask(type,
businessTasks::dockerTask, milli, GlobalConfig.dockerInterval*1000L);
}else{
dynamicTaskService.cancelTask(type);
GlobalConfig.dockerInterval = 300;
}
} }
break; break;
default: //系统其他采集 default: //系统其他采集
boolean flag = false;
if(StringUtils.equals(type, "systemSwapSizeFreeCollect")){ if(StringUtils.equals(type, "systemSwapSizeFreeCollect")){
GlobalConfig.systemSwapSizeFreeCollect = collect; if(GlobalConfig.systemSwapSizeFreeCollect != collect || GlobalConfig.systemSwapSizeFreeInterval != c.getInterval()){
GlobalConfig.systemSwapSizeFreeInterval = c.getInterval(); flag = true;
GlobalConfig.systemSwapSizeFreeCollect = collect;
GlobalConfig.systemSwapSizeFreeInterval = c.getInterval();
if(!collect){
GlobalConfig.systemSwapSizeFreeInterval = 300;
}
}
} }
if(StringUtils.equals(type, "memoryUtilizationCollect")){ if(StringUtils.equals(type, "memoryUtilizationCollect")){
GlobalConfig.memoryUtilizationCollect = collect; if(GlobalConfig.memoryUtilizationCollect != collect || GlobalConfig.memoryUtilizationInterval != c.getInterval()){
GlobalConfig.memoryUtilizationInterval = c.getInterval(); flag = true;
GlobalConfig.memoryUtilizationCollect = collect;
GlobalConfig.memoryUtilizationInterval = c.getInterval();
if(!collect){
GlobalConfig.memoryUtilizationInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemSwapSizePercentCollect")){ if(StringUtils.equals(type, "systemSwapSizePercentCollect")){
GlobalConfig.systemSwapSizePercentCollect = collect; if(GlobalConfig.systemSwapSizePercentCollect != collect || GlobalConfig.systemSwapSizePercentInterval != c.getInterval()){
GlobalConfig.systemSwapSizePercentInterval = c.getInterval(); flag = true;
GlobalConfig.systemSwapSizePercentCollect = collect;
GlobalConfig.systemSwapSizePercentInterval = c.getInterval();
if(!collect){
GlobalConfig.systemSwapSizePercentInterval = 300;
}
}
} }
if(StringUtils.equals(type, "memorySizeAvailableCollect")){ if(StringUtils.equals(type, "memorySizeAvailableCollect")){
GlobalConfig.memorySizeAvailableCollect = collect; if(GlobalConfig.memorySizeAvailableCollect != collect || GlobalConfig.memorySizeAvailableInterval != c.getInterval()){
GlobalConfig.memorySizeAvailableInterval = c.getInterval(); flag = true;
GlobalConfig.memorySizeAvailableCollect = collect;
GlobalConfig.memorySizeAvailableInterval = c.getInterval();
if(!collect){
GlobalConfig.memorySizeAvailableInterval = 300;
}
}
} }
if(StringUtils.equals(type, "memorySizePercentCollect")){ if(StringUtils.equals(type, "memorySizePercentCollect")){
GlobalConfig.memorySizePercentCollect = collect; if(GlobalConfig.memorySizePercentCollect != collect || GlobalConfig.memorySizePercentInterval != c.getInterval()){
GlobalConfig.memorySizePercentInterval = c.getInterval(); flag = true;
GlobalConfig.memorySizePercentCollect = collect;
GlobalConfig.memorySizePercentInterval = c.getInterval();
if(!collect){
GlobalConfig.memorySizePercentInterval = 300;
}
}
} }
if(StringUtils.equals(type, "memorySizeTotalCollect")){ if(StringUtils.equals(type, "memorySizeTotalCollect")){
GlobalConfig.memorySizeTotalCollect = collect; if(GlobalConfig.memorySizeTotalCollect != collect || GlobalConfig.memorySizeTotalInterval != c.getInterval()){
GlobalConfig.memorySizeTotalInterval = c.getInterval(); flag = true;
GlobalConfig.memorySizeTotalCollect = collect;
GlobalConfig.memorySizeTotalInterval = c.getInterval();
if(!collect){
GlobalConfig.memorySizeTotalInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemSwOsCollect")){ if(StringUtils.equals(type, "systemSwOsCollect")){
GlobalConfig.systemSwOsCollect = collect; if(GlobalConfig.systemSwOsCollect != collect || GlobalConfig.systemSwOsInterval != c.getInterval()){
GlobalConfig.systemSwOsInterval = c.getInterval(); flag = true;
GlobalConfig.systemSwOsCollect = collect;
GlobalConfig.systemSwOsInterval = c.getInterval();
if(!collect){
GlobalConfig.systemSwOsInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemSwArchCollect")){ if(StringUtils.equals(type, "systemSwArchCollect")){
GlobalConfig.systemSwArchCollect = collect; if(GlobalConfig.systemSwArchCollect != collect || GlobalConfig.systemSwArchInterval != c.getInterval()){
GlobalConfig.systemSwArchInterval = c.getInterval(); flag = true;
GlobalConfig.systemSwArchCollect = collect;
GlobalConfig.systemSwArchInterval = c.getInterval();
if(!collect){
GlobalConfig.systemSwArchInterval = 300;
}
}
} }
if(StringUtils.equals(type, "kernelMaxprocCollect")){ if(StringUtils.equals(type, "kernelMaxprocCollect")){
GlobalConfig.kernelMaxprocCollect = collect; if(GlobalConfig.kernelMaxprocCollect != collect || GlobalConfig.kernelMaxprocInterval != c.getInterval()){
GlobalConfig.kernelMaxprocInterval = c.getInterval(); flag = true;
GlobalConfig.kernelMaxprocCollect = collect;
GlobalConfig.kernelMaxprocInterval = c.getInterval();
if(!collect){
GlobalConfig.kernelMaxprocInterval = 300;
}
}
} }
if(StringUtils.equals(type, "procNumRunCollect")){ if(StringUtils.equals(type, "procNumRunCollect")){
GlobalConfig.procNumRunCollect = collect; if(GlobalConfig.procNumRunCollect != collect || GlobalConfig.procNumRunInterval != c.getInterval()){
GlobalConfig.procNumRunInterval = c.getInterval(); flag = true;
GlobalConfig.procNumRunCollect = collect;
GlobalConfig.procNumRunInterval = c.getInterval();
if(!collect){
GlobalConfig.procNumRunInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemUsersNumCollect")){ if(StringUtils.equals(type, "systemUsersNumCollect")){
GlobalConfig.systemUsersNumCollect = collect; if(GlobalConfig.systemUsersNumCollect != collect || GlobalConfig.systemUsersNumInterval != c.getInterval()){
GlobalConfig.systemUsersNumInterval = c.getInterval(); flag = true;
GlobalConfig.systemUsersNumCollect = collect;
GlobalConfig.systemUsersNumInterval = c.getInterval();
if(!collect){
GlobalConfig.systemUsersNumInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemDiskSizeTotalCollect")){ if(StringUtils.equals(type, "systemDiskSizeTotalCollect")){
GlobalConfig.systemDiskSizeTotalCollect = collect; if(GlobalConfig.systemDiskSizeTotalCollect != collect || GlobalConfig.systemDiskSizeTotalInterval != c.getInterval()){
GlobalConfig.systemDiskSizeTotalInterval = c.getInterval(); flag = true;
GlobalConfig.systemDiskSizeTotalCollect = collect;
GlobalConfig.systemDiskSizeTotalInterval = c.getInterval();
if(!collect){
GlobalConfig.systemDiskSizeTotalInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemBoottimeCollect")){ if(StringUtils.equals(type, "systemBoottimeCollect")){
GlobalConfig.systemBoottimeCollect = collect; if(GlobalConfig.systemBoottimeCollect != collect || GlobalConfig.systemBoottimeInterval != c.getInterval()){
GlobalConfig.systemBoottimeInterval = c.getInterval(); flag = true;
GlobalConfig.systemBoottimeCollect = collect;
GlobalConfig.systemBoottimeInterval = c.getInterval();
if(!collect){
GlobalConfig.systemBoottimeInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemUnameCollect")){ if(StringUtils.equals(type, "systemUnameCollect")){
GlobalConfig.systemUnameCollect = collect; if(GlobalConfig.systemUnameCollect != collect || GlobalConfig.systemUnameInterval != c.getInterval()){
GlobalConfig.systemUnameInterval = c.getInterval(); flag = true;
GlobalConfig.systemUnameCollect = collect;
GlobalConfig.systemUnameInterval = c.getInterval();
if(!collect){
GlobalConfig.systemUnameInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemLocaltimeCollect")){ if(StringUtils.equals(type, "systemLocaltimeCollect")){
GlobalConfig.systemLocaltimeCollect = collect; if(GlobalConfig.systemLocaltimeCollect != collect || GlobalConfig.systemLocaltimeInterval != c.getInterval()){
GlobalConfig.systemLocaltimeInterval = c.getInterval(); flag = true;
GlobalConfig.systemLocaltimeCollect = collect;
GlobalConfig.systemLocaltimeInterval = c.getInterval();
if(!collect){
GlobalConfig.systemLocaltimeInterval = 300;
}
}
} }
if(StringUtils.equals(type, "systemUptimeCollect")){ if(StringUtils.equals(type, "systemUptimeCollect")){
GlobalConfig.systemUptimeCollect = collect; if(GlobalConfig.systemUptimeCollect != collect || GlobalConfig.systemUptimeInterval != c.getInterval()){
GlobalConfig.systemUptimeInterval = c.getInterval(); flag = true;
GlobalConfig.systemUptimeCollect = collect;
GlobalConfig.systemUptimeInterval = c.getInterval();
if(!collect){
GlobalConfig.systemUptimeInterval = 300;
}
}
} }
if(StringUtils.equals(type, "procNumCollect")){ if(StringUtils.equals(type, "procNumCollect")){
GlobalConfig.procNumCollect = collect; if(GlobalConfig.procNumCollect != collect || GlobalConfig.procNumInterval != c.getInterval()){
GlobalConfig.procNumInterval = c.getInterval(); flag = true;
GlobalConfig.procNumCollect = collect;
GlobalConfig.procNumInterval = c.getInterval();
if(!collect){
GlobalConfig.procNumInterval = 300;
}
}
}
if (flag) {
if(collect){
long milli = AgentUtil.getMillisToNextMinute() + 60000;
dynamicTaskService.scheduleTask(type,
() -> businessTasks.systemTask(type), milli, c.getInterval()*1000L);
}else{
dynamicTaskService.cancelTask(type);
}
} }
long milli = AgentUtil.getMillisToNextMinute() + 60000;
dynamicTaskService.scheduleTask(c.getType(),
() -> businessTasks.systemTask(c.getType()), milli, c.getInterval()*1000L);
break; break;
} }
} }
@@ -236,90 +378,209 @@ public class AgentServiceImpl implements AgentService {
for (CollectEO c : configList) { for (CollectEO c : configList) {
String type = c.getType(); String type = c.getType();
boolean collect = c.isCollect(); boolean collect = c.isCollect();
boolean flag = false;
switch(type) { switch(type) {
case "switchNetCollect": //交换机网络采集 case "switchNetCollect": //交换机网络采集
GlobalConfig.switchNetCollect = collect; if(GlobalConfig.switchNetCollect != collect || GlobalConfig.switchNetInterval != c.getInterval()){
GlobalConfig.switchNetInterval = c.getInterval(); flag = true;
GlobalConfig.switchNetCollect = collect;
GlobalConfig.switchNetInterval = c.getInterval();
if(!collect){
GlobalConfig.switchNetInterval = 300;
}
}
break; break;
case "switchModuleCollect": //光模块采集 case "switchModuleCollect": //光模块采集
GlobalConfig.switchModuleCollect = collect; if(GlobalConfig.switchModuleCollect != collect || GlobalConfig.switchModuleInterval != c.getInterval()){
GlobalConfig.switchModuleInterval = c.getInterval(); flag = true;
GlobalConfig.switchModuleCollect = collect;
GlobalConfig.switchModuleInterval = c.getInterval();
if(!collect){
GlobalConfig.switchModuleInterval = 300;
}
}
break; break;
case "switchMpuCollect": //MPU采集 case "switchMpuCollect": //MPU采集
GlobalConfig.switchMpuCollect = collect; if(GlobalConfig.switchMpuCollect != collect || GlobalConfig.switchMpuInterval != c.getInterval()){
GlobalConfig.switchMpuInterval = c.getInterval(); flag = true;
GlobalConfig.switchMpuCollect = collect;
GlobalConfig.switchMpuInterval = c.getInterval();
if(!collect){
GlobalConfig.switchMpuInterval = 300;
}
}
break; break;
case "switchPwrCollect": //电源采集 case "switchPwrCollect": //电源采集
GlobalConfig.switchPwrCollect = collect; if(GlobalConfig.switchPwrCollect != collect || GlobalConfig.switchPwrInterval != c.getInterval()){
GlobalConfig.switchPwrInterval = c.getInterval(); flag = true;
GlobalConfig.switchPwrCollect = collect;
GlobalConfig.switchPwrInterval = c.getInterval();
if(!collect){
GlobalConfig.switchPwrInterval = 300;
}
}
break; break;
case "dockerCollect": //风扇采集 case "dockerCollect": //风扇采集
GlobalConfig.switchFanCollect = collect; if(GlobalConfig.switchFanCollect != collect || GlobalConfig.switchFanInterval != c.getInterval()){
GlobalConfig.switchFanInterval = c.getInterval(); flag = true;
GlobalConfig.switchFanCollect = collect;
GlobalConfig.switchFanInterval = c.getInterval();
if(!collect){
GlobalConfig.switchFanInterval = 300;
}
}
break; break;
default: //系统其他采集 default: //系统其他采集
if(StringUtils.equals(type, "switchSysDescrCollect")){ if(StringUtils.equals(type, "switchSysDescrCollect")){
GlobalConfig.switchSysDescrCollect = collect; if(GlobalConfig.switchSysDescrCollect != collect || GlobalConfig.switchSysDescrInterval != c.getInterval()){
GlobalConfig.switchSysDescrInterval = c.getInterval(); flag = true;
GlobalConfig.switchSysDescrCollect = collect;
GlobalConfig.switchSysDescrInterval = c.getInterval();
if(!collect){
GlobalConfig.switchSysDescrInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchSysObjectIDCollect")){ if(StringUtils.equals(type, "switchSysObjectIDCollect")){
GlobalConfig.switchSysObjectIDCollect = collect; if(GlobalConfig.switchSysObjectIDCollect != collect || GlobalConfig.switchSysObjectIDInterval != c.getInterval()){
GlobalConfig.switchSysObjectIDInterval = c.getInterval(); flag = true;
GlobalConfig.switchSysObjectIDCollect = collect;
GlobalConfig.switchSysObjectIDInterval = c.getInterval();
if(!collect){
GlobalConfig.switchSysObjectIDInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchSysUpTimeCollect")){ if(StringUtils.equals(type, "switchSysUpTimeCollect")){
GlobalConfig.switchSysUpTimeCollect = collect; if(GlobalConfig.switchSysUpTimeCollect != collect || GlobalConfig.switchSysUpTimeInterval != c.getInterval()){
GlobalConfig.switchSysUpTimeInterval = c.getInterval(); flag = true;
GlobalConfig.switchSysUpTimeCollect = collect;
GlobalConfig.switchSysUpTimeInterval = c.getInterval();
if(!collect){
GlobalConfig.switchSysUpTimeInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchSysContactCollect")){ if(StringUtils.equals(type, "switchSysContactCollect")){
GlobalConfig.switchSysContactCollect = collect; if(GlobalConfig.switchSysContactCollect != collect || GlobalConfig.switchSysContactInterval != c.getInterval()){
GlobalConfig.switchSysContactInterval = c.getInterval(); flag = true;
GlobalConfig.switchSysContactCollect = collect;
GlobalConfig.switchSysContactInterval = c.getInterval();
if(!collect){
GlobalConfig.switchSysContactInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchSysNameCollect")){ if(StringUtils.equals(type, "switchSysNameCollect")){
GlobalConfig.switchSysNameCollect = collect; if(GlobalConfig.switchSysNameCollect != collect || GlobalConfig.switchSysNameInterval != c.getInterval()){
GlobalConfig.switchSysNameInterval = c.getInterval(); flag = true;
GlobalConfig.switchSysNameCollect = collect;
GlobalConfig.switchSysNameInterval = c.getInterval();
if(!collect){
GlobalConfig.switchSysNameInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchSysLocationCollect")){ if(StringUtils.equals(type, "switchSysLocationCollect")){
GlobalConfig.switchSysLocationCollect = collect; if(GlobalConfig.switchSysLocationCollect != collect || GlobalConfig.switchSysLocationInterval != c.getInterval()){
GlobalConfig.switchSysLocationInterval = c.getInterval(); flag = true;
GlobalConfig.switchSysLocationCollect = collect;
GlobalConfig.switchSysLocationInterval = c.getInterval();
if(!collect){
GlobalConfig.switchSysLocationInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchHwStackSystemMacCollect")){ if(StringUtils.equals(type, "switchHwStackSystemMacCollect")){
GlobalConfig.switchHwStackSystemMacCollect = collect; if(GlobalConfig.switchHwStackSystemMacCollect != collect || GlobalConfig.switchHwStackSystemMacInterval != c.getInterval()){
GlobalConfig.switchHwStackSystemMacInterval = c.getInterval(); flag = true;
GlobalConfig.switchHwStackSystemMacCollect = collect;
GlobalConfig.switchHwStackSystemMacInterval = c.getInterval();
if(!collect){
GlobalConfig.switchHwStackSystemMacInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchEntIndexCollect")){ if(StringUtils.equals(type, "switchEntIndexCollect")){
GlobalConfig.switchEntIndexCollect = collect; if(GlobalConfig.switchEntIndexCollect != collect || GlobalConfig.switchEntIndexInterval != c.getInterval()){
GlobalConfig.switchEntIndexInterval = c.getInterval(); flag = true;
GlobalConfig.switchEntIndexCollect = collect;
GlobalConfig.switchEntIndexInterval = c.getInterval();
if(!collect){
GlobalConfig.switchEntIndexInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchEntPhysicalNameCollect")){ if(StringUtils.equals(type, "switchEntPhysicalNameCollect")){
GlobalConfig.switchEntPhysicalNameCollect = collect; if(GlobalConfig.switchEntPhysicalNameCollect != collect || GlobalConfig.switchEntPhysicalNameInterval != c.getInterval()){
GlobalConfig.switchEntPhysicalNameInterval = c.getInterval(); flag = true;
GlobalConfig.switchEntPhysicalNameCollect = collect;
GlobalConfig.switchEntPhysicalNameInterval = c.getInterval();
if(!collect){
GlobalConfig.switchEntPhysicalNameInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchEntPhysicalSoftwareRevCollect")){ if(StringUtils.equals(type, "switchEntPhysicalSoftwareRevCollect")){
GlobalConfig.switchEntPhysicalSoftwareRevCollect = collect; if(GlobalConfig.switchEntPhysicalSoftwareRevCollect != collect || GlobalConfig.switchEntPhysicalSoftwareRevInterval != c.getInterval()){
GlobalConfig.switchEntPhysicalSoftwareRevInterval = c.getInterval(); flag = true;
GlobalConfig.switchEntPhysicalSoftwareRevCollect = collect;
GlobalConfig.switchEntPhysicalSoftwareRevInterval = c.getInterval();
if(!collect){
GlobalConfig.switchEntPhysicalSoftwareRevInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchHwEntityCpuUsageCollect")){ if(StringUtils.equals(type, "switchHwEntityCpuUsageCollect")){
GlobalConfig.switchHwEntityCpuUsageCollect = collect; if(GlobalConfig.switchHwEntityCpuUsageCollect != collect || GlobalConfig.switchHwEntityCpuUsageInterval != c.getInterval()){
GlobalConfig.switchHwEntityCpuUsageInterval = c.getInterval(); flag = true;
GlobalConfig.switchHwEntityCpuUsageCollect = collect;
GlobalConfig.switchHwEntityCpuUsageInterval = c.getInterval();
if(!collect){
GlobalConfig.switchHwEntityCpuUsageInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchHwEntityMemUsageCollect")){ if(StringUtils.equals(type, "switchHwEntityMemUsageCollect")){
GlobalConfig.switchHwEntityMemUsageCollect = collect; if(GlobalConfig.switchHwEntityMemUsageCollect != collect || GlobalConfig.switchHwEntityMemUsageInterval != c.getInterval()){
GlobalConfig.switchHwEntityMemUsageInterval = c.getInterval(); flag = true;
GlobalConfig.switchHwEntityMemUsageCollect = collect;
GlobalConfig.switchHwEntityMemUsageInterval = c.getInterval();
if(!collect){
GlobalConfig.switchHwEntityMemUsageInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchHwAveragePowerCollect")){ if(StringUtils.equals(type, "switchHwAveragePowerCollect")){
GlobalConfig.switchHwAveragePowerCollect = collect; if(GlobalConfig.switchHwAveragePowerCollect != collect || GlobalConfig.switchHwAveragePowerInterval != c.getInterval()){
GlobalConfig.switchHwAveragePowerInterval = c.getInterval(); flag = true;
GlobalConfig.switchHwAveragePowerCollect = collect;
GlobalConfig.switchHwAveragePowerInterval = c.getInterval();
if(!collect){
GlobalConfig.switchHwAveragePowerInterval = 300;
}
}
} }
if(StringUtils.equals(type, "switchHwCurrentPowerCollect")){ if(StringUtils.equals(type, "switchHwCurrentPowerCollect")){
GlobalConfig.switchHwCurrentPowerCollect = collect; if(GlobalConfig.switchHwCurrentPowerCollect != collect || GlobalConfig.switchHwCurrentPowerInterval != c.getInterval()){
GlobalConfig.switchHwCurrentPowerInterval = c.getInterval(); flag = true;
GlobalConfig.switchHwCurrentPowerCollect = collect;
GlobalConfig.switchHwCurrentPowerInterval = c.getInterval();
if(!collect){
GlobalConfig.switchHwCurrentPowerInterval = 300;
}
}
} }
break; break;
} }
if(collect){ if (flag) {
long milli = AgentUtil.millisecondsToNext5Minute(); if(collect){
dynamicTaskService.scheduleTask(c.getType(), long milli = AgentUtil.millisecondsToNext5Minute();
() -> businessTasks.switchBoardTask(c.getType()), milli, GlobalConfig.switchNetInterval*1000L); dynamicTaskService.scheduleTask(c.getType(),
() -> businessTasks.switchBoardTask(c.getType()), milli, c.getInterval()*1000L);
}else{
dynamicTaskService.cancelTask(type);
}
} }
} }
} }
@@ -49,42 +49,70 @@ public class AlarmServiceImpl implements AlarmService {
String threshold = alarmEO.getThreshold(); String threshold = alarmEO.getThreshold();
int compareType = alarmEO.getCompareType(); int compareType = alarmEO.getCompareType();
AlarmVO alarmVO = AlarmVO.builder().type(type).timestamp(timestamp).build(); AlarmVO alarmVO = AlarmVO.builder().type(type).timestamp(timestamp).build();
String result = "";
switch(type) { switch(type) {
case "systemCpuUti": //CPU使用率 case "systemCpuUti": //CPU使用率
alarmVO.setResult(handleSystemCpuUti(threshold, compareType)); result = handleSystemCpuUti(threshold, compareType);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "memoryUtilization": //内存利用率 case "memoryUtilization": //内存利用率
alarmVO.setResult(handleMemoryUtilization(threshold, compareType)); result = handleMemoryUtilization(threshold, compareType);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "systemSwapSizePercent": //可用交换空间百分比 case "systemSwapSizePercent": //可用交换空间百分比
alarmVO.setResult(handleSystemSwapSizePercent(threshold, compareType)); result = handleSystemSwapSizePercent(threshold, compareType);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "systemUsersNum": //登录用户数 case "systemUsersNum": //登录用户数
alarmVO.setResult(handleSystemUsersNum(threshold, compareType)); result = handleSystemUsersNum(threshold, compareType);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "vfsFsUtil": //挂载点的空间利用率 case "vfsFsUtil": //挂载点的空间利用率
alarmVO.setResult(handleVfsFsUtil(threshold, compareType)); result = handleVfsFsUtil(threshold, compareType);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "netUtil": //网络带宽使用率 case "netUtil": //网络带宽使用率
alarmVO.setResult(handleNetUtil(threshold, compareType)); result = handleNetUtil(threshold, compareType);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "containerMemUtil": //容器内存使用率 case "containerMemUtil": //容器内存使用率
alarmVO.setResult(handleContainerMemUtil(threshold, compareType)); result = handleContainerMemUtil(threshold, compareType);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "netIfStatus": //网络运行状态UP变down case "netIfStatus": //网络运行状态UP变down
alarmVO.setResult(handleNetIfStatus()); result = handleNetIfStatus();
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
case "extraPorts": //多余端口 case "extraPorts": //多余端口
alarmVO.setResult(handleExtraPorts(threshold)); result = handleExtraPorts(threshold);
alarmVOList.add(alarmVO); if(StringUtils.isNotBlank(result)){
alarmVO.setResult(result);
alarmVOList.add(alarmVO);
}
break; break;
default: //其他 default: //其他
break; break;
+1 -1
View File
@@ -1,7 +1,7 @@
server: server:
port: 7010 port: 7010
servlet: servlet:
context-path: /agent-client context-path: /tr-agent-client
# 接口文档配置 # 接口文档配置
knife4j: knife4j:
+1 -1
View File
@@ -5,7 +5,7 @@ spring:
pathmatch: pathmatch:
matching-strategy: ant_path_matcher matching-strategy: ant_path_matcher
application: application:
name: agent-client name: tr-agent-client
version: 1.0 version: 1.0
web: web:
resources: resources: