开启/更新采集测试及优化

This commit is contained in:
qiminbao
2025-09-13 14:21:20 +08:00
parent b2243cfb5b
commit f32d86938a
3 changed files with 95 additions and 86 deletions
@@ -143,7 +143,7 @@ public class AgentEndpoint {
json.put("resCode",1);
json.put("resMag","");
json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.开启或更新系统采集应答.getValue()).content(json.toString()).build();
return UpMsgResponse.builder().clientId(clientId).dataType(MsgEnum.开启或更新系统采集应答.getValue()).content(json.toString()).build();
}
}
@@ -159,7 +159,7 @@ public class AgentEndpoint {
json.put("resCode",1);
json.put("resMag","");
json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.关闭所有系统采集应答.getValue()).content(json.toString()).build();
return UpMsgResponse.builder().clientId(clientId).dataType(MsgEnum.关闭所有系统采集应答.getValue()).content(json.toString()).build();
}
}
@@ -175,7 +175,7 @@ public class AgentEndpoint {
json.put("resCode",1);
json.put("resMag","");
json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.开启或更新交换机采集应答.getValue()).content(json.toString()).build();
return UpMsgResponse.builder().clientId(clientId).dataType(MsgEnum.开启或更新交换机采集应答.getValue()).content(json.toString()).build();
}
}
@@ -191,7 +191,7 @@ public class AgentEndpoint {
json.put("resCode",1);
json.put("resMag","");
json.put("timestamp",timestamp);
return UpMsgResponse.builder().dataType(MsgEnum.关闭所有交换机采集应答.getValue()).content(json.toString()).build();
return UpMsgResponse.builder().clientId(clientId).dataType(MsgEnum.关闭所有交换机采集应答.getValue()).content(json.toString()).build();
}
}
@@ -1,6 +1,7 @@
package com.tongran.agent.client.scheduler.service;
import com.tongran.agent.client.core.config.GlobalConfig;
import com.tongran.agent.client.utils.AssertLog;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +43,7 @@ public class DynamicTaskService {
taskFutures.put(taskId, future);
GlobalConfig.taskIds.put(taskId, 0L);
AssertLog.info("添加或更新定时任务taskId={}",taskId);
}
/**
@@ -63,16 +63,19 @@ public class AgentServiceImpl implements AgentService {
if(jsonObject.containsKey("collects")){
String collects = jsonObject.getString("collects");
List<CollectEO> configList = JSON.parseObject(collects, new TypeReference<List<CollectEO>>() {});
AssertLog.info("开启或更新系统采集={}", JSON.toJSONString(configList));
for (CollectEO c : configList) {
String type = c.getType();
boolean collect = c.isCollect();
int interval = c.getInterval();
AssertLog.info("开启或更新系统采集2type={}, collect={}", type, collect);
switch(type) {
case "cpuCollect": //cpu采集
//判断与上次有无变化
if(GlobalConfig.cpuCollect != collect || GlobalConfig.cpuInterval != c.getInterval()){
if(GlobalConfig.cpuCollect != collect || GlobalConfig.cpuInterval != interval){
GlobalConfig.cpuCollect = collect;
if(collect){
GlobalConfig.cpuInterval = c.getInterval();
GlobalConfig.cpuInterval = interval;
long milli = AgentUtil.getMillisToNextMinute() + 60000;
dynamicTaskService.scheduleTask(type,
businessTasks::cpuTask, milli, GlobalConfig.cpuInterval*1000L);
@@ -83,10 +86,10 @@ public class AgentServiceImpl implements AgentService {
}
break;
case "vfsCollect": //挂载采集
if(GlobalConfig.vfsCollect != collect || GlobalConfig.vfsInterval != c.getInterval()){
if(GlobalConfig.vfsCollect != collect || GlobalConfig.vfsInterval != interval){
GlobalConfig.vfsCollect = collect;
if(collect){
GlobalConfig.vfsInterval = c.getInterval();
GlobalConfig.vfsInterval = interval;
long milli = AgentUtil.getMillisToNextMinute() + 60000;
dynamicTaskService.scheduleTask(type,
businessTasks::pointTask, milli, GlobalConfig.vfsInterval*1000L);
@@ -97,10 +100,10 @@ public class AgentServiceImpl implements AgentService {
}
break;
case "netCollect": //网络采集
if(GlobalConfig.netCollect != collect || GlobalConfig.netInterval != c.getInterval()){
if(GlobalConfig.netCollect != collect || GlobalConfig.netInterval != interval){
GlobalConfig.netCollect = collect;
if(collect){
GlobalConfig.netInterval = c.getInterval();
GlobalConfig.netInterval = interval;
long milli = AgentUtil.millisecondsToNext5Minute();
dynamicTaskService.scheduleTask(type,
businessTasks::netTask, milli, GlobalConfig.netInterval*1000L);
@@ -111,10 +114,10 @@ public class AgentServiceImpl implements AgentService {
}
break;
case "diskCollect": //磁盘采集
if(GlobalConfig.diskCollect != collect || GlobalConfig.diskInterval != c.getInterval()){
if(GlobalConfig.diskCollect != collect || GlobalConfig.diskInterval != interval){
GlobalConfig.diskCollect = collect;
if(collect){
GlobalConfig.diskInterval = c.getInterval();
GlobalConfig.diskInterval = interval;
long milli = AgentUtil.getMillisToNextMinute() + 60000;
dynamicTaskService.scheduleTask(type,
businessTasks::diskTask, milli, GlobalConfig.diskInterval*1000L);
@@ -125,10 +128,10 @@ public class AgentServiceImpl implements AgentService {
}
break;
case "dockerCollect": //docker采集
if(GlobalConfig.dockerCollect != collect || GlobalConfig.dockerInterval != c.getInterval()){
if(GlobalConfig.dockerCollect != collect || GlobalConfig.dockerInterval != interval){
GlobalConfig.dockerCollect = collect;
if(collect){
GlobalConfig.dockerInterval = c.getInterval();
GlobalConfig.dockerInterval = interval;
long milli = AgentUtil.getMillisToNextMinute() + 60000;
dynamicTaskService.scheduleTask(type,
businessTasks::dockerTask, milli, GlobalConfig.dockerInterval*1000L);
@@ -141,157 +144,157 @@ public class AgentServiceImpl implements AgentService {
default: //系统其他采集
boolean flag = false;
if(StringUtils.equals(type, "systemSwapSizeFreeCollect")){
if(GlobalConfig.systemSwapSizeFreeCollect != collect || GlobalConfig.systemSwapSizeFreeInterval != c.getInterval()){
if(GlobalConfig.systemSwapSizeFreeCollect != collect || GlobalConfig.systemSwapSizeFreeInterval != interval){
flag = true;
GlobalConfig.systemSwapSizeFreeCollect = collect;
GlobalConfig.systemSwapSizeFreeInterval = c.getInterval();
GlobalConfig.systemSwapSizeFreeInterval = interval;
if(!collect){
GlobalConfig.systemSwapSizeFreeInterval = 300;
}
}
}
if(StringUtils.equals(type, "memoryUtilizationCollect")){
if(GlobalConfig.memoryUtilizationCollect != collect || GlobalConfig.memoryUtilizationInterval != c.getInterval()){
if(GlobalConfig.memoryUtilizationCollect != collect || GlobalConfig.memoryUtilizationInterval != interval){
flag = true;
GlobalConfig.memoryUtilizationCollect = collect;
GlobalConfig.memoryUtilizationInterval = c.getInterval();
GlobalConfig.memoryUtilizationInterval = interval;
if(!collect){
GlobalConfig.memoryUtilizationInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemSwapSizePercentCollect")){
if(GlobalConfig.systemSwapSizePercentCollect != collect || GlobalConfig.systemSwapSizePercentInterval != c.getInterval()){
if(GlobalConfig.systemSwapSizePercentCollect != collect || GlobalConfig.systemSwapSizePercentInterval != interval){
flag = true;
GlobalConfig.systemSwapSizePercentCollect = collect;
GlobalConfig.systemSwapSizePercentInterval = c.getInterval();
GlobalConfig.systemSwapSizePercentInterval = interval;
if(!collect){
GlobalConfig.systemSwapSizePercentInterval = 300;
}
}
}
if(StringUtils.equals(type, "memorySizeAvailableCollect")){
if(GlobalConfig.memorySizeAvailableCollect != collect || GlobalConfig.memorySizeAvailableInterval != c.getInterval()){
if(GlobalConfig.memorySizeAvailableCollect != collect || GlobalConfig.memorySizeAvailableInterval != interval){
flag = true;
GlobalConfig.memorySizeAvailableCollect = collect;
GlobalConfig.memorySizeAvailableInterval = c.getInterval();
GlobalConfig.memorySizeAvailableInterval = interval;
if(!collect){
GlobalConfig.memorySizeAvailableInterval = 300;
}
}
}
if(StringUtils.equals(type, "memorySizePercentCollect")){
if(GlobalConfig.memorySizePercentCollect != collect || GlobalConfig.memorySizePercentInterval != c.getInterval()){
if(GlobalConfig.memorySizePercentCollect != collect || GlobalConfig.memorySizePercentInterval != interval){
flag = true;
GlobalConfig.memorySizePercentCollect = collect;
GlobalConfig.memorySizePercentInterval = c.getInterval();
GlobalConfig.memorySizePercentInterval = interval;
if(!collect){
GlobalConfig.memorySizePercentInterval = 300;
}
}
}
if(StringUtils.equals(type, "memorySizeTotalCollect")){
if(GlobalConfig.memorySizeTotalCollect != collect || GlobalConfig.memorySizeTotalInterval != c.getInterval()){
if(GlobalConfig.memorySizeTotalCollect != collect || GlobalConfig.memorySizeTotalInterval != interval){
flag = true;
GlobalConfig.memorySizeTotalCollect = collect;
GlobalConfig.memorySizeTotalInterval = c.getInterval();
GlobalConfig.memorySizeTotalInterval = interval;
if(!collect){
GlobalConfig.memorySizeTotalInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemSwOsCollect")){
if(GlobalConfig.systemSwOsCollect != collect || GlobalConfig.systemSwOsInterval != c.getInterval()){
if(GlobalConfig.systemSwOsCollect != collect || GlobalConfig.systemSwOsInterval != interval){
flag = true;
GlobalConfig.systemSwOsCollect = collect;
GlobalConfig.systemSwOsInterval = c.getInterval();
GlobalConfig.systemSwOsInterval = interval;
if(!collect){
GlobalConfig.systemSwOsInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemSwArchCollect")){
if(GlobalConfig.systemSwArchCollect != collect || GlobalConfig.systemSwArchInterval != c.getInterval()){
if(GlobalConfig.systemSwArchCollect != collect || GlobalConfig.systemSwArchInterval != interval){
flag = true;
GlobalConfig.systemSwArchCollect = collect;
GlobalConfig.systemSwArchInterval = c.getInterval();
GlobalConfig.systemSwArchInterval = interval;
if(!collect){
GlobalConfig.systemSwArchInterval = 300;
}
}
}
if(StringUtils.equals(type, "kernelMaxprocCollect")){
if(GlobalConfig.kernelMaxprocCollect != collect || GlobalConfig.kernelMaxprocInterval != c.getInterval()){
if(GlobalConfig.kernelMaxprocCollect != collect || GlobalConfig.kernelMaxprocInterval != interval){
flag = true;
GlobalConfig.kernelMaxprocCollect = collect;
GlobalConfig.kernelMaxprocInterval = c.getInterval();
GlobalConfig.kernelMaxprocInterval = interval;
if(!collect){
GlobalConfig.kernelMaxprocInterval = 300;
}
}
}
if(StringUtils.equals(type, "procNumRunCollect")){
if(GlobalConfig.procNumRunCollect != collect || GlobalConfig.procNumRunInterval != c.getInterval()){
if(GlobalConfig.procNumRunCollect != collect || GlobalConfig.procNumRunInterval != interval){
flag = true;
GlobalConfig.procNumRunCollect = collect;
GlobalConfig.procNumRunInterval = c.getInterval();
GlobalConfig.procNumRunInterval = interval;
if(!collect){
GlobalConfig.procNumRunInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemUsersNumCollect")){
if(GlobalConfig.systemUsersNumCollect != collect || GlobalConfig.systemUsersNumInterval != c.getInterval()){
if(GlobalConfig.systemUsersNumCollect != collect || GlobalConfig.systemUsersNumInterval != interval){
flag = true;
GlobalConfig.systemUsersNumCollect = collect;
GlobalConfig.systemUsersNumInterval = c.getInterval();
GlobalConfig.systemUsersNumInterval = interval;
if(!collect){
GlobalConfig.systemUsersNumInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemDiskSizeTotalCollect")){
if(GlobalConfig.systemDiskSizeTotalCollect != collect || GlobalConfig.systemDiskSizeTotalInterval != c.getInterval()){
if(GlobalConfig.systemDiskSizeTotalCollect != collect || GlobalConfig.systemDiskSizeTotalInterval != interval){
flag = true;
GlobalConfig.systemDiskSizeTotalCollect = collect;
GlobalConfig.systemDiskSizeTotalInterval = c.getInterval();
GlobalConfig.systemDiskSizeTotalInterval = interval;
if(!collect){
GlobalConfig.systemDiskSizeTotalInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemBoottimeCollect")){
if(GlobalConfig.systemBoottimeCollect != collect || GlobalConfig.systemBoottimeInterval != c.getInterval()){
if(GlobalConfig.systemBoottimeCollect != collect || GlobalConfig.systemBoottimeInterval != interval){
flag = true;
GlobalConfig.systemBoottimeCollect = collect;
GlobalConfig.systemBoottimeInterval = c.getInterval();
GlobalConfig.systemBoottimeInterval = interval;
if(!collect){
GlobalConfig.systemBoottimeInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemUnameCollect")){
if(GlobalConfig.systemUnameCollect != collect || GlobalConfig.systemUnameInterval != c.getInterval()){
if(GlobalConfig.systemUnameCollect != collect || GlobalConfig.systemUnameInterval != interval){
flag = true;
GlobalConfig.systemUnameCollect = collect;
GlobalConfig.systemUnameInterval = c.getInterval();
GlobalConfig.systemUnameInterval = interval;
if(!collect){
GlobalConfig.systemUnameInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemLocaltimeCollect")){
if(GlobalConfig.systemLocaltimeCollect != collect || GlobalConfig.systemLocaltimeInterval != c.getInterval()){
if(GlobalConfig.systemLocaltimeCollect != collect || GlobalConfig.systemLocaltimeInterval != interval){
flag = true;
GlobalConfig.systemLocaltimeCollect = collect;
GlobalConfig.systemLocaltimeInterval = c.getInterval();
GlobalConfig.systemLocaltimeInterval = interval;
if(!collect){
GlobalConfig.systemLocaltimeInterval = 300;
}
}
}
if(StringUtils.equals(type, "systemUptimeCollect")){
if(GlobalConfig.systemUptimeCollect != collect || GlobalConfig.systemUptimeInterval != c.getInterval()){
if(GlobalConfig.systemUptimeCollect != collect || GlobalConfig.systemUptimeInterval != interval){
flag = true;
GlobalConfig.systemUptimeCollect = collect;
GlobalConfig.systemUptimeInterval = c.getInterval();
@@ -319,12 +322,13 @@ public class AgentServiceImpl implements AgentService {
dynamicTaskService.cancelTask(type);
}
}
break;
}
}
}
}
@Override
public void systemCollectStop() {
String[] arr = {"cpuCollect","vfsCollect","netCollect","diskCollect","dockerCollect","systemSwapSizeFreeCollect","memoryUtilizationCollect"
@@ -396,53 +400,54 @@ public class AgentServiceImpl implements AgentService {
for (CollectEO c : configList) {
String type = c.getType();
boolean collect = c.isCollect();
int interval = c.getInterval();
boolean flag = false;
switch(type) {
case "switchNetCollect": //交换机网络采集
if(GlobalConfig.switchNetCollect != collect || GlobalConfig.switchNetInterval != c.getInterval()){
if(GlobalConfig.switchNetCollect != collect || GlobalConfig.switchNetInterval != interval){
flag = true;
GlobalConfig.switchNetCollect = collect;
GlobalConfig.switchNetInterval = c.getInterval();
GlobalConfig.switchNetInterval = interval;
if(!collect){
GlobalConfig.switchNetInterval = 300;
}
}
break;
case "switchModuleCollect": //光模块采集
if(GlobalConfig.switchModuleCollect != collect || GlobalConfig.switchModuleInterval != c.getInterval()){
if(GlobalConfig.switchModuleCollect != collect || GlobalConfig.switchModuleInterval != interval){
flag = true;
GlobalConfig.switchModuleCollect = collect;
GlobalConfig.switchModuleInterval = c.getInterval();
GlobalConfig.switchModuleInterval = interval;
if(!collect){
GlobalConfig.switchModuleInterval = 300;
}
}
break;
case "switchMpuCollect": //MPU采集
if(GlobalConfig.switchMpuCollect != collect || GlobalConfig.switchMpuInterval != c.getInterval()){
if(GlobalConfig.switchMpuCollect != collect || GlobalConfig.switchMpuInterval != interval){
flag = true;
GlobalConfig.switchMpuCollect = collect;
GlobalConfig.switchMpuInterval = c.getInterval();
GlobalConfig.switchMpuInterval = interval;
if(!collect){
GlobalConfig.switchMpuInterval = 300;
}
}
break;
case "switchPwrCollect": //电源采集
if(GlobalConfig.switchPwrCollect != collect || GlobalConfig.switchPwrInterval != c.getInterval()){
if(GlobalConfig.switchPwrCollect != collect || GlobalConfig.switchPwrInterval != interval){
flag = true;
GlobalConfig.switchPwrCollect = collect;
GlobalConfig.switchPwrInterval = c.getInterval();
GlobalConfig.switchPwrInterval = interval;
if(!collect){
GlobalConfig.switchPwrInterval = 300;
}
}
break;
case "dockerCollect": //风扇采集
if(GlobalConfig.switchFanCollect != collect || GlobalConfig.switchFanInterval != c.getInterval()){
if(GlobalConfig.switchFanCollect != collect || GlobalConfig.switchFanInterval != interval){
flag = true;
GlobalConfig.switchFanCollect = collect;
GlobalConfig.switchFanInterval = c.getInterval();
GlobalConfig.switchFanInterval = interval;
if(!collect){
GlobalConfig.switchFanInterval = 300;
}
@@ -450,152 +455,151 @@ public class AgentServiceImpl implements AgentService {
break;
default: //系统其他采集
if(StringUtils.equals(type, "switchSysDescrCollect")){
if(GlobalConfig.switchSysDescrCollect != collect || GlobalConfig.switchSysDescrInterval != c.getInterval()){
if(GlobalConfig.switchSysDescrCollect != collect || GlobalConfig.switchSysDescrInterval != interval){
flag = true;
GlobalConfig.switchSysDescrCollect = collect;
GlobalConfig.switchSysDescrInterval = c.getInterval();
GlobalConfig.switchSysDescrInterval = interval;
if(!collect){
GlobalConfig.switchSysDescrInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchSysObjectIDCollect")){
if(GlobalConfig.switchSysObjectIDCollect != collect || GlobalConfig.switchSysObjectIDInterval != c.getInterval()){
if(GlobalConfig.switchSysObjectIDCollect != collect || GlobalConfig.switchSysObjectIDInterval != interval){
flag = true;
GlobalConfig.switchSysObjectIDCollect = collect;
GlobalConfig.switchSysObjectIDInterval = c.getInterval();
GlobalConfig.switchSysObjectIDInterval = interval;
if(!collect){
GlobalConfig.switchSysObjectIDInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchSysUpTimeCollect")){
if(GlobalConfig.switchSysUpTimeCollect != collect || GlobalConfig.switchSysUpTimeInterval != c.getInterval()){
if(GlobalConfig.switchSysUpTimeCollect != collect || GlobalConfig.switchSysUpTimeInterval != interval){
flag = true;
GlobalConfig.switchSysUpTimeCollect = collect;
GlobalConfig.switchSysUpTimeInterval = c.getInterval();
GlobalConfig.switchSysUpTimeInterval = interval;
if(!collect){
GlobalConfig.switchSysUpTimeInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchSysContactCollect")){
if(GlobalConfig.switchSysContactCollect != collect || GlobalConfig.switchSysContactInterval != c.getInterval()){
if(GlobalConfig.switchSysContactCollect != collect || GlobalConfig.switchSysContactInterval != interval){
flag = true;
GlobalConfig.switchSysContactCollect = collect;
GlobalConfig.switchSysContactInterval = c.getInterval();
GlobalConfig.switchSysContactInterval = interval;
if(!collect){
GlobalConfig.switchSysContactInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchSysNameCollect")){
if(GlobalConfig.switchSysNameCollect != collect || GlobalConfig.switchSysNameInterval != c.getInterval()){
if(GlobalConfig.switchSysNameCollect != collect || GlobalConfig.switchSysNameInterval != interval){
flag = true;
GlobalConfig.switchSysNameCollect = collect;
GlobalConfig.switchSysNameInterval = c.getInterval();
GlobalConfig.switchSysNameInterval = interval;
if(!collect){
GlobalConfig.switchSysNameInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchSysLocationCollect")){
if(GlobalConfig.switchSysLocationCollect != collect || GlobalConfig.switchSysLocationInterval != c.getInterval()){
if(GlobalConfig.switchSysLocationCollect != collect || GlobalConfig.switchSysLocationInterval != interval){
flag = true;
GlobalConfig.switchSysLocationCollect = collect;
GlobalConfig.switchSysLocationInterval = c.getInterval();
GlobalConfig.switchSysLocationInterval = interval;
if(!collect){
GlobalConfig.switchSysLocationInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchHwStackSystemMacCollect")){
if(GlobalConfig.switchHwStackSystemMacCollect != collect || GlobalConfig.switchHwStackSystemMacInterval != c.getInterval()){
if(GlobalConfig.switchHwStackSystemMacCollect != collect || GlobalConfig.switchHwStackSystemMacInterval != interval){
flag = true;
GlobalConfig.switchHwStackSystemMacCollect = collect;
GlobalConfig.switchHwStackSystemMacInterval = c.getInterval();
GlobalConfig.switchHwStackSystemMacInterval = interval;
if(!collect){
GlobalConfig.switchHwStackSystemMacInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchEntIndexCollect")){
if(GlobalConfig.switchEntIndexCollect != collect || GlobalConfig.switchEntIndexInterval != c.getInterval()){
if(GlobalConfig.switchEntIndexCollect != collect || GlobalConfig.switchEntIndexInterval != interval){
flag = true;
GlobalConfig.switchEntIndexCollect = collect;
GlobalConfig.switchEntIndexInterval = c.getInterval();
GlobalConfig.switchEntIndexInterval = interval;
if(!collect){
GlobalConfig.switchEntIndexInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchEntPhysicalNameCollect")){
if(GlobalConfig.switchEntPhysicalNameCollect != collect || GlobalConfig.switchEntPhysicalNameInterval != c.getInterval()){
if(GlobalConfig.switchEntPhysicalNameCollect != collect || GlobalConfig.switchEntPhysicalNameInterval != interval){
flag = true;
GlobalConfig.switchEntPhysicalNameCollect = collect;
GlobalConfig.switchEntPhysicalNameInterval = c.getInterval();
GlobalConfig.switchEntPhysicalNameInterval = interval;
if(!collect){
GlobalConfig.switchEntPhysicalNameInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchEntPhysicalSoftwareRevCollect")){
if(GlobalConfig.switchEntPhysicalSoftwareRevCollect != collect || GlobalConfig.switchEntPhysicalSoftwareRevInterval != c.getInterval()){
if(GlobalConfig.switchEntPhysicalSoftwareRevCollect != collect || GlobalConfig.switchEntPhysicalSoftwareRevInterval != interval){
flag = true;
GlobalConfig.switchEntPhysicalSoftwareRevCollect = collect;
GlobalConfig.switchEntPhysicalSoftwareRevInterval = c.getInterval();
GlobalConfig.switchEntPhysicalSoftwareRevInterval = interval;
if(!collect){
GlobalConfig.switchEntPhysicalSoftwareRevInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchHwEntityCpuUsageCollect")){
if(GlobalConfig.switchHwEntityCpuUsageCollect != collect || GlobalConfig.switchHwEntityCpuUsageInterval != c.getInterval()){
if(GlobalConfig.switchHwEntityCpuUsageCollect != collect || GlobalConfig.switchHwEntityCpuUsageInterval != interval){
flag = true;
GlobalConfig.switchHwEntityCpuUsageCollect = collect;
GlobalConfig.switchHwEntityCpuUsageInterval = c.getInterval();
GlobalConfig.switchHwEntityCpuUsageInterval = interval;
if(!collect){
GlobalConfig.switchHwEntityCpuUsageInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchHwEntityMemUsageCollect")){
if(GlobalConfig.switchHwEntityMemUsageCollect != collect || GlobalConfig.switchHwEntityMemUsageInterval != c.getInterval()){
if(GlobalConfig.switchHwEntityMemUsageCollect != collect || GlobalConfig.switchHwEntityMemUsageInterval != interval){
flag = true;
GlobalConfig.switchHwEntityMemUsageCollect = collect;
GlobalConfig.switchHwEntityMemUsageInterval = c.getInterval();
GlobalConfig.switchHwEntityMemUsageInterval = interval;
if(!collect){
GlobalConfig.switchHwEntityMemUsageInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchHwAveragePowerCollect")){
if(GlobalConfig.switchHwAveragePowerCollect != collect || GlobalConfig.switchHwAveragePowerInterval != c.getInterval()){
if(GlobalConfig.switchHwAveragePowerCollect != collect || GlobalConfig.switchHwAveragePowerInterval != interval){
flag = true;
GlobalConfig.switchHwAveragePowerCollect = collect;
GlobalConfig.switchHwAveragePowerInterval = c.getInterval();
GlobalConfig.switchHwAveragePowerInterval = interval;
if(!collect){
GlobalConfig.switchHwAveragePowerInterval = 300;
}
}
}
if(StringUtils.equals(type, "switchHwCurrentPowerCollect")){
if(GlobalConfig.switchHwCurrentPowerCollect != collect || GlobalConfig.switchHwCurrentPowerInterval != c.getInterval()){
if(GlobalConfig.switchHwCurrentPowerCollect != collect || GlobalConfig.switchHwCurrentPowerInterval != interval){
flag = true;
GlobalConfig.switchHwCurrentPowerCollect = collect;
GlobalConfig.switchHwCurrentPowerInterval = c.getInterval();
GlobalConfig.switchHwCurrentPowerInterval = interval;
if(!collect){
GlobalConfig.switchHwCurrentPowerInterval = 300;
}
}
}
break;
}
if (flag) {
if(collect){
long milli = AgentUtil.millisecondsToNext5Minute();
dynamicTaskService.scheduleTask(c.getType(),
() -> businessTasks.switchBoardTask(c.getType()), milli, c.getInterval()*1000L);
() -> businessTasks.switchBoardTask(c.getType()), milli, interval*1000L);
}else{
dynamicTaskService.cancelTask(type);
}
@@ -771,4 +775,7 @@ public class AgentServiceImpl implements AgentService {
}
public void caseTypeBySystem(String type, int interval, boolean collect){
}
}