Authored by qinchao

zk添加log4j监控

... ... @@ -62,6 +62,23 @@ public class ZkMonitorCtrl {
}
return new BaseResponse<PageResponse<ZkConfig>>(list);
}
/**
* 查询选中Ip下的根节点
* @param req
* @return
* @throws Exception
*/
@RequestMapping("/getZkMonitorTree4Log4j")
@ResponseBody
public BaseResponse<PageResponse<ZkConfig>> getZkMonitorTree4Log4j(@RequestBody ZkTreeReq req) throws Exception {
log.debug("getZkMonitorTree4Log4j with req is {}",req);
PageResponse<ZkConfig> list = zkMoitorService.getZkMonitorTree4Log4j(req);
if(list==null){
return new BaseResponse<PageResponse<ZkConfig>>();
}
return new BaseResponse<PageResponse<ZkConfig>>(list);
}
/**
* 查询跟节点下的所有子节点的路径和值
... ...
... ... @@ -18,6 +18,8 @@ public interface IZkMoitorService {
PageResponse<ZkConfig> getZkMonitorTree(ZkTreeReq req);
PageResponse<ZkConfig> getZkMonitorTree4Log4j(ZkTreeReq req);
PageResponse<ZkConfigAll> getZkMonitorDetail(ZkTreeAllReq req);
int editZkMonitorDetail(ZkTreeAllReq req);
... ...
... ... @@ -93,7 +93,16 @@ public class ZkMoitorServiceImpl implements IZkMoitorService {
@Override
public PageResponse<ZkConfig> getZkMonitorTree(ZkTreeReq req) {
return getZkMonitorTreeWithPath(req,"config");
}
@Override
public PageResponse<ZkConfig> getZkMonitorTree4Log4j(ZkTreeReq req) {
return getZkMonitorTreeWithPath(req,"log4j");
}
private PageResponse<ZkConfig> getZkMonitorTreeWithPath(ZkTreeReq req,String equalName) {
String hostIp = getHostIp(req.getIp());
PageResponse<ZkConfig> response = new PageResponse<ZkConfig>();
List<ZkConfig> list = new ArrayList<ZkConfig>();
... ... @@ -112,18 +121,18 @@ public class ZkMoitorServiceImpl implements IZkMoitorService {
zkConfig.setName(chi);
zkConfig.setRoot(rootString);
zkConfig.setIp(req.getIp());
if(chi.equals("config")){
if(chi.equals(equalName)){
list.add(zkConfig);
}
page++;
}
response.setCurrentPage(req.getCurrentPage());
response.setPageSize(req.getPageSize());
response.setTotal(page);
response.setRows(list);
response.setCurrentPage(req.getCurrentPage());
response.setPageSize(req.getPageSize());
response.setTotal(page);
response.setRows(list);
} catch (Exception e) {
logger.error("getZkMonitorTree fail with ip is {}",req.getIp());
e.printStackTrace();
... ...