Authored by fanzelei

Merge branch 'master' of http://git.yoho.cn/ops/monitor-ui

  1 +<%@ page import="org.aspectj.weaver.ast.Var"%>
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8"%> 3 pageEncoding="UTF-8"%>
3 -  
4 <% 4 <%
5 String path = request.getContextPath(); 5 String path = request.getContextPath();
6 String basePath = request.getScheme() + "://" 6 String basePath = request.getScheme() + "://"
7 + request.getServerName() + ":" + request.getServerPort() 7 + request.getServerName() + ":" + request.getServerPort()
8 + path + "/"; 8 + path + "/";
9 %> 9 %>
10 -<script type="text/javascript" src="<%=basePath %>/js/jquery.min.js"></script>  
11 -<script language="JavaScript" src="<%=basePath %>/js/charts/FusionCharts.js"></script> 10 +
12 <div id="breadcrumb"> 11 <div id="breadcrumb">
13 <a href="#" title="Go to Home" class="tip-bottom"><i 12 <a href="#" title="Go to Home" class="tip-bottom"><i
14 - class="icon-home"></i> Home</a> <a href="#" class="current">Redis监控</a> 13 + class="icon-home"></i> Home</a> <a href="#" class="current">Redis</a>
15 </div> 14 </div>
16 15
17 <div class="container-fluid"> 16 <div class="container-fluid">
18 - <div class="widget-box">  
19 - <div class="widget-title">  
20 - <h5>Redis监控</h5> 17 + <div class="row-fluid"
  18 + style="border: solid 1px #CDC9C9; padding: 10px">
  19 + <div class="span12">
  20 + <div class="section section-visible">
  21 + <h3 style="margin-left: 16px;">REDIS(最近两分钟)</h3>
  22 + <div id="redisAppendDiv">
  23 +
  24 + </div>
  25 +
  26 + </div>
  27 + <!-- row -->
21 </div> 28 </div>
22 - <div class="widget-content nopadding" id="charDiv">  
23 29
  30 + </div>
  31 +</div>
  32 +
  33 +
  34 +
  35 +<div class="modal fade" style="margin-top: 60px;" id="myRedisProxyDetail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  36 + <div class="modal-dialog">
  37 + <div class="modal-content">
  38 + <div class="modal-header">
  39 + <button type="button" class="close" data-dismiss="modal"
  40 + aria-hidden="true">&times;</button>
  41 + <h4 class="modal-title" id="myModalLabel"></h4>
  42 + </div>
  43 + <div class="modal-body" id="redislistDetail">
  44 +
  45 + </div>
24 </div> 46 </div>
  47 + <!-- /.modal-content -->
25 </div> 48 </div>
  49 + <!-- /.modal -->
26 </div> 50 </div>
27 -<div id="testDiv"></div> 51 +
28 <script type="text/javascript"> 52 <script type="text/javascript">
  53 + var myMasterRedis=new Array();
  54 + var mySlaveRedis=new Array();
29 $.ajax({ 55 $.ajax({
30 - url: contextPath + "/redisInfo/getRedisInfo",  
31 - type: 'post', 56 + url: contextPath + "redisInfo/getRedisInfo",
  57 + type: 'get',
32 async: false, 58 async: false,
33 dataType: "json", 59 dataType: "json",
34 success: function (data) { 60 success: function (data) {
35 - if(data.data!=null&&data.data!=''){  
36 - $.each(data.data, function (n, value) {  
37 - var idDiv="chartdiv"+n;  
38 - $("#charDiv").prepend('<div id="'+idDiv+'" align="center" style="width:600px;">FusionCharts. </div>');  
39 - var chart0 = new FusionCharts("<%=basePath %>/js/charts/DragNode.swf", "ChartId", "1200", "650", "0");  
40 - chart0.setXMLData(value);  
41 - chart0.render(idDiv); 61 + var time="";
  62 + var awsHtml = '';
  63 + if(data.data != null){
  64 + $.each(data.data,function(name,value) {
  65 + var contentHtml="";
  66 + var topNode="";
  67 + var activeCount=0;
  68 + var failedCount=0;
  69 + var successIp='';
  70 + var failedIp="";
  71 + $.each(value, function (n, obj) {
  72 + if(obj.level==0){
  73 + topNode=obj.nodeFrom;
  74 + return true;
  75 + }
  76 + if(obj.level==1){
  77 + if(obj.isFailed==1){
  78 + successIp=successIp+'<a href="#" style="color: white;" onclick="displatyTetail(\''+obj.nodeTo+'\')">'+obj.nodeTo+'('+obj.paramMonitor+')</a><br/>';
  79 + activeCount=activeCount+1;
  80 + }else if(obj.isFailed==0){
  81 + failedCount=failedCount+1;
  82 + failedIp=failedIp+obj.nodeTo+'<br/>';
  83 + }
  84 + return true;
  85 + }
  86 + if(obj.level==2){
  87 + if(obj.isSlave==0){
  88 + myMasterRedis.push(obj);
  89 + }else if(obj.isSlave==1){
  90 + mySlaveRedis.push(obj);
  91 + }
42 92
  93 + }
  94 + });
  95 + contentHtml='<div class="col-md-4" id="aws" style="height: 300px;">'+
  96 + '<div class="panel panel-success-alt noborder" style="background-color: #5cb85c;">'+
  97 + '<div class="panel-heading noborder">'+
  98 + '<div>'+ '<div style="margin-left: 18px;"><img src="img/log_redis.png"><span style="font-size:28px;color: white;margin-left: 180px;">'+topNode+'</span></div>'+
  99 + '</div>'+
  100 + '<hr>'+
  101 + '<div class="clearfix mt15">'+
  102 + '<div class="pull-left">'+
  103 + '<h5 class="md-title nomargin" style="color: white;">twemproxy列表:'+activeCount+'(好),'+failedCount+'(失败)</h5>'+
  104 + '<h4 class="nomargin" style="font-size: 16px; line-height: 21px;">'+successIp+'</h4>'+
  105 + '</div>'+
  106 + '</div>'+
  107 + '</div>'+
  108 + '</div>'+
  109 + '</div>';
  110 + $("#redisAppendDiv").append(contentHtml);
43 }); 111 });
44 - }else{  
45 - alert("数据加载失败!");  
46 } 112 }
47 } 113 }
48 }); 114 });
  115 +
  116 + function displatyTetail(ip){
  117 + var detailListRedis=new Array();
  118 + $.each(myMasterRedis, function (i, myMasterObj) {
  119 + if(ip==myMasterObj.nodeFrom){
  120 + detailListRedis.push(myMasterObj);
  121 + $.each(mySlaveRedis, function (j, mySlaveObj) {
  122 + if(myMasterObj.nodeTo==mySlaveObj.nodeFrom){
  123 + detailListRedis.push(mySlaveObj);
  124 + }
  125 + });
  126 + }
  127 + });
  128 +
  129 + $("#redislistDetail").table({
  130 + columnAutoWidth : false,
  131 + data : detailListRedis,
  132 + striped : true,
  133 + columns : [{
  134 + title : "nodeFrom",
  135 + field : "nodeFrom",
  136 + width : "12%"
  137 + },{
  138 + title : "nodeTo",
  139 + field : "nodeTo",
  140 + width : "12%"
  141 + },{
  142 + title : "redis监控信息",
  143 + field : "paramMonitor",
  144 + width : "12%"
  145 + }]
  146 + });
  147 + $("#myModalLabel").text("twemproxy详细信息");
  148 + $("#myRedisProxyDetail").modal('show');
  149 + }
  150 +
49 </script> 151 </script>