Authored by qinchao

标签管理

... ... @@ -3,6 +3,7 @@ package com.monitor.cmdb.ctrl;
import com.alibaba.fastjson.JSON;
import com.model.HostInfo;
import com.monitor.cmdb.service.IHostInfoService;
import com.monitor.common.HostTagConstant;
import com.monitor.model.page.PageResponse;
import com.monitor.model.request.HostInfoReq;
import com.monitor.model.request.SetHostTagsReq;
... ... @@ -149,7 +150,7 @@ public class HostInfoCtrl {
@RequestMapping("/getHostInfoByTagNginx")
@ResponseBody
public String getHostInfoByTagNginx() throws Exception {
List<HostInfo> hostInfoList= hostInfoService.getHostInfosByTag("upstream-switch");
List<HostInfo> hostInfoList= hostInfoService.getHostInfosByTag(HostTagConstant.tag_upstreamSwitch);
Set<String> ips=new HashSet<String>();
if(hostInfoList!=null&&hostInfoList.size()>0){
for(HostInfo host:hostInfoList){
... ...
package com.monitor.common;
public class HostTagConstant {
public static final String tag_upstreamSwitch="upstream-switch";
public static final String tag_gateway="gateway";
public static final String tag_az1="az1";
public static final String tag_az2="az2";
public static final String tag_az3="az3";
public static final String tag_huidu_cn="灰度";
public static final String tag_upstreamSwitch="upstream-switch";
public static final String tag_NginxJAVA="Nginx-JAVA";
public static final String tag_luaSwitch="lua-switch";
public static final String tag_lbSwitch="lb-switch";
public static final String tag_limitSwitch="limit-switch";
}
... ...
... ... @@ -2,6 +2,7 @@ package com.monitor.compare.service;
import com.model.HostInfo;
import com.monitor.cmdb.service.IHostInfoService;
import com.monitor.common.HostTagConstant;
import com.monitor.compare.comparator.IpComparator;
import com.yoho.ops.cmdb.aws.lb.AwsLoadBalance;
import com.yoho.ops.cmdb.models.Host;
... ... @@ -70,7 +71,7 @@ public class NignxCompare {
List<String> cmdbIpList = new ArrayList<>();
for (HostInfo hostInfo : hostInfoService.getHostInfosByTag("Nginx-JAVA")) {
for (HostInfo hostInfo : hostInfoService.getHostInfosByTag(HostTagConstant.tag_NginxJAVA)) {
//1 aws 2 qcloud
if (2 == hostInfo.getCloudType()) {
... ... @@ -128,7 +129,7 @@ public class NignxCompare {
List<String> cmdbIpList = new ArrayList<>();
for (HostInfo hostInfo : hostInfoService.getHostInfosByTag("Nginx-JAVA")) {
for (HostInfo hostInfo : hostInfoService.getHostInfosByTag(HostTagConstant.tag_NginxJAVA)) {
//1 aws 2 qcloud
if (1 == hostInfo.getCloudType()) {
cmdbIpList.add(hostInfo.getHostIp());
... ...
... ... @@ -172,7 +172,7 @@
select
<include refid="Base_Column_List" />
from host_info
where instr(tags, concat(#{tag},',')) &gt; 0
where instr(concat(',',IFNULL(tags,'')), concat(',',#{tag},',')) &gt; 0
</select>
<select id="selectHostInfosByTagList" resultMap="BaseResultMap">
... ... @@ -182,9 +182,9 @@
where 1=1
<if test="tagsList != null &amp;&amp; tagsList.size > 0" >
and
<foreach open="(" close=")" item="item" index="index" collection="tagsList" separator="and">
instr(tags, concat(#{item},',')) &gt; 0
</foreach>
<foreach open="(" close=")" item="item" index="index" collection="tagsList" separator="and">
instr(concat(',',IFNULL(tags,'')), concat(',',#{item},',')) &gt; 0
</foreach>
</if>
</select>
... ...
... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.model.HostInfo;
import com.monitor.common.HostTagConstant;
import com.monitor.common.util.HandlebarsUtils;
import com.monitor.model.response.BaseResponse;
import com.monitor.mysql.mapper.HostInfoMapper;
... ... @@ -44,7 +45,7 @@ public class NginxLimit {
@RequestMapping(value = "viewConf")
@ResponseBody
public BaseResponse viewConf() throws Exception {
List<HostInfo> qcloudNginxHosts = hostInfoMapper.selectHostInfosByTag("limit-switch");
List<HostInfo> qcloudNginxHosts = hostInfoMapper.selectHostInfosByTag(HostTagConstant.tag_limitSwitch);
if (CollectionUtils.isEmpty(qcloudNginxHosts)) {
return new BaseResponse(500,"没有找到限流的nginx服务器",new HashMap<String,Object>());
}
... ... @@ -95,7 +96,7 @@ public class NginxLimit {
@ResponseBody
public BaseResponse switchNginxConf(HttpServletRequest httpRequest) {
//获取对应cloud的机器 aws 1 qcloud 2
List<HostInfo> nginxHosts = hostInfoMapper.selectHostInfosByTag("limit-switch");
List<HostInfo> nginxHosts = hostInfoMapper.selectHostInfosByTag(HostTagConstant.tag_limitSwitch);
if (CollectionUtils.isEmpty(nginxHosts)) {
return new BaseResponse(500, "在cmdb中未找到限流对应的nginx服务器!");
}
... ...