...
|
...
|
@@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.contants.AlarmGroupContants;
|
|
|
import com.model.DockerJenkinsRecord;
|
|
|
import com.model.DockerMonitorClusterModel;
|
|
|
import com.model.DockerMonitorServiceModel;
|
|
|
import com.monitor.common.service.AlarmMsgService;
|
|
|
import com.monitor.mysql.mapper.DockerJenkinsRecordMapper;
|
|
|
import com.monitor.mysql.mapper.DockerMonitorClusterMapper;
|
|
|
import com.monitor.mysql.mapper.DockerMonitorServiceMapper;
|
|
|
import com.monitor.other.worksystem.dock.qq.DockerServerDeployService;
|
|
|
import com.util.GetUsersInfoUtil;
|
...
|
...
|
@@ -36,6 +38,8 @@ public class DockerMonitorTask { |
|
|
|
|
|
private static String ALARMTEMPLATE = "DOCKER监控报警:集群%s,命名空间%s,服务名%s : %s";
|
|
|
|
|
|
@Autowired
|
|
|
private DockerMonitorClusterMapper dockerMonitorClusterMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private DockerServerDeployService txService;
|
...
|
...
|
@@ -76,6 +80,13 @@ public class DockerMonitorTask { |
|
|
}
|
|
|
|
|
|
synchronized (LOCK.intern()) {
|
|
|
Map<String,String> clusterIdAndDescrMap=new HashMap<>();
|
|
|
List<DockerMonitorClusterModel> clusterIds = dockerMonitorClusterMapper.selectAll();
|
|
|
if(clusterIds!=null&&clusterIds.size()>0){
|
|
|
for(DockerMonitorClusterModel clusterModel:clusterIds){
|
|
|
clusterIdAndDescrMap.put(clusterModel.getClusterId(),clusterModel.getDescr());
|
|
|
}
|
|
|
}
|
|
|
List<DockerMonitorServiceModel> serviceModels = dockerMonitorServiceMapper.selectAllMonitor();
|
|
|
for(DockerMonitorServiceModel model:serviceModels){
|
|
|
String simpleKey=model.getServiceName()+model.getClusterId()+model.getNamespace();
|
...
|
...
|
@@ -89,7 +100,7 @@ public class DockerMonitorTask { |
|
|
|
|
|
if(jsonArrayInst==null){
|
|
|
//报警
|
|
|
alarm(String.format(ALARMTEMPLATE,model.getClusterId(),model.getNamespace(),model.getServiceName(),"接口异常"));
|
|
|
alarm(String.format(ALARMTEMPLATE,model.getClusterId()+"["+clusterIdAndDescrMap.get(model.getClusterId())+"]",model.getNamespace(),model.getServiceName(),"接口异常"));
|
|
|
continue;
|
|
|
}
|
|
|
for(int i=0;i<jsonArrayInst.size();i++){
|
...
|
...
|
@@ -120,7 +131,7 @@ public class DockerMonitorTask { |
|
|
}
|
|
|
|
|
|
if(alarmFlag){
|
|
|
alarm(String.format(ALARMTEMPLATE,model.getClusterId(),model.getNamespace(),model.getServiceName(),name+"运行状态"+status+",原因"+reason));
|
|
|
alarm(String.format(ALARMTEMPLATE,model.getClusterId()+"["+clusterIdAndDescrMap.get(model.getClusterId())+"]",model.getNamespace(),model.getServiceName(),name+"运行状态"+status+",原因"+reason));
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -133,7 +144,7 @@ public class DockerMonitorTask { |
|
|
if(!"0".equals(restartCount)&&!lastCount.equals(restartCount)){
|
|
|
//
|
|
|
map.put(key2,restartCount);
|
|
|
alarm(String.format(ALARMTEMPLATE,model.getClusterId(),model.getNamespace(),model.getServiceName(),name+"当前重启次数"+restartCount+",原重启次数"+lastCount));
|
|
|
alarm(String.format(ALARMTEMPLATE,model.getClusterId()+"["+clusterIdAndDescrMap.get(model.getClusterId())+"]",model.getNamespace(),model.getServiceName(),name+"当前重启次数"+restartCount+",原重启次数"+lastCount));
|
|
|
|
|
|
}
|
|
|
}
|
...
|
...
|
|