...
|
...
|
@@ -316,11 +316,134 @@ public class CloudToolServiceImpl implements CloudToolService { |
|
|
return updateMobject4Nginx(infoReq);
|
|
|
}else if ("PCH5-memcache".equalsIgnoreCase(infoReq.getScalingGroupName())||"java-gateway-memcache".equalsIgnoreCase(infoReq.getScalingGroupName())){
|
|
|
return updateMemcacheInfoForMobject(infoReq);
|
|
|
}else if("ELASTICSEARCH".equalsIgnoreCase(infoReq.getScalingGroupName())){
|
|
|
//暂时不做
|
|
|
}else if("PCH5-NODE".equalsIgnoreCase(infoReq.getScalingGroupName())||"PCH5-AutoScaling".equalsIgnoreCase(infoReq.getScalingGroupName())){
|
|
|
//暂时不做
|
|
|
}else{
|
|
|
////// 普通java项目
|
|
|
return updateMobject4JavaApp(infoReq);
|
|
|
}
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/// java app的监控配置,java_nginx 既包括172 ,又包括10,所以更新的时候,如果要删除需要只删除当前云
|
|
|
private BaseResponse updateMobject4JavaApp(AutoScalingInfoReq infoReq){
|
|
|
BaseResponse res = new BaseResponse();
|
|
|
String environment="";
|
|
|
if(1==infoReq.getCloudType()){
|
|
|
environment="aws";
|
|
|
}else if(2==infoReq.getCloudType()){
|
|
|
environment="qcloud";
|
|
|
}
|
|
|
String mobjectPaths=infoReq.getMobjectPaths();
|
|
|
String[] mobjectPaths_array=mobjectPaths.split(",");
|
|
|
String typeNames=mobjectPaths_array[mobjectPaths_array.length-1];//////////有可能是多个,比如activity-bigdata
|
|
|
StringBuilder sb=new StringBuilder();
|
|
|
|
|
|
String[] allIps=infoReq.getNewInstanceIps().split(",");
|
|
|
List<String> allIpsList=new ArrayList<String>();
|
|
|
for(String ip:allIps){
|
|
|
if(StringUtils.isNotBlank(ip)){
|
|
|
allIpsList.add(ip);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for(String typeName:typeNames.split("-")){
|
|
|
mobjectPaths_array[mobjectPaths_array.length-1]=typeName;
|
|
|
TypeInfo typeInfo = getTypeByMobjectPathArray(mobjectPaths_array);
|
|
|
if(typeInfo!=null){
|
|
|
List<MObjectInfo> objectInfoList = mObjectInfoMapper.getTypeMosInfo(typeInfo.getTypeId());
|
|
|
List<String> existsHostIps=new ArrayList<String>();
|
|
|
if(objectInfoList!=null&&objectInfoList.size()>0){
|
|
|
for(MObjectInfo mob:objectInfoList){
|
|
|
//处理移除的机器,但是要保留另外一个云的机器信息
|
|
|
if(!allIpsList.contains(mob.getMoHostIp())){
|
|
|
if(environment.equals("aws")&&mob.getMoHostIp().startsWith("172.")){
|
|
|
mObjectInfoMapper.deleteMoInfo(mob.getMoId());
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}
|
|
|
if(environment.equals("qcloud")&&mob.getMoHostIp().startsWith("10.")){
|
|
|
mObjectInfoMapper.deleteMoInfo(mob.getMoId());
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}
|
|
|
}else{
|
|
|
existsHostIps.add(mob.getMoHostIp());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//处理新增的机器
|
|
|
for(String ip:allIps){
|
|
|
if(StringUtils.isNotBlank(ip)&&!existsHostIps.contains(ip)){
|
|
|
MObjectInfo mob=new MObjectInfo();
|
|
|
mob.setMoName(buildMoName(typeName,environment));
|
|
|
mob.setMoHostIp(ip);
|
|
|
mob.setMoTags(getMobjectTagsForJavaApp(typeName));
|
|
|
mob.setMoTypeId(typeInfo.getTypeId());
|
|
|
mObjectInfoMapper.insertMoInfo(mob);
|
|
|
sb.append("添加"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
res.setData(sb.toString());
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
// 获取java app的标签 :端口号
|
|
|
private String getMobjectTagsForJavaApp(String typeName){
|
|
|
String tag="";
|
|
|
switch (typeName){
|
|
|
case "gateway":
|
|
|
tag="8080";
|
|
|
break;
|
|
|
case "order":
|
|
|
tag="8084";
|
|
|
break;
|
|
|
case "promotion":
|
|
|
tag="8085";
|
|
|
break;
|
|
|
case "product":
|
|
|
tag="8083";
|
|
|
break;
|
|
|
case "message":
|
|
|
tag="8086";
|
|
|
break;
|
|
|
case "sns":
|
|
|
tag="8082";
|
|
|
break;
|
|
|
case "users":
|
|
|
tag="8081";
|
|
|
break;
|
|
|
case "resources":
|
|
|
tag="8087";
|
|
|
break;
|
|
|
case "activity":
|
|
|
tag="8090";
|
|
|
break;
|
|
|
case "union":
|
|
|
tag="";
|
|
|
break;
|
|
|
case "brower":
|
|
|
tag="8092";
|
|
|
break;
|
|
|
case "social":
|
|
|
tag="8095";
|
|
|
break;
|
|
|
case "uic":
|
|
|
tag="8096";
|
|
|
break;
|
|
|
case "bigdata":
|
|
|
tag="";
|
|
|
break;
|
|
|
case "yoho!now":
|
|
|
tag="";
|
|
|
break;
|
|
|
}
|
|
|
return tag;
|
|
|
}
|
|
|
/// nginx的监控配置,java_nginx 既包括172 ,又包括10,所以更新的时候,如果要删除需要只删除当前云
|
|
|
private BaseResponse updateMobject4Nginx(AutoScalingInfoReq infoReq){
|
|
|
BaseResponse res = new BaseResponse();
|
...
|
...
|
@@ -343,18 +466,27 @@ public class CloudToolServiceImpl implements CloudToolService { |
|
|
|
|
|
StringBuilder sb=new StringBuilder();
|
|
|
List<MObjectInfo> objectInfoList = mObjectInfoMapper.getTypeMosInfo(typeInfo.getTypeId());
|
|
|
|
|
|
String[] allIps=infoReq.getNewInstanceIps().split(",");
|
|
|
List<String> allIpsList=new ArrayList<String>();
|
|
|
for(String ip:allIps){
|
|
|
if(StringUtils.isNotBlank(ip)){
|
|
|
allIpsList.add(ip);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<String> existsHostIps=new ArrayList<String>();
|
|
|
if(objectInfoList!=null&&objectInfoList.size()>0){
|
|
|
for(MObjectInfo mob:objectInfoList){
|
|
|
//处理移除的机器,但是要保留另外一个云的机器信息
|
|
|
if(infoReq.getNewInstanceIps().indexOf(mob.getMoHostIp())<0){
|
|
|
if(!allIpsList.contains(mob.getMoHostIp())){
|
|
|
if(environment.equals("aws")&&mob.getMoHostIp().startsWith("172.")){
|
|
|
mObjectInfoMapper.deleteMoInfo(mob.getMoId());
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoId()+"\n");
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}
|
|
|
if(environment.equals("qcloud")&&mob.getMoHostIp().startsWith("10.")){
|
|
|
mObjectInfoMapper.deleteMoInfo(mob.getMoId());
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoId()+"\n");
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}
|
|
|
}else{
|
|
|
existsHostIps.add(mob.getMoHostIp());
|
...
|
...
|
@@ -362,7 +494,6 @@ public class CloudToolServiceImpl implements CloudToolService { |
|
|
}
|
|
|
}
|
|
|
//处理新增的机器
|
|
|
String[] allIps=infoReq.getNewInstanceIps().split(",");
|
|
|
for(String ip:allIps){
|
|
|
if(StringUtils.isNotBlank(ip)&&!existsHostIps.contains(ip)){
|
|
|
MObjectInfo mob=new MObjectInfo();
|
...
|
...
|
@@ -370,7 +501,7 @@ public class CloudToolServiceImpl implements CloudToolService { |
|
|
mob.setMoHostIp(ip);
|
|
|
mob.setMoTypeId(typeInfo.getTypeId());
|
|
|
mObjectInfoMapper.insertMoInfo(mob);
|
|
|
sb.append("添加"+typeName+"监控对象:"+mob.getMoId()+"\n");
|
|
|
sb.append("添加"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}
|
|
|
}
|
|
|
res.setData(sb.toString());
|
...
|
...
|
@@ -400,13 +531,22 @@ public class CloudToolServiceImpl implements CloudToolService { |
|
|
|
|
|
StringBuilder sb=new StringBuilder();
|
|
|
List<MObjectInfo> objectInfoList = mObjectInfoMapper.getTypeMosInfo(typeInfo.getTypeId());
|
|
|
|
|
|
String[] allIps=infoReq.getNewInstanceIps().split(",");
|
|
|
List<String> allIpsList=new ArrayList<String>();
|
|
|
for(String ip:allIps){
|
|
|
if(StringUtils.isNotBlank(ip)){
|
|
|
allIpsList.add(ip);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<String> existsHostIps=new ArrayList<String>();
|
|
|
if(objectInfoList!=null&&objectInfoList.size()>0){
|
|
|
for(MObjectInfo mob:objectInfoList){
|
|
|
//处理移除的机器
|
|
|
if(infoReq.getNewInstanceIps().indexOf(mob.getMoHostIp())<0){
|
|
|
if(!allIpsList.contains(mob.getMoHostIp())){
|
|
|
mObjectInfoMapper.deleteMoInfo(mob.getMoId());
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoId()+"\n");
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}else{
|
|
|
existsHostIps.add(mob.getMoHostIp());
|
|
|
}
|
...
|
...
|
@@ -417,7 +557,7 @@ public class CloudToolServiceImpl implements CloudToolService { |
|
|
if(typeName.indexOf("java")>0){
|
|
|
port="port:21211";
|
|
|
}
|
|
|
String[] allIps=infoReq.getNewInstanceIps().split(",");
|
|
|
|
|
|
for(String ip:allIps){
|
|
|
if(StringUtils.isNotBlank(ip)&&!existsHostIps.contains(ip)){
|
|
|
MObjectInfo mob=new MObjectInfo();
|
...
|
...
|
@@ -426,7 +566,7 @@ public class CloudToolServiceImpl implements CloudToolService { |
|
|
mob.setMoHostIp(ip);
|
|
|
mob.setMoTypeId(typeInfo.getTypeId());
|
|
|
mObjectInfoMapper.insertMoInfo(mob);
|
|
|
sb.append("添加"+typeName+"监控对象:"+mob.getMoId()+"\n");
|
|
|
sb.append("添加"+typeName+"监控对象:"+mob.getMoHostIp()+"\n");
|
|
|
}
|
|
|
}
|
|
|
res.setData(sb.toString());
|
...
|
...
|
|