Authored by qinchao

zk添加log4j监控

... ... @@ -71,6 +71,11 @@ public class HttpUriContants {
public static final String EDIT_ZK_ROOT = "/zkMonitor/editZkMonitorRoot";
/***
* ZK监控信息查询 log4j
****/
public static final String GET_ZK_TREE_LOG4J = "/zkMonitor/getZkMonitorTree4Log4j";
/***
* ZK 服务监控查询
****/
public static final String GET_ZK_SVC_LIST = "/zkSvcLookup/getAllSvc";
... ...
... ... @@ -34,6 +34,11 @@ public class ZkMonitorTreeCtrl {
return new ModelAndView("zkMonitor/zkMonitorList");
}
@RequestMapping("/tozkMonitorList4Log4j")
public ModelAndView tozkMonitorList4Log4j() {
return new ModelAndView("zkMonitor/zkMonitorList4Log4j");
}
@RequestMapping("/getRoot")
@ResponseBody
public BaseResponse getRoot(ZkTreeReq req){
... ... @@ -42,6 +47,14 @@ public class ZkMonitorTreeCtrl {
return response;
}
@RequestMapping("/getRoot4Log4j")
@ResponseBody
public BaseResponse getRoot4Log4j(ZkTreeReq req){
log.info("getRoot4Log4j with req is {}",req);
BaseResponse response=httpClient.defaultPost(HttpUriContants.GET_ZK_TREE_LOG4J, req, BaseResponse.class);
return response;
}
@RequestMapping("/getAll")
@ResponseBody
public BaseResponse getAll(ZkDetailReq req){
... ...
... ... @@ -236,7 +236,7 @@
</div>
</div>
</body>
<script src="<%=basePath %>script/common/genarate_left_panel.js?v=20171016-1"></script>
<script src="<%=basePath %>script/common/genarate_left_panel.js?v=20171023-1"></script>
<script type="text/javascript">
$("#li_dashboard").addClass("active");
</script>
... ...
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-datetimepicker.css"/>
<link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>css/yoho.css"/>
<script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>/js/bootstrap.min.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jstree/jstree.js"></script>
<script src="<%=basePath %>js/jquery.toaster.js"></script>
<link href="<%=basePath %>css/jquery.tagsinput.css" rel="stylesheet"/>
<script src="<%=basePath %>js/jquery.tagsinput.min.js" type="text/javascript"></script>
<script>
var contextPath = '<%=basePath %>';
</script>
<title>YOHO!运维</title>
</head>
<body>
<!-- 头部 -->
<div id="head">
</div>
<!-- 右侧具体内容 -->
<div id="content">
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">监控对象</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>ZK配置</h5>
</div>
<!-- 树 -->
<div style="float: left;width: 250px;color: #D3D3D3;height: 600px;">
<div class="widget-title" style="height: 50px;">
<h5>节点展示</h5>
</div>
<div class="tree_container" style="height: 540px;color: black;overflow:auto;">
<div id="jstree" class="jstree jstree-default" role="tree" aria-multiselectable="true"
tabindex="0"></div>
</div>
</div>
<!-- 列表 -->
<div class="widget-content nopadding" style="border-left: 1px solid #E5E5E5;width: 450px;float: left;">
<div class="widget-title" style="height: 50px;">
<h5>根路径</h5>
</div>
<div class="widget-content nopadding">
<div class="tree_container" style="height: 540px;color: black;overflow:auto;">
<div id="rootTable"></div>
</div>
</div>
</div>
<div class="widget-content nopadding" style="margin-left: 700px;border-left: 1px solid #E5E5E5;">
<div class="widget-title" style="height: 50px;">
<h5>节点详情</h5>
</div>
<div class="widget-content nopadding">
<div class="tree_container" style="height: 540px;color: black;overflow:auto;">
<div id="detailTable"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="<%=basePath %>/script/yoho.type.zktree.log4j.js"></script>
<script>
function toDetail(rowData,ip){
$("#detailTable").show();
$(function () {
$("#detailTable").table({
url: contextPath + "/zkTree/getAll?ip="+ip+"&zkPath="+rowData.root,
striped : true,
pagination : false,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "名称",
width:"60%",
align:"left",
field: "zkName"
}/*, {
title: "值",
width:"20%",
field: "zkValue"
}*/, {
title: "操作",
width:"20%",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
//修改
var editBtn = $("<button data-target='#updateModal' data-toggle='modal'>").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
/* editBtn.click(function () {
updateMObject(rowData);
});*/
return div;
}
}],
});
});
}
function updateMObject(rowData){
paramObj.zkPath = rowData.zkPath;
paramObj.zkValue = rowData.zkValue;
paramObj.zkName = rowData.zkName;
var dialog0 = $("<div>").appendTo($("body"));
dialog0.dialog({
size : "modal-lg",
title : "修改路径",
backdrop : "static",
href : contextPath +"/jsp/zkMonitor/zkMonitorEdit.jsp",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog0).dialog("hide");
}
}, {
text : "提交",
className : "btn-success",
onclick : function() {
var btn = $(this);
$(dialog0).dialog("hide");
$("#zkInfoForm").form("submit", {
submitUrl : contextPath + "/zkTree/editDetail.do",
submitData : {
ip : rowData.ip,
zkPath : rowData.zkPath
},
onBeforeSubmit : function() {
if (!$(this).form("validate")) {
btn.removeAttr("disabled");
return false;
}
},
success : function(data) {
var mes="";
if(data.data==1){
mes="修改成功";
}else{
mes="修改失败";
}
if(data.data==1){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title :mes,
backdrop : "static",
content : mes,
buttons : [{
text : "确定",
className : "btn-success",
onclick : function() {
$(dialog).dialog("hide");
$("#detailTable").table("load");
}
}]
});
}
$(dialog0).dialog("hide");
}
});
}
}]
});
}
</script>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script type="text/javascript">
$("#li_config").addClass("active open");
$("#li_zkMonitor_log4j").addClass("active");
</script>
</html>
\ No newline at end of file
... ...
... ... @@ -66,8 +66,9 @@ innerHTML += "</ul></li>";
innerHTML += "</ul></li>";*/
/*配置管理*/
innerHTML += "<li class='submenu' id='li_config'><a id='li_config_a' href='#'><i class='icon icon-th-list'></i> <span>配置管理</span><span class='label'>8</span></a><ul>";
innerHTML += "<li class='submenu' id='li_config'><a id='li_config_a' href='#'><i class='icon icon-th-list'></i> <span>配置管理</span><span class='label'>9</span></a><ul>";
innerHTML += "<li id='li_zkMonitor'><a id='li_zkMonitor_a' href=''><i class='icon icon-th'></i> <span>ZK配置管理</span></a></li>";
innerHTML += "<li id='li_zkMonitor_log4j'><a id='li_zkMonitor_log4j_a' href=''><i class='icon icon-th'></i> <span>ZK_log4j配置管理</span></a></li>";
innerHTML += "<li id='li_nginxSync'><a id='li_nginxSync_a' href=''><i class='icon icon-th'></i> <span>Nginx配置同步</span></a></li>";
innerHTML += "<li id='li_degrade_info'><a id='li_degrade_info_a' href=''><i class='icon icon-th'></i> <span>降级服务配置</span></a></li>";
innerHTML += "<li id='li_app_degrade'><a id='li_app_degrade_a' href=''><i class='icon icon-th'></i> <span>APP降级管理</span></a></li>";
... ... @@ -157,6 +158,7 @@ document.getElementById("changepwd_a").setAttribute("href", path + "/user/toupda
document.getElementById("li_sms_a").setAttribute("href", path + "/sms/toSmsLog");
document.getElementById("li_search_compare_a").setAttribute("href", path + "/searchCompare/getComparePage");
document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList");
document.getElementById("li_zkMonitor_log4j_a").setAttribute("href", path + "/zkTree/tozkMonitorList4Log4j");
document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser");
document.getElementById("li_module_a").setAttribute("href", path + "/manage/toModule");
document.getElementById("li_taskConfigure_a").setAttribute("href", path + "/taskConfigure/toTaskConfigure");
... ...
/**
* Created by frw on 2016/6/17.
*/
var selectedNodeId = null;
var treeData = [];
var nodeId2id = function (nodeid) {
if (nodeid == "#") {
return 0;
} else {
return nodeid.split("_")[1];
}
};
var getPath = function (nodeid) {
var paths = [];
var num = 0;
var currentId = nodeid;
while (currentId != "#") {
var node = $("#jstree").jstree().get_node(currentId);
paths.push(node.text);
num++;
currentId = node.parent;
}
var strPath = "";
for (var i = 0; i < num; i++) {
strPath += paths.pop() + "/";
}
return strPath;
}
var openTree = function (node_id, level) {
// console.log("open tree" + node_id);
try {
var node = $("#jstree").jstree().get_node(node_id);
$("#jstree").jstree("open_node", node);
var children = node.children;
} catch (e) {
console.warn(e);
return;
}
// console.log("open children" +children);
if (level <= 1)
return;
level--;
$.each(children, function (n, data) {
openTree(data, level);
});
}
var addType = function (node) {
var rel = 0;
var pid;
var name;
var isleaf;
$('#modal_type_update').hide();
$('#modal_type_del').hide();
$('#modal_type_add').show();
$('#myModalLabel').html("添加类型");
$('#cb_new_type_isleaf').prop("checked", true);// 默认为子节点
$('#tx_new_type_name').val("");
$('#tx_type_id').val(nodeId2id(node.id));
$('#tx_type_action').val("add");
$('#tx_new_type_isleaf').val(1);
$('#tx_new_type_parent').val(getPath(node.id));
$('#myModal').modal({keyboard: true});
return rel;
};
var doAddType = function () {
var pid = $('#tx_type_id').val();
var name = $('#tx_new_type_name').val();
if (name == null || $('#tx_new_type_name').val() == "") {
$.toaster('输入类型名', '提示', 'warning');
return;
}
var isleaf = $('#cb_new_type_isleaf').prop("checked") == true ? 1 : 0;
$.get("type/add", {"pid": pid, "name": name, "isleaf": isleaf},
function (data, state) {
var repjson = JSON.parse(data);
if (state == "success" && repjson.code == 200) {
$.toaster('添加成功', '提示', 'info');
console.log(repjson.data);
var newNode = repjson.data;
$('#jstree').jstree().create_node("#node_" + newNode.typeParentId,
{
'id': "node_" + newNode.typeId,
'text': newNode.typeName,
'parent': "#node_" + newNode.typeParentId,
'data': newNode.typeIsLeaf
}, 'last');
$('#jstree').jstree().get_node("node_" + newNode.typeId).data = newNode.typeIsLeaf;
} else
$.toaster('添加失败' + repjson.code + " " + repjson.message, '提示', 'warning');
}
).fail(function () {
$.toaster('添加失败:', '提示', 'warning');
});
$('#myModal').dialog('hide');
}
/**
* 获取所有选择节点
* @param isleaf true:仅获取叶子节点;false:所有节点
* @returns {Array}
*/
var getSelectType = function (isleaf) {
var seltypes = [];
$.each($("#jstree").jstree('get_selected'), function (idx, nodeid) {
var node = $('#jstree').jstree().get_node(nodeid);
if (isleaf == true && node.data != 1)
return;
seltypes.push(nodeId2id(nodeid));
});
return seltypes;
}
/**
* 检查节点是否子节点
* @param nodeid
* @returns {boolean}
*/
var checkIsLeaf = function (nodeid) {
var node = $('#jstree').jstree().get_node(nodeid);
var isLeaf = node.data == 1 ? true : false;
return isLeaf;
}
$("#btn4type").click(function () {
console.log("frw");
if ($("#tx_type_action").val() == "add") {
doAddType();
}
});
/**
* 根据选中的节点获取信息
*/
function searchType(ip, children, nodeId){
//非叶子节点不处理
if(children.length != 0) {
return;
}
//将原来选中的节点的背景颜色去掉
if(selectedNodeId != null) {
var nodeStyle = document.getElementById(selectedNodeId).style;
nodeStyle.backgroundColor="";
nodeStyle.color="black";
//document.getElementById(selectedNodeId).style.backgroundColor="";
}
//给选中的节点添加背景颜色
var nodeStyle = document.getElementById(nodeId).style;
nodeStyle.backgroundColor = "#3392e3";
nodeStyle.color = "#ffffff";
selectedNodeId = nodeId;
$("#detailTable").hide();
$("#rootTable").table({
url: contextPath + "/zkTree/getRoot4Log4j?ip="+ip,
striped: true,
panelClass: "panel-success",
pagination: false,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "名称",
field: "name",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var input = $("<input type=\"button\">").addClass("form-control").attr({
id :"name",
name : "name",
style : "border: none;",
value : value
}).appendTo(div);
input.click(function () {
toDetail(rowData,ip);
});
return div;
}
}, {
title: "路径",
field: "root"
}],
});
}
var refreshTypeTree = function () {
console.log("refresh tree");
treeData = []; //重置
$.get(contextPath+"type/zkTree", function (data, state) {
console.log(state)
var jsonData = JSON.parse(data);
$.each(jsonData.data, function (n, val) {
var treeNode = {};
treeNode.id = "node_" + val.typeId;
treeNode.parent = (val.typeParentId == 0 ? "#" : "node_" + val.typeParentId);
treeNode.text = val.typeName;
treeNode.data = val.typeIsLeaf;
treeData.push(treeNode)
});
$('#jstree').jstree(true).settings.core.data = treeData;
$('#jstree').jstree().refresh(true, true);
setTimeout("openTree('#', 3)", 300); //展开三层
});
}
$('#jstree').jstree({
"plugins": ["themes", "contextmenu", "ui", "types", "crrm", "core", "status"],
'core': {
"themes": {
name: 'proton',
dots: false,
icons: false
},
'data': treeData,
'check_callback': true
}
}).bind("changed.jstree",
function (e, data) {
console.log(data);
console.log("Checked: " + data.node.text);
searchType(data.node.text, data.node.children, data.node.a_attr.id);
});
refreshTypeTree();
... ...