... ... @@ -172,4 +172,10 @@ public class HttpUriContants {
public static final String CENTERSWITCH_GET = "/centerSwitch/getSwitchList";
public static final String CENTERSWITCH_SWITCH = "/centerSwitch/doExe";
//java监控信息
public static final String JAVA_MONITOR_GET = "/newJavaApiInfo/queryByServiceType";
public static final String JAVA_GRAPH_GET = "/newJavaApiInfo/getJavaApiGraph";
public static final String JAVA_IP_LIST = "/newJavaApiInfo/getIPList";
public static final String JAVA_API_LIST = "/newJavaApiInfo/queryByServiceTypeAndIP";
}
... ...
... ... @@ -14,6 +14,4 @@ public class CenterSwitchModel {
private String exe;
private String toCloud;
}
... ...
package com.ui.model.req;
import lombok.Data;
/**
* javaAPI监控信息
* Created by lingmin on 2016/10/21.
*/
@Data
public class JavaApiMonitorReq extends PageRequest {
private int serviceType;
private String serviceName;
private int timeInterval;
//曲线图类型,1:平均耗时,2:异常次数
private int graphType;
//云类型 1-aws,2-qcloud
private int cloudType;
private String startTime;
private String endTime;
private String ip;
}
... ...
package com.ui.ctrl;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.req.JavaApiMonitorReq;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
/**
* Created by lingmin on 2016/10/19.
*/
@Controller
@RequestMapping("javaMonitor")
public class JavaMonitorCtrl {
Logger log = LoggerFactory.getLogger(JavaMonitorCtrl.class);
@Autowired
private HttpRestClient httpClient;
@RequestMapping("/toJavaMonitor")
public ModelAndView toJavaMonitor() {
return new ModelAndView("javaMonitor/javaMonitor");
}
@RequestMapping("/toJavaApiInfoList")
public ModelAndView toJavaApiInfoList() {
return new ModelAndView("javaMonitor/javaApiInfoList");
}
@RequestMapping("/query")
@ResponseBody
public BaseResponse queryApiMonitorInfo(JavaApiMonitorReq req) {
//校验参数
if(StringUtils.isEmpty(req.getServiceName())){
req.setServiceName("gateway");
}
if(req.getTimeInterval() == 0){
req.setTimeInterval(1);
}
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_MONITOR_GET, req, BaseResponse.class);
return rep;
}
@RequestMapping("/getGraphData")
@ResponseBody
public BaseResponse getGraphData(JavaApiMonitorReq req) {
if(StringUtils.isEmpty(req.getServiceName())){
req.setServiceName("gateway");
}
BaseResponse rep;
try {
rep = httpClient.defaultPost(HttpUriContants.JAVA_GRAPH_GET, req, BaseResponse.class);
} catch (Exception e) {
rep = new BaseResponse(400);
rep.setMessage("getGraphData error");
}
return rep;
}
@RequestMapping("/queryIpList")
@ResponseBody
public BaseResponse queryIpList(JavaApiMonitorReq req) {
//校验参数
if(StringUtils.isEmpty(req.getServiceName())){
req.setServiceName("gateway");
}
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_IP_LIST, req, BaseResponse.class);
return rep;
}
@RequestMapping("/queryByServiceTypeAndIP")
@ResponseBody
public BaseResponse queryByServiceTypeAndIP(JavaApiMonitorReq req) {
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_API_LIST, req, BaseResponse.class);
return rep;
}
}
... ...
div.dataTables_length label {
float: left;
text-align: left;
}
div.dataTables_length select {
width: 75px;
}
div.dataTables_filter label {
float: right;
}
div.dataTables_info {
padding-top: 8px;
}
div.dataTables_paginate {
float: right;
margin: 0;
}
table.table {
clear: both;
margin-bottom: 6px !important;
max-width: none !important;
}
table.table thead .sorting,
table.table thead .sorting_asc,
table.table thead .sorting_desc,
table.table thead .sorting_asc_disabled,
table.table thead .sorting_desc_disabled {
cursor: pointer;
*cursor: hand;
}
table.table thead .sorting { background: url('http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/sort_both.png') no-repeat center right; }
table.table thead .sorting_asc { background: url('http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/sort_asc.png') no-repeat center right; }
table.table thead .sorting_desc { background: url('http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/sort_desc.png') no-repeat center right; }
table.table thead .sorting_asc_disabled { background: url('http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/sort_asc_disabled.png') no-repeat center right; }
table.table thead .sorting_desc_disabled { background: url('http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/sort_desc_disabled.png') no-repeat center right; }
table.dataTable th:active {
outline: none;
}
/* Scrolling */
div.dataTables_scrollHead table {
margin-bottom: 0 !important;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
div.dataTables_scrollHead table thead tr:last-child th:first-child,
div.dataTables_scrollHead table thead tr:last-child td:first-child {
border-bottom-left-radius: 0 !important;
border-bottom-right-radius: 0 !important;
}
div.dataTables_scrollBody table {
border-top: none;
margin-bottom: 0 !important;
}
div.dataTables_scrollBody tbody tr:first-child th,
div.dataTables_scrollBody tbody tr:first-child td {
border-top: none;
}
div.dataTables_scrollFoot table {
border-top: none;
}
/*
* TableTools styles
*/
.table tbody tr.active td,
.table tbody tr.active th {
background-color: #08C;
color: white;
}
.table tbody tr.active:hover td,
.table tbody tr.active:hover th {
background-color: #0075b0 !important;
}
.table-striped tbody tr.active:nth-child(odd) td,
.table-striped tbody tr.active:nth-child(odd) th {
background-color: #017ebc;
}
table.DTTT_selectable tbody tr {
cursor: pointer;
*cursor: hand;
}
div.DTTT .btn {
color: #333 !important;
font-size: 12px;
}
div.DTTT .btn:hover {
text-decoration: none !important;
}
ul.DTTT_dropdown.dropdown-menu a {
color: #333 !important; /* needed only when demo_page.css is included */
}
ul.DTTT_dropdown.dropdown-menu li {
position: relative;
}
ul.DTTT_dropdown.dropdown-menu li:hover a {
background-color: #0088cc;
color: white !important;
}
/* TableTools information display */
div.DTTT_print_info.modal {
height: 150px;
margin-top: -75px;
text-align: center;
}
div.DTTT_print_info h6 {
font-weight: normal;
font-size: 28px;
line-height: 28px;
margin: 1em;
}
div.DTTT_print_info p {
font-size: 14px;
line-height: 20px;
}
/*
* FixedColumns styles
*/
div.DTFC_LeftHeadWrapper table,
div.DTFC_LeftFootWrapper table,
div.DTFC_RightHeadWrapper table,
div.DTFC_RightFootWrapper table,
table.DTFC_Cloned tr.even {
background-color: white;
}
div.DTFC_RightHeadWrapper table ,
div.DTFC_LeftHeadWrapper table {
margin-bottom: 0 !important;
border-top-right-radius: 0 !important;
border-bottom-left-radius: 0 !important;
border-bottom-right-radius: 0 !important;
}
div.DTFC_RightHeadWrapper table thead tr:last-child th:first-child,
div.DTFC_RightHeadWrapper table thead tr:last-child td:first-child,
div.DTFC_LeftHeadWrapper table thead tr:last-child th:first-child,
div.DTFC_LeftHeadWrapper table thead tr:last-child td:first-child {
border-bottom-left-radius: 0 !important;
border-bottom-right-radius: 0 !important;
}
div.DTFC_RightBodyWrapper table,
div.DTFC_LeftBodyWrapper table {
border-top: none;
margin-bottom: 0 !important;
}
div.DTFC_RightBodyWrapper tbody tr:first-child th,
div.DTFC_RightBodyWrapper tbody tr:first-child td,
div.DTFC_LeftBodyWrapper tbody tr:first-child th,
div.DTFC_LeftBodyWrapper tbody tr:first-child td {
border-top: none;
}
div.DTFC_RightFootWrapper table,
div.DTFC_LeftFootWrapper table {
border-top: none;
}
... ...
... ... @@ -94,6 +94,8 @@
</li>
<li class="" id="hostInfoList"><a href="?page_type=hostInfoList"><i class="icon icon-th"></i> <span>主机管理</span></a>
</li>
<li class="" id="javaMonitor"><a href="?page_type=javaMonitor"><i class="icon icon-th"></i><span>JAVA服务监控</span></a>
</li>
<li class="" id="javaApi"><a href="?page_type=javaApi"><i class="icon icon-th"></i><span>JAVA服务信息</span></a>
</li>
<li class="" id="zkInfo"><a href="?page_type=zkInfo"><i class="icon icon-th"></i><span>ZK监控</span></a>
... ... @@ -123,6 +125,7 @@
"mobjectInfo": 'jsp/mobject/mobjectInfo.jsp',
"hostGroupList": 'jsp/host/hostGroupList.jsp',
"hostInfoList": 'jsp/host/hostInfoList.jsp',
"javaMonitor": 'jsp/javaMonitor/javaMonitor.jsp',
"javaApi": 'jsp/javaapi/javaApi.jsp',
"zkInfo": '/jsp/zkInfo/zkInfoList.jsp',
"redisInfo": '/jsp/redisInfo/redisInfoList.jsp',
... ...
... ... @@ -33,7 +33,7 @@
}
header.append($("<h4>").addClass("modal-title").html(opt.title));
var body = $("<div>").addClass("modal-body").css({
width : "100%",
width : "100%",
overflow : "auto"
});
if (opt.content !== undefined) {
... ... @@ -74,7 +74,14 @@
}
var dialogDiv = $("<div>").addClass("modal-dialog").css(opt.style).addClass(opt.size ? opt.size : "").attr("role", "document").appendTo(self);
var contentDiv = $("<div>").addClass("modal-content").append(header).append(body).append(footer).appendTo(dialogDiv);
if (opt.height) {
body.css("height", opt.height);
}
if (opt.width) {
contentDiv.css("width", opt.width);
}
self.on("show.bs.modal", function(e) {
if (opt.onBeforeShow) {
opt.onBeforeShow.call(self);
... ... @@ -101,10 +108,10 @@
keyboard : opt.keyboard,
show : opt.show
}));
});
};
/**
* 销毁
*/
... ... @@ -112,8 +119,8 @@
//$(jq).empty().removeClass("modal fade").removeAttr("role").removeAttr("aria-labelledby");
jq.remove();
}
$.fn.dialog.methods = {
show : function() {
return this.each(function() {
... ... @@ -154,7 +161,7 @@
});
}
};
$.fn.dialog.events = {
onBeforeShow : function() {},
onAfterShow : function() {},
... ...
... ... @@ -29,9 +29,6 @@
if (opt.loadFilter) {
opt.data = opt.loadFilter(data);
}
if (opt.onLoadSuccess) {
opt.onLoadSuccess(opt.data);
}
_createSelect(self);
}
});
... ... @@ -41,7 +38,7 @@
});
};
/**
* 生成select
*/
... ... @@ -53,9 +50,9 @@
if (opt.className) {
jq.addClass(opt.className);
}
if (!opt.data || opt.data.length == 0) {
return;
}
/*if (!opt.data) {
return;
}*/
if (opt.onChange) {
jq.change(function() {
var optionData = jq.find("option[value='"+ jq.val() +"']").data("optionData");
... ... @@ -68,22 +65,47 @@
$(opt.data).each(function(index, item) {
$("<option "+ ((opt.value && opt.value == item[opt.valueField]) ? "selected" : "") +">").data("optionData", item).val(item[opt.valueField]).html(item[opt.textField]).appendTo(jq);
});
if (opt.onLoadSuccess) {
opt.onLoadSuccess.call(jq, opt.data);
}
//设置已经加载完成
jq.attr("loadStatus", "1");
}
function _getValue(jq) {
return $(jq).val();
}
function _getText(jq) {
var obj = $(jq).find("option:selected");
return obj ? obj.html() : "";
}
//方法
$.fn.select.methods = $.extend({}, $.fn.validate.methods, {
/**
* 获取值
*/
getValue : function() {
return _getValue(this);
},
/**
* 获取文本
*/
getText : function() {
return _getText(this);
}
});
//事件
$.fn.select.event = {
$.fn.select.event = $.extend({}, $.fn.validate.event, {
/**
* 加载完成执行
* @param data
*/
onLoadSuccess : function(data) {
},
/**
* 当下拉框改变的时候执行
... ... @@ -91,8 +113,8 @@
* @param optionData
*/
onChange : function(value, optionData) {}
};
});
//属性
$.fn.select.defaults = $.extend({}, $.fn.select.event, $.fn.validate.defaults, {
firstText : undefined,
... ... @@ -109,9 +131,9 @@
loadFilter : function(data) {},
value : null
});
/**
其中data包含的属性有
*/
其中data包含的属性有
*/
})(jQuery);
\ No newline at end of file
... ...
This diff could not be displayed because it is too large.
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<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/yoho.css"/>
<link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.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/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.min.js"></script>
<script src="<%=basePath %>js/jquery.toaster.js"></script>
<script type="text/javascript" src="<%=basePath %>js/jquery.dataTables.js"></script>
<script type="text/javascript" src="<%=basePath %>js/echarts.simple.min.js"></script>
<script type="text/javascript" src="<%=basePath %>js/echarts.min.js"></script>
<script src="<%=basePath %>js/highcharts.js"></script>
\ No newline at end of file
... ...
<%@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 + "/";
String serviceType = request.getParameter("serviceType");
String serviceName = request.getParameter("serviceName");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/jsp/common/include.jsp" flush="true"/>
<script>
var contextPath = '<%=basePath %>';
var serviceType = "<%=serviceType %>";
var serviceName = "<%=serviceName%>";
var startTime = "<%=startTime%>>";
var endTime = "<%=endTime%>>"
var homeUrl = contextPath + "jsp/javaMonitor/javaMonitor.jsp";
</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> Java服务</a> <a href='<%=basePath %>jsp/javaMonitor/javaMonitor.jsp' class="current">服务监控</a><a href="#"
class="current">API详情</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>Java API监控信息</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 53px;">
<div class="form-inline" role="form" id="inBoxQueryDiv"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" style="float: left;">
<span class="input-group-addon">服务名:</span>
<input type="text" id="serviceType" name="serviceType" class="form-control" disabled>
</input>
</div>
<div class="input-group" style="margin-left: 15px">
<select id="cloudType" name="cloudType" class="form-control" style="width: 100px" onchange="getOnchange()">
<option value="1">AWS</option>
<option value="2">QCloud</option>
</select>
</div>
<div class="input-group" style="margin-left: 15px">
<span class="input-group-addon">IP:</span>
<select id="iPName" name="iPName" class="form-control" style="width: 200px" onchange="getIpOnchange()">
</select>
</div>
</div>
</div>
<div id="infoTableDiv">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#timesPart" aria-controls="timesPart" role="tab" data-toggle="tab">异常次数</a>
</li>
<li role="presentation">
<a href="#costPart" aria-controls="costPart" role="tab" data-toggle="tab">平均耗时</a>
</li>
</ul>
<div class="tab-content" style="padding-top:10px">
<div role="tabpanel" class="tab-pane fade in active" id="timesPart">
<div id="infoTable"></div>
</div>
<div role="tabpanel" class="tab-pane fade" id="costPart">
<div id="infoTable1"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script>
$("#li_monitor").addClass("active open");
$("#li_javaMonitor").addClass("active");
$("#serviceType").val(serviceName);
</script>
<script>
var java_api_type = [];
var java_app = {};
var table_data;
$('body').on('click', function (e) {
$('[data-toggle="popover"]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
//类型选择事件
function getOnchange() {
var cloudType = $("#cloudType").val();
if(cloudType == null){
cloudType = 1;
}
getJavaAppType(cloudType);
}
//ip类型选择事件
function getIpOnchange() {
$("#infoTable").table("load", {
startTime : startTime,
endTime : endTime,
serviceType : serviceType,
serviceName : serviceName,
ip:$("#iPName").val(),
cloudType : $("#cloudType").val()
});
}
var getJavaAppType = function (cloudType) {
$.ajax({
url: contextPath + "/javaMonitor/queryIpList",
type: 'post',
data : {
serviceType:serviceType,
cloudType : cloudType
},
dataType:'json',
success: function (data) {
var selObj = $("#iPName");
selObj.empty();
selObj.append("<option value=0>" + "all" + "</option>");
$.each(data.data, function (idx, val) {
selObj.append("<option value='" + val + "'>" + val + "</option>");
});
}
});
};
$(function () {
getJavaAppType(1);
$("#infoTable").table({
columnAutoWidth: false,
url: contextPath + "/javaMonitor/queryByServiceTypeAndIP",
queryParams : {
startTime : startTime,
endTime : endTime,
serviceType : serviceType,
serviceName : serviceName
},
striped: true,
title: "java服务监控信息列表",
dataType: "json",
sortable: true, //是否启用排序
sortOrder: "desc",
loadFilter: function (data) {
return defaultLoadFilter(data);
},
onLoadSuccess: function (data) {
if(data != null){
//同步加载根据平均耗时排序的tab页列表
var costObj = new Array();
for(var j = 0;j<data.length;j++){
costObj.push(data[j]);
}
//按平均耗时从大到小排序ss
costObj.sort(function(a,b){
return b.avgCost-a.avgCost;
});
//同步加载根据异常次数排序的tab页列表
var errorObj = new Array();
for (var i = 0; i < data.length; i++) {
errorObj.push(data[i]);
}
//按异常次数从大到小排序
errorObj.sort(function (a, b) {
return b.errorCount - a.errorCount;
});
$("#infoTable1").table("loadLoaclData", errorObj);
return costObj;
}
},
columns: [{
title: "接口名",
field: "apiName",
width: "10%",
sortable: true
// formatter: function (value, rowData, rowIndex) {
// var div = $("<div>");
// var editBtn = $("<button>").addClass("btn btn-xs btn-success").html(rowData.ip).appendTo(div);
// editBtn.click(function () {
// var dialog = $("<div>").appendTo($("body"));
// dialog.dialog({
// backdrop: "static",
// title: "API详情",
// href: contextPath + "jsp/javaMonitor/javaIpInfoList.jsp",
// height: "80%",
// width: "60%",
// buttons: [{
// text: "关闭",
// className: "btn-info",
// onclick: function () {
// $(dialog).dialog("hide");
// }
// }]
// });
//
// });
// return div;
// }
}, {
title: "总请求次数",
field: "totalCount",
width: "10%",
sortable: true
}, {
title: "请求异常次数",
field: "errorCount",
width: "10%",
sortable: true,
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.errorCount).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if (rowData.errorInfo != null) {
for (var i = 0; i < rowData.errorInfo.length; i++) {
content = content + rowData.errorInfo[i] + "<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "异常详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
}, {
title: "平均耗时(ms)",
field: "avgCost",
width: "10%",
sortable: true,
// formatter : function(value, rowData, rowIndex) {
// var div = $("<div>");
// var textView = $("<span>").html(rowData.avgCost).appendTo(div);
// div.append("<br>");
// var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
// var content = "";
// if(rowData.timeoutInfo != null){
// for(var i = 0;i<rowData.timeoutInfo.length;i++){
// content= content +rowData.timeoutInfo[i]+"<br><br>";
// }
// }
// editBtn.click(function () {
// var dialog = $("<div>").appendTo($("body"));
// dialog.dialog({
// backdrop : "static",
// title : "超时详情",
// content : content,
// height : "60%",
// width : "50%",
// buttons : [{
// text : "关闭",
// className : "btn-danger",
// onclick : function() {
// $(dialog).dialog("hide");
// }
// }]
// });
// });
// return div;
// }
}]
});
//加载表格
$("#infoTable1").table({
columnAutoWidth: false,
striped: true,
title: "java服务监控信息列表",
dataType: "json",
sortable: true, //是否启用排序
sortOrder: "desc",
columns: [{
title: "接口名",
field: "apiName",
width: "10%",
sortable: true
}, {
title: "总请求次数",
field: "totalCount",
width: "10%",
sortable: true
}, {
title: "请求异常次数",
field: "errorCount",
width: "10%",
sortable: true,
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.errorCount).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if (rowData.errorInfo != null) {
for (var i = 0; i < rowData.errorInfo.length; i++) {
content = content + rowData.errorInfo[i] + "<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "异常详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
}, {
title: "平均耗时(ms)",
field: "avgCost",
width: "10%",
sortable: true
// formatter : function(value, rowData, rowIndex) {
// var div = $("<div>");
// var textView = $("<span>").html(rowData.avgCost).appendTo(div);
// div.append("<br>");
// var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
// var content = "";
// if(rowData.timeoutInfo != null){
// for(var i = 0;i<rowData.timeoutInfo.length;i++){
// content= content +rowData.timeoutInfo[i]+"<br><br>";
// }
// }
// editBtn.click(function () {
// var dialog = $("<div>").appendTo($("body"));
// dialog.dialog({
// backdrop : "static",
// title : "超时详情",
// content : content,
// height : "60%",
// width : "50%",
// buttons : [{
// text : "关闭",
// className : "btn-danger",
// onclick : function() {
// $(dialog).dialog("hide");
// }
// }]
// });
// });
// return div;
// }
}]
});
});
</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 + "/";
String serviceType = request.getParameter("serviceType");
String serviceName = request.getParameter("serviceName");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
String apiName = request.getParameter("apiName");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/jsp/common/include.jsp" flush="true"/>
<script>
var contextPath = '<%=basePath %>';
var serviceType = "<%=serviceType %>";
var serviceName = "<%=serviceName%>";
var startTime = "<%=startTime%>>";
var endTime = "<%=endTime%>>";
var apiName = "<%=apiName%>>";
</script>
</head>
<body>
<!-- 右侧具体内容 -->
<form class="form-horizontal" id="javaIpInfoForm" name="javaIpInfoForm">
<div class="form-group">
<div class="col-sm-5" >
<span class="input-group-addon">服务名:</span>
<input type="text" id="serviceType" name="serviceType" class="form-control" disabled>
</input>
</div>
<div class="col-sm-5" >
<span class="input-group-addon">接口名:</span>
<input type="text" id="apiName" name="apiName" class="form-control" disabled>
</select>
</div>
</div>
<div class="form-group">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#timesPartIpInfo" aria-controls="timesPartIpInfo" role="tab" data-toggle="tab">异常次数</a>
</li>
<li role="presentation">
<a href="#costPartIpInfo" aria-controls="costPartIpInfo" role="tab" data-toggle="tab">平均耗时</a>
</li>
</ul>
<div class="tab-content" style="padding-top:10px">
<div role="tabpanel" class="tab-pane fade in active" id="timesPartIpInfo">
<div id="ipInfoTable"></div>
</div>
<div role="ipInfoTable2" class="tab-pane fade" id="costPartIpInfo">
<div id="infoTable1"></div>
</div>
</div>
</div>
</form>
</body>
<script>
$("#serviceType").val(serviceName);
$("#apiName").val(apiName);
</script>
<script>
$(function () {
$("#javaIpInfoForm #ipInfoTable").table({
columnAutoWidth: false,
url: contextPath + "/javaMonitor/query",
striped: true,
title: "java服务监控信息列表",
dataType: "json",
sortable: true, //是否启用排序
sortOrder: "desc",
loadFilter: function (data) {
return defaultLoadFilter(data);
},
onLoadSuccess: function (data) {
if(data != null){
//同步加载根据异常次数排序的tab页列表
var errorObj = new Array();
for (var i = 0; i < data.length; i++) {
errorObj.push(data[i]);
}
//按异常次数从大到小排序
errorObj.sort(function (a, b) {
return b.errorCount - a.errorCount;
});
$("#javaIpInfoForm #ipInfoTable2").table("loadLoaclData", errorObj);
}
},
columns: [{
title: "IP",
field: "ip",
width: "10%",
sortable: true
}, {
title: "总请求次数",
field: "totalCount",
width: "10%",
sortable: true
}, {
title: "请求异常次数",
field: "errorCount",
width: "10%",
sortable: true,
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.errorCount).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if (rowData.errorInfo != null) {
for (var i = 0; i < rowData.errorInfo.length; i++) {
content = content + rowData.errorInfo[i] + "<br><br>";
}
}
editBtn.click(function () {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop: "static",
title: "异常详情",
content: content,
height : "700px",
width : "1100px",
buttons: [{
text: "关闭",
className: "btn-danger",
onclick: function () {
$(dialog).dialog("hide");
}
}]
});
});
return div;
}
}, {
title: "平均耗时(ms)",
field: "avgCost",
width: "10%",
sortable: true
// formatter : function(value, rowData, rowIndex) {
// var div = $("<div>");
// var textView = $("<span>").html(rowData.avgCost).appendTo(div);
// div.append("<br>");
// var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
// var content = "";
// if(rowData.timeoutInfo != null){
// for(var i = 0;i<rowData.timeoutInfo.length;i++){
// content= content +rowData.timeoutInfo[i]+"<br><br>";
// }
// }
// editBtn.click(function () {
// var dialog = $("<div>").appendTo($("body"));
// dialog.dialog({
// backdrop : "static",
// title : "超时详情",
// content : content,
// height : "60%",
// width : "50%",
// buttons : [{
// text : "关闭",
// className : "btn-danger",
// onclick : function() {
// $(dialog).dialog("hide");
// }
// }]
// });
// });
// return div;
// }
}]
});
//加载表格
$("#javaIpInfoForm #ipInfoTable2").table({
columnAutoWidth: false,
striped: true,
title: "java服务监控信息列表",
dataType: "json",
sortable: true, //是否启用排序
sortOrder: "desc",
columns: [{
title: "IP",
field: "ip",
width: "10%",
sortable: true
},{
title: "请求异常次数",
field: "errorCount",
width: "10%",
sortable: true,
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.errorCount).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if (rowData.errorInfo != null) {
for (var i = 0; i < rowData.errorInfo.length; i++) {
content = content + rowData.errorInfo[i] + "<br><br>";
}
}
editBtn.click(function () {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop: "static",
title: "异常详情",
content: content,
height : "700px",
width : "1100px",
buttons: [{
text: "关闭",
className: "btn-danger",
onclick: function () {
$(dialog).dialog("hide");
}
}]
});
});
return div;
}
}, {
title: "平均耗时(ms)",
field: "avgCost",
width: "10%",
sortable: true
// formatter : function(value, rowData, rowIndex) {
// var div = $("<div>");
// var textView = $("<span>").html(rowData.avgCost).appendTo(div);
// div.append("<br>");
// var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
// var content = "";
// if(rowData.timeoutInfo != null){
// for(var i = 0;i<rowData.timeoutInfo.length;i++){
// content= content +rowData.timeoutInfo[i]+"<br><br>";
// }
// }
// editBtn.click(function () {
// var dialog = $("<div>").appendTo($("body"));
// dialog.dialog({
// backdrop : "static",
// title : "超时详情",
// content : content,
// height : "60%",
// width : "50%",
// buttons : [{
// text : "关闭",
// className : "btn-danger",
// onclick : function() {
// $(dialog).dialog("hide");
// }
// }]
// });
// });
// return div;
// }
}]
});
});
</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>
<jsp:include page="/jsp/common/include.jsp" flush="true" />
<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> Java服务</a> <a href="#" class="current">服务监控</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>Java服务监控曲线</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 400px;">
<div class="col-sm-5 control-label" role="form" id="chartterDiv"
style=" margin-top: 12px;margin-left: 10px;">
<div id="costCharts" class="input-group" style="height: 380px;width: 760px">
</div>
</div>
<div class="col-sm-5 control-label" role="form" id="chartterDiv1"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div id="timesCharts" class="input-group" style="height: 380px;width: 760px;margin-left: 100px">
</div>
</div>
</div>
</div>
</div>
<div class="widget-box">
<div class="widget-title">
<h5>Java服务监控信息</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 53px;">
<div class="form-inline" role="form" id="inBoxQueryDiv"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" id="timeDiv" style="float: left;">
<select id="timeInterval" name="timeInterval" class="form-control" onchange="getOnchange(2)">
<option value="1">1 minute</option>
<option value="5">5 minutes</option>
<option value="10">10 minutes</option>
</select>
</div>
<div class="input-group" style="margin-left: 10px">
<span class="input-group-addon" >服务名:</span>
<select id="searchApiName" name="searchApiName" class="form-control" onchange="getOnchange(1)">
</select>
</div>
<button id="searchJavaInfoBtn" class="btn btn-primary" style="margin-left: 15px">API统计详情</button>
</div>
</div>
<div id="infoTableDiv">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#ipPart" aria-controls="ipPart" role="tab" data-toggle="tab">IP</a>
</li>
<li role="presentation">
<a href="#timesPart" aria-controls="timesPart" role="tab" data-toggle="tab">异常次数</a>
</li>
<li role="presentation">
<a href="#costPart" aria-controls="costPart" role="tab" data-toggle="tab">平均耗时</a>
</li>
</ul>
<div class="tab-content" style="padding-top:10px">
<div role="tabpanel" class="tab-pane fade in active" id="ipPart">
<div id="ipInfoTable"></div>
</div>
<div role="tabpanel" class="tab-pane fade" id="timesPart">
<div id="infoTable"></div>
</div>
<div role="tabpanel" class="tab-pane fade" id="costPart">
<div id="infoTable1"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script>
$("#li_monitor").addClass("active open");
$("#li_javaMonitor").addClass("active");
</script>
<script>
var java_api_type = [];
var java_app = {};
var table_data;
$('body').on('click', function (e) {
$('[data-toggle="popover"]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
//1min定时
function timer() {
//加载表格
if($("#searchApiName").val() != null && $("#searchApiName").select("getText") != null) {
$("#ipInfoTable").table("load", {
serviceType: $("#searchApiName").val(),
serviceName: $("#searchApiName").select("getText"),
timeInterval: $("#timeInterval").val()
});
//更新曲线图
getLineDate(1);
getLineDate(2);
}
setTimeout("timer()", 60000);
}
timer();
//画图事件
function drawLine(type,title,subTitle,yText,categories,series) {
var title = {
text: title
};
var subtitle = {
text: subTitle == null? "gateway":subTitle
};
var xAxis = {
// tickInterval: 5*60* 1000, // one week
// categories: ['16:40','16:42','16:44', '16:46','16:48', '16:50',
// '16:52', '16:54', '16:56', '16:58', '17:00', '17:02']
categories:categories
};
var yAxis = {
title: {
// text: 'cost (ms)'
text: yText
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
};
var tooltip = {
valueSuffix: ''
};
var legend = {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
};
// var series = [
// {
// name: '172.31.57.252',
// data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
// 26.5, 23.3, 18.3, 13.9, 9.6]
// },
// {
// name: '172.31.57.254',
// data: [1, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8,
// 24.1, 20.1, 14.1, 8.6, 2.5]
// },
// {
// name: '172.31.57.253',
// data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0,
// 16.6, 14.2, 10.3, 6.6, 4.8]
// }
// ];
var series = series;
var json = {};
json.title = title;
json.subtitle = subtitle;
json.xAxis = xAxis;
json.yAxis = yAxis;
json.tooltip = tooltip;
json.legend = legend;
json.series = series;
if(type == 1){
$('#costCharts').highcharts(json);
}else{
$('#timesCharts').highcharts(json);
}
}
//类型选择事件,type用于区分点击服务名称下拉(1)还是时间下拉(2)
function getOnchange(type){
$("#ipInfoTable").table("load", {
serviceType: $("#searchApiName").val(),
serviceName: $("#searchApiName").select("getText"),
timeInterval:$("#timeInterval").val()
});
//为1则是服务名选择
if(type == 1){
//更新曲线图
getLineDate(1);
getLineDate(2);
}
}
//获取曲线数据
function getLineDate(lineType){
paramObj.serviceType = 0;
paramObj.serviceName = "";
if($("#searchApiName").val() != null){
paramObj.serviceType = $("#searchApiName").val();
}
if($("#searchApiName").select("getText") != null){
paramObj.serviceName = $("#searchApiName").select("getText");
}
$.ajax({
url: contextPath + "/javaMonitor/getGraphData",
type: 'post',
data:{
serviceType : paramObj.serviceType,
serviceName : paramObj.serviceName,
graphType : lineType
},
dataType:'json',
success: function (data) {
if (!data || data.code != 200) {
$.toaster('获取曲线数据失败', '警告', 'warning');
return;
}
//根据Ip处理曲线数据
var categories = data.data.time;
var series = data.data.content;
var title = "";
var xText = "";
if(lineType == 1){
title = "平均耗时-曲线图";
xText = "cost(ms)";
}else{
title = "异常次数-曲线图";
xText = "error times";
}
drawLine(lineType,title,$("#searchApiName").select("getText"),xText,categories,series);
}
});
}
$(function () {
$("#searchApiName").select({
valueField: "typeId",
textField: "typeName",
className: "form-control",
url: contextPath + "/type/queryJavaApiType",
loadFilter: function (data) {
return defaultLoadFilter(data);
}
});
$("#ipInfoTable").table({
columnAutoWidth: false,
url: contextPath + "/javaMonitor/query",
striped: true,
title: "java服务监控信息列表",
dataType: "json",
sortable: true, //是否启用排序
sortOrder:"desc",
loadFilter: function (data) {
//记录下开始时间和结束时间
paramObj.startTime = data.data.startTime;
paramObj.endTime = data.data.endTime;
return defaultLoadFilter(data).content;
},
onLoadSuccess: function (data) {
//记录第一条ip
if(data!= null){
paramObj.ipName = data[0].ip;
//同步加载根据异常次数排序的tab页列表
var errorObj = new Array();
for(var i = 0;i<data.length;i++){
errorObj.push(data[i]);
}
//按异常次数从大到小排序
errorObj.sort(function(a,b){
return b.errorCount-a.errorCount;
});
$("#infoTable").table("loadLoaclData", errorObj);
//同步加载根据平均耗时排序的tab页列表
var costObj = new Array();
for(var j = 0;j<data.length;j++){
costObj.push(data[j]);
}
//按平均耗时从大到小排序ss
costObj.sort(function(a,b){
return b.avgCost-a.avgCost;
});
$("#infoTable1").table("loadLoaclData", costObj);
}
},
columns: [{
title: "IP",
field: "ip",
width: "10%",
sortable:true
}, {
title: "网络归属",
field: "type",
width: "10%"
}, {
title: "总请求次数",
field: "totalCount",
width: "10%",
sortable:true
}, {
title: "请求异常次数",
field: "errorCount",
width: "10%",
sortable:true,
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.errorCount).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if(rowData.errorInfo != null){
for(var i = 0;i<rowData.errorInfo.length;i++){
content= content +rowData.errorInfo[i]+"<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "异常详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
},{
title: "平均耗时(ms)",
field: "avgCost",
width: "10%",
sortable:true,
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.avgCost).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if(rowData.timeoutInfo != null){
for(var i = 0;i<rowData.timeoutInfo.length;i++){
content= content +rowData.timeoutInfo[i]+"<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "超时详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
}, {
title: "CPU使用率",
field: "cpuRate",
width: "10%"
},{
title: "可用内存/总内存(MB)",
field: "memoryRate",
width: "10%"
},{
title: "带宽(IN/OUT)(KBps)",
field: "bandwidth",
width: "10%"
}]
});
$("#infoTable").table({
columnAutoWidth: false,
striped: true,
title: "java服务监控信息列表",
dataType: "json",
sortable: true, //是否启用排序
sortOrder:"desc",
// loadFilter: function (data) {
// return defaultLoadFilter(data);
// },
onLoadSuccess: function (data) {
},
columns: [{
title: "IP",
field: "ip",
width: "10%",
sortable:true
}, {
title: "网络归属",
field: "type",
width: "10%"
}, {
title: "总请求次数",
field: "totalCount",
width: "10%",
sortable:true
}, {
title: "请求异常次数",
field: "errorCount",
width: "10%",
sortable:true,
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.errorCount).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if(rowData.errorInfo != null){
for(var i = 0;i<rowData.errorInfo.length;i++){
content= content +rowData.errorInfo[i]+"<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "异常详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
},{
title: "平均耗时(ms)",
field: "avgCost",
width: "10%",
sortable:true,
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.avgCost).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if(rowData.timeoutInfo != null){
for(var i = 0;i<rowData.timeoutInfo.length;i++){
content= content +rowData.timeoutInfo[i]+"<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "超时详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
}, {
title: "CPU使用率",
field: "cpuRate",
width: "10%"
},{
title: "可用内存/总内存(MB)",
field: "memoryRate",
// formatter: function (value, rowData, rowIndex) {
// if (rowData.apiToggle == 0)
// return "N";
// else
// return "Y";
// },
width: "10%"
},{
title: "带宽(IN/OUT)(KBps)",
field: "bandwidth",
width: "15%"
}]
});
//加载表格
$("#infoTable1").table({
columnAutoWidth: false,
striped: true,
title: "java服务监控信息列表",
dataType: "json",
sortable: true, //是否启用排序
sortOrder:"desc",
columns: [{
title: "IP",
field: "ip",
width: "10%",
sortable:true
}, {
title: "网络归属",
field: "type",
width: "10%"
}, {
title: "总请求次数",
field: "totalCount",
width: "10%",
sortable:true
}, {
title: "请求异常次数",
field: "errorCount",
width: "10%",
sortable:true,
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.errorCount).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if(rowData.errorInfo != null){
for(var i = 0;i<rowData.errorInfo.length;i++){
content= content +rowData.errorInfo[i]+"<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "异常详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
},{
title: "平均耗时(ms)",
field: "avgCost",
width: "10%",
sortable:true,
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var textView = $("<span>").html(rowData.avgCost).appendTo(div);
div.append("<br>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
var content = "";
if(rowData.timeoutInfo != null){
for(var i = 0;i<rowData.timeoutInfo.length;i++){
content= content +rowData.timeoutInfo[i]+"<br><br>";
}
}
editBtn.click(function () {
if(content != ""){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
backdrop : "static",
title : "超时详情",
content : content,
height : "700px",
width : "1100px",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
});
return div;
}
}, {
title: "CPU使用率",
field: "cpuRate",
width: "10%"
},{
title: "可用内存/总内存(MB)",
field: "memoryRate",
// formatter: function (value, rowData, rowIndex) {
// if (rowData.apiToggle == 0)
// return "N";
// else
// return "Y";
// },
width: "10%"
},{
title: "带宽(IN/OUT)(KBps)",
field: "bandwidth",
width: "15%"
}]
});
var title = $("#searchApiName").val();
if (title == null){
title = "gateway";
}
//更新曲线图
getLineDate(1);
getLineDate(2);
//新增
$("#searchJavaInfoBtn").click(function() {
var url = contextPath + "/javaMonitor/toJavaApiInfoList";
var serviceType = $("#searchApiName").val();
var serviceName = $("#searchApiName").select("getText");
url += "?serviceType=" + serviceType+"&serviceName="+serviceName+"&startTime="+paramObj.startTime+"&endTime="+paramObj.endTime;
window.location.href = url;
});
});
</script>
... ...
... ... @@ -145,6 +145,7 @@
selObj.val(api_type);
}
};
var getTypeName = function (typeId) {
for (var i = 0; i < java_api_type.length; i++) {
... ...
... ... @@ -78,6 +78,36 @@
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
<div class="modal-dialog" style="margin-top: 5%;
margin-left: auto;
height:50.333%;
width: 60%;
overflow:scroll;
overflow-x:auto;
overflow-y:auto ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel"></h4>
</div>
<div class="modal-body">
<div id="check_result_div" style="">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script type="text/javascript">
$("#li_switch").addClass("active open");
... ... @@ -99,36 +129,54 @@
columns: [{
title: "切换项",
field: "cName",
width: "20%"
width: "15%"
}, {
title: "切向QQ",
field: "name",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
$("<button onclick=\"doExe(\'" + value + "\',\'qcloud\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
$("<button onclick=\"doExe(\'" + value + "\',\'beforeCheck\')\">").addClass("btn btn-xs btn-success").html("前检测").appendTo(div);
div.append("&nbsp;");
$("<button onclick=\"toDoExe(\'" + value + "\',\'toQcloud\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
div.append("&nbsp;");
$("<button onclick=\"doExe(\'" + value + "\',\'afterCheck\')\">").addClass("btn btn-xs btn-success").html("后检测").appendTo(div);
return div;
},
width: "40%"
width: "35%"
},{
title: "切回AWS",
field: "name",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
$("<button onclick=\"doExe(\'" + value + "\',\'aws\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
$("<button onclick=\"doExe(\'" + value + "\',\'afterCheck\')\">").addClass("btn btn-xs btn-success").html("前检测").appendTo(div);
div.append("&nbsp;");
$("<button onclick=\"toDoExe(\'" + value + "\',\'toAws\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
div.append("&nbsp;");
$("<button onclick=\"doExe(\'" + value + "\',\'beforeCheck\')\">").addClass("btn btn-xs btn-success").html("后检测").appendTo(div);
return div;
},
width: "35%"
},{
title: "状态查看",
field: "name",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
$("<button onclick=\"doExe(\'" + value + "\',\'status\')\">").addClass("btn btn-primary").html("当前状态").appendTo(div);
return div;
},
width: "40%"
width: "35%"
}]
});
});
//执行切换
function doExe(name, toCloud) {
function toDoExe(name, toCloud) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title: "切换确定",
backdrop: "static",
content: "name:"+name+" 切向:"+toCloud,
content: "name:"+name+" exe:"+toCloud,
buttons: [{
text: "否",
className: "btn-danger",
... ... @@ -140,11 +188,51 @@
className: "btn-success",
onclick: function () {
$(dialog).dialog("hide");
window.open(contextPath + "centerSwitch/todoExe?name=" + name + "&toCloud=" + toCloud, "_self");
doExe(name,toCloud);
}
}]
});
}
//执行切换
function doExe(name, exe) {
var jq = $("#switchTable");
$.ajax({
type: 'post',
url: contextPath + "/centerSwitch/doExe",
data:{
'name':name,
'exe':exe
},
dataType: 'json',
beforeSend:function(){
var div = $("<div>").attr("tableSelector", jq.selector).addClass("modal-backdrop fade in").appendTo($("body")).hide();
var tableOffset = jq.offset();
var tableWidth = jq.outerWidth(true), tableHeight = jq.outerHeight(true);
div.append($("<div>").addClass("table-loading").css({
left : (tableWidth - 124) / 2,
top : (tableHeight - 124) / 2
}));
div.css({
width : tableWidth,
height : tableHeight,
left : tableOffset.left,
top : tableOffset.top
});
div.show();
},
success: function (resp) {
$("body").find("div[tableSelector='"+ jq.selector +"']").remove();
$("#check_result_div").html(resp.data);
$("#myModalLabel").text("name:"+name+" exe:"+exe);
$("#myModal").modal('show');
},
error: function (resp) {
}
});
}
</script>
 
\ No newline at end of file
... ...
... ... @@ -100,10 +100,10 @@
url: contextPath + "/centerSwitch/doExe",
data:{
'name':name,
'toCloud':toCloud
'exe':toCloud
},
dataType: 'json',
beforeSend:function(XMLHttpRequest){
beforeSend:function(){
var div = $("<div>").attr("tableSelector", jq.selector).addClass("modal-backdrop fade in").appendTo($("body")).hide();
var tableOffset = jq.offset();
var tableWidth = jq.outerWidth(true), tableHeight = jq.outerHeight(true);
... ... @@ -129,12 +129,12 @@
});
// document.onkeydown = function()
// {
// if(event.keyCode==116 || event.keyCode==8 || (event.ctrlKey && event.keyCode==82) || event.keyCode == 13) {
// event.keyCode=0;
// event.returnValue = false;
// }
// }
// document.oncontextmenu = function() {event.returnValue = false;}
document.onkeydown = function()
{
if(event.keyCode==116 || event.keyCode==8 || (event.ctrlKey && event.keyCode==82) || event.keyCode == 13) {
event.keyCode=0;
event.returnValue = false;
}
}
document.oncontextmenu = function() {event.returnValue = false;}
</script>
\ No newline at end of file
... ...
... ... @@ -11,7 +11,8 @@ innerHTML += "<div id='sidebar'><ul>";
innerHTML += "<li id='li_dashboard'><a id='li_dashboard_a' href=''><i class='icon icon-th'></i> <span>Dashboard</span></a></li>";
/*监控*/
innerHTML += "<li class='submenu' id='li_monitor'><a id='li_monitor_a' href='#'><i class='icon icon-th-list'></i> <span>监控</span><span class='label'>7</span></a><ul>";
innerHTML += "<li class='submenu' id='li_monitor'><a id='li_monitor_a' href='#'><i class='icon icon-th-list'></i> <span>监控</span><span class='label'>8</span></a><ul>";
innerHTML += "<li id='li_javaMonitor'><a id='li_javaMonitor_a' href=''><i class='icon icon-th'></i> <span>JAVA服务监控</span></a></li>";
innerHTML += "<li id='li_javaApi'><a id='li_javaApi_a' href=''><i class='icon icon-th'></i> <span>JAVA服务信息</span></a></li>";
innerHTML += "<li id='li_zkInfo'><a id='li_zkInfo_a' href=''><i class='icon icon-th'></i> <span>ZK监控</span></a></li>";
innerHTML += "<li id='li_rabbitview'><a id='li_rabbitview_a' href=''><i class='icon icon-th'></i> <span>Rabbitmq监控</span></a></li>";
... ... @@ -62,7 +63,7 @@ innerHTML += "<li id='li_projectHistory'><a id='li_projectHistory_a' href=''><i
innerHTML += "</ul></li>";
/*switch*/
innerHTML += "<li class='submenu' id='li_switch'><a id='li_switch_a' href='#'><i class='icon icon-th-list'></i> <span>关键切换</span><span class='label'>3</span></a>";
innerHTML += "<li class='submenu' id='li_switch'><a id='li_switch_a' href='#'><i class='icon icon-th-list'></i> <span>关键切换</span><span class='label'>4</span></a>";
innerHTML += "<ul><li id='li_nginxswitch'><a id='li_nginxswitch_a' href=''>nginx切换</a></li>";
innerHTML += "<li id='li_luaswitch'><a id='li_luaswitch_a' href='#'>LUA切换</a></li>";
innerHTML += "<li id='li_limitswitch'><a id='li_limitswitch_a' href='#'>限流调整</a></li>";
... ... @@ -90,6 +91,7 @@ document.getElementById("li_dashboard_a").setAttribute("href", path + "/dashboar
document.getElementById("li_mobjectInfo_a").setAttribute("href", path + "/mobject/toMobject");
document.getElementById("li_hostGroupList_a").setAttribute("href", path + "/hostGroup/toHostGroup");
document.getElementById("li_hostInfoList_a").setAttribute("href", path + "/hostInfoList/toHostInfos");
document.getElementById("li_javaMonitor_a").setAttribute("href", path + "/javaMonitor/toJavaMonitor");
document.getElementById("li_javaApi_a").setAttribute("href", path + "/javaApi/toJavaApi");
document.getElementById("li_zkInfo_a").setAttribute("href", path + "/zkMonitor/tozkMonitor");
document.getElementById("li_rabbitview_a").setAttribute("href", path + "/rabbitmq/toRabbitmq");
... ...