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