monitor.tmpl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {{template "header.tmpl" .}}
  2. </head>
  3. <body>
  4. {{template "navbar.tmpl" .}}
  5. <div class="container-fluid">
  6. <h4 class="text-center">Redis监控日志列表</h4>
  7. <hr />
  8. <form class="form-inline" id="filterform" style="margin-bottom:10px;">
  9. <div class="form-group" style="margin-right:20px;">
  10. <label>Redis实例:</label>
  11. <select class="form-control" name="redis_id" autocomplete="off">
  12. <option value="0">所有</option>
  13. </select>
  14. </div>
  15. <div class="form-group">
  16. <label>排序方式:</label>
  17. <select class="form-control" name="order" autocomplete="off">
  18. <option value="ASC">正序</option>
  19. <option value="DESC" selected="selected">倒序</option>
  20. </select>
  21. </div>
  22. </form>
  23. <table class="table table-bordered table-striped">
  24. <thead>
  25. <tr>
  26. <th>ID</th>
  27. <th>Redis ID</th>
  28. <th>Redis地址</th>
  29. <th>Redis备注</th>
  30. <th>检测时间</th>
  31. <th>服务状态</th>
  32. <th>连续异常次数</th>
  33. <th>已用内存</th>
  34. <th>分配内存</th>
  35. <th>系统内存</th>
  36. <th>客户连接数</th>
  37. <th>QPS</th>
  38. <th>淘汰KEY数量</th>
  39. <th>新增淘汰KEY数量</th>
  40. </tr>
  41. </thead>
  42. <tbody id="list"></tbody>
  43. </table>
  44. <div id="pager" class="text-center"></div>
  45. </div>
  46. <script type="text/javascript">
  47. var $SESS = {{.Sess}};
  48. $(function(){
  49. var PAGE_SIZE = 20;
  50. var form = $('#filterform').get(0);
  51. function init() {
  52. $.get('/syscfg/redis_list', {}, function(resp) {
  53. if (resp && resp.errno == 0) {
  54. var selector = $(form.redis_id);
  55. for (var i=0; i<resp.data.length; i++) {
  56. var item = resp.data[i];
  57. selector.append($(`<option value="${item.Id}">#${item.Id}[${item.Address}] ${item.Remark}</opton>`));
  58. }
  59. }
  60. }, 'json');
  61. }
  62. function load(p) {
  63. $.get('/log/monitor_list', {
  64. 'size': PAGE_SIZE,
  65. 'page': p || 1,
  66. 'redis_id': form.redis_id.value,
  67. 'order': form.order.value
  68. }, function(resp){
  69. if (resp && resp.errno == 0) {
  70. var html = '';
  71. for (var i=0; i<resp.data.List.length; i++) {
  72. html += '<tr>';
  73. html += ' <td>' + resp.data.List[i].Id + '</td>';
  74. html += ' <td>' + resp.data.List[i].RedisId + '</td>';
  75. html += ' <td>' + resp.data.List[i].RedisAddress + '</td>';
  76. html += ' <td>' + resp.data.List[i].RedisRemark + '</td>';
  77. html += ' <td>' + time2str(resp.data.List[i].LogTime) + '</td>';
  78. html += ' <td' + (resp.data.List[i].QueryStatus ? '' : ' class="danger"') + '>' + (resp.data.List[i].QueryStatus ? '正常' : '异常') + '</td>';
  79. html += ' <td>' + resp.data.List[i].FailedCount + '</td>';
  80. html += ' <td>' + size2str(resp.data.List[i].UsedMemory) + '</td>';
  81. html += ' <td>' + size2str(resp.data.List[i].MaxMemory) + '</td>';
  82. html += ' <td>' + size2str(resp.data.List[i].SystemMemory) + '</td>';
  83. html += ' <td>' + resp.data.List[i].Connection + '</td>';
  84. html += ' <td>' + resp.data.List[i].QPS + '</td>';
  85. html += ' <td>' + resp.data.List[i].EvictedKeys + '</td>';
  86. html += ' <td>' + resp.data.List[i].EviIncreased + '</td>';
  87. html += '</tr>';
  88. }
  89. $('#list').html(html);
  90. pager({
  91. 'id': 'pager',
  92. 'total': resp.data.Count,
  93. 'page_size': PAGE_SIZE,
  94. 'page_num': p,
  95. 'callback': load
  96. });
  97. }
  98. }, 'json');
  99. return false;
  100. }
  101. $('select', form).change(function(){
  102. load(1);
  103. return false;
  104. });
  105. init();
  106. load(1);
  107. });
  108. </script>
  109. </body>
  110. </html>