...
|
...
|
@@ -316,11 +316,126 @@ 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();
|
|
|
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(infoReq.getNewInstanceIps().indexOf(mob.getMoHostIp())<0){
|
|
|
if(environment.equals("aws")&&mob.getMoHostIp().startsWith("172.")){
|
|
|
mObjectInfoMapper.deleteMoInfo(mob.getMoId());
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoId()+"\n");
|
|
|
}
|
|
|
if(environment.equals("qcloud")&&mob.getMoHostIp().startsWith("10.")){
|
|
|
mObjectInfoMapper.deleteMoInfo(mob.getMoId());
|
|
|
sb.append("删除"+typeName+"监控对象:"+mob.getMoId()+"\n");
|
|
|
}
|
|
|
}else{
|
|
|
existsHostIps.add(mob.getMoHostIp());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//处理新增的机器
|
|
|
String[] allIps=infoReq.getNewInstanceIps().split(",");
|
|
|
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.getMoId()+"\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();
|
...
|
...
|
|