Authored by qinchao

删除恶意ip需要接口:nginx标签的机器

package com.monitor.cmdb.ctrl;
import com.alibaba.fastjson.JSON;
import com.model.HostInfo;
import com.monitor.cmdb.service.IHostInfoService;
import com.monitor.model.request.HostInfoReq;
import com.monitor.model.response.PageResponse;
import com.monitor.model.response.BaseResponse;
import com.monitor.model.response.PageResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -15,13 +16,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Created by yoho on 2016/6/14.
* 查询机器信息
*/
@Controller
@RequestMapping("hostInfo")
@RequestMapping("/hostInfo")
public class HostInfoCtrl {
Logger log = LoggerFactory.getLogger(HostInfoCtrl.class);
... ... @@ -82,5 +87,22 @@ public class HostInfoCtrl {
return resp;
}
/**
* 获取所有具有nginx标签的主机信息,返回给外系统(恶意ip捕获)调用
* @return
* @throws Exception
*/
@RequestMapping("/getHostInfoByTagNginx")
@ResponseBody
public String getHostInfoByTagNginx() throws Exception {
List<HostInfo> hostInfoList= hostInfoService.getHostInfosByTag("nginx");
Set<String> ips=new HashSet<String>();
if(hostInfoList!=null&&hostInfoList.size()>0){
for(HostInfo host:hostInfoList){
ips.add(host.getHostIp());
}
}
return JSON.toJSONString(ips);
}
}
... ...