|
|
package com.monitor.middleware.rabbitmq.task;
|
|
|
|
|
|
import com.model.MObjectInfo;
|
|
|
import com.model.RabbitAlertInfo;
|
|
|
import com.model.TypeInfo;
|
|
|
import com.monitor.cmdb.service.IMObjectInfoService;
|
|
|
import com.monitor.cmdb.service.ITypeInfoService;
|
|
|
import com.monitor.middleware.rabbitmq.constant.InterVar;
|
|
|
import com.monitor.mysql.mapper.RabbitAlertMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
...
|
...
|
@@ -14,6 +16,7 @@ import org.springframework.stereotype.Component; |
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -29,14 +32,16 @@ public class RabbitScanTask implements Runnable { |
|
|
@Autowired
|
|
|
ITypeInfoService typeService;
|
|
|
|
|
|
@Autowired
|
|
|
RabbitAlertMapper rabbitAlertMapper;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init()
|
|
|
{
|
|
|
public void init() {
|
|
|
InterVar.EXECUTOR_SERVICE.submit(this);
|
|
|
}
|
|
|
|
|
|
//自动发现rabbit监控对象
|
|
|
@Scheduled(fixedRate = 60*1000L)
|
|
|
@Scheduled(fixedRate = 60 * 1000L)
|
|
|
public void doTask() {
|
|
|
|
|
|
List<TypeInfo> typeInfosList = typeService.queryAllTypesInfo();
|
...
|
...
|
@@ -51,13 +56,30 @@ public class RabbitScanTask implements Runnable { |
|
|
}
|
|
|
}
|
|
|
|
|
|
synchronized (InterVar.LOCK.intern())
|
|
|
{
|
|
|
synchronized (InterVar.LOCK.intern()) {
|
|
|
|
|
|
for (MObjectInfo info : mObjectInfoList) {
|
|
|
|
|
|
InterVar.moMaps.put(info.getMoId(), info);
|
|
|
}
|
|
|
|
|
|
for (RabbitAlertInfo info : rabbitAlertMapper.getAllAlertsInfo()) {
|
|
|
|
|
|
HashMap<String, Integer> alertMap = new HashMap<>();
|
|
|
|
|
|
if (InterVar.alertMaps.containsKey(info.getMoId())) {
|
|
|
|
|
|
alertMap = InterVar.alertMaps.get(info.getMoId());
|
|
|
}
|
|
|
|
|
|
alertMap.put(info.getQueueName(), info.getAlertHigh());
|
|
|
|
|
|
InterVar.alertMaps.put(info.getMoId(), alertMap);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|