main.tpl.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <div class="container">
  2. <div class="row clearfix">
  3. <div class="col-md-12 column">
  4. <ul class="nav nav-tabs">
  5. <li class="active">
  6. <a href="/">概述</a>
  7. </li>
  8. <li>
  9. <a href="/?fn=statistic">监控</a>
  10. </li>
  11. <li>
  12. <a href="/?fn=logger">日志</a>
  13. </li>
  14. <li class="disabled">
  15. <a href="#">告警</a>
  16. </li>
  17. <li class="dropdown pull-right">
  18. <a href="#" data-toggle="dropdown" class="dropdown-toggle">其它<strong class="caret"></strong></a>
  19. <ul class="dropdown-menu">
  20. <li>
  21. <a href="/?fn=admin&act=detect_server">探测节点</a>
  22. </li>
  23. <li>
  24. <a href="/?fn=admin">节点管理</a>
  25. </li>
  26. </ul>
  27. </li>
  28. </ul>
  29. </div>
  30. </div>
  31. <div class="row clearfix">
  32. <div class="col-md-12 column">
  33. <?php if($err_msg){?>
  34. <div class="alert alert-dismissable alert-danger">
  35. <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
  36. <strong><?php echo $err_msg;?></strong>
  37. </div>
  38. <?php }?>
  39. <div class="row clearfix">
  40. <div class="col-md-12 column text-center">
  41. <?php echo $date_btn_str;?>
  42. </div>
  43. </div>
  44. <div class="row clearfix">
  45. <div class="col-md-6 column height-400" id="suc-pie">
  46. </div>
  47. <div class="col-md-6 column height-400" id="code-pie">
  48. </div>
  49. </div>
  50. <div class="row clearfix">
  51. <div class="col-md-12 column height-400" id="req-container" >
  52. </div>
  53. </div>
  54. <div class="row clearfix">
  55. <div class="col-md-12 column height-400" id="time-container" >
  56. </div>
  57. </div>
  58. <script>
  59. Highcharts.setOptions({
  60. global: {
  61. useUTC: false
  62. }
  63. });
  64. $('#suc-pie').highcharts({
  65. chart: {
  66. plotBackgroundColor: null,
  67. plotBorderWidth: null,
  68. plotShadow: false
  69. },
  70. title: {
  71. text: '<?php echo $date;?> 可用性'
  72. },
  73. tooltip: {
  74. pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  75. },
  76. plotOptions: {
  77. pie: {
  78. allowPointSelect: true,
  79. cursor: 'pointer',
  80. dataLabels: {
  81. enabled: true,
  82. color: '#000000',
  83. connectorColor: '#000000',
  84. format: '<b>{point.name}</b>: {point.percentage:.1f} %'
  85. }
  86. }
  87. },
  88. series: [{
  89. type: 'pie',
  90. name: '可用性',
  91. data: [
  92. {
  93. name: '可用',
  94. y: <?php echo $global_rate;?>,
  95. sliced: true,
  96. selected: true,
  97. color: '#2f7ed8'
  98. },
  99. {
  100. name: '不可用',
  101. y: <?php echo (100-$global_rate);?>,
  102. sliced: true,
  103. selected: true,
  104. color: '#910000'
  105. }
  106. ]
  107. }]
  108. });
  109. $('#code-pie').highcharts({
  110. chart: {
  111. plotBackgroundColor: null,
  112. plotBorderWidth: null,
  113. plotShadow: false
  114. },
  115. title: {
  116. text: '<?php echo $date;?> 返回码分布'
  117. },
  118. tooltip: {
  119. pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  120. },
  121. plotOptions: {
  122. pie: {
  123. allowPointSelect: true,
  124. cursor: 'pointer',
  125. dataLabels: {
  126. enabled: true,
  127. color: '#000000',
  128. connectorColor: '#000000',
  129. format: '<b>{point.name}</b>: {point.percentage:.1f} %'
  130. }
  131. }
  132. },
  133. series: [{
  134. type: 'pie',
  135. name: '返回码分布',
  136. data: [
  137. <?php echo $code_pie_data;?>
  138. ]
  139. }]
  140. });
  141. $('#req-container').highcharts({
  142. chart: {
  143. type: 'spline'
  144. },
  145. title: {
  146. text: '<?php echo "$date $interface_name";?> 请求量曲线'
  147. },
  148. subtitle: {
  149. text: ''
  150. },
  151. xAxis: {
  152. type: 'datetime',
  153. dateTimeLabelFormats: {
  154. hour: '%H:%M'
  155. }
  156. },
  157. yAxis: {
  158. title: {
  159. text: '请求量(次/5分钟)'
  160. },
  161. min: 0
  162. },
  163. tooltip: {
  164. formatter: function() {
  165. return '<p style="color:'+this.series.color+';font-weight:bold;">'
  166. + this.series.name +
  167. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">时间:' + Highcharts.dateFormat('%m月%d日 %H:%M', this.x) +
  168. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">数量:'+ this.y + '</p>';
  169. }
  170. },
  171. credits: {
  172. enabled: false,
  173. },
  174. series: [ {
  175. name: '成功曲线',
  176. data: [
  177. <?php echo $success_series_data;?>
  178. ],
  179. lineWidth: 2,
  180. marker:{
  181. radius: 1
  182. },
  183. pointInterval: 300*1000
  184. },
  185. {
  186. name: '失败曲线',
  187. data: [
  188. <?php echo $fail_series_data;?>
  189. ],
  190. lineWidth: 2,
  191. marker:{
  192. radius: 1
  193. },
  194. pointInterval: 300*1000,
  195. color : '#9C0D0D'
  196. }]
  197. });
  198. $('#time-container').highcharts({
  199. chart: {
  200. type: 'spline'
  201. },
  202. title: {
  203. text: '<?php echo "$date $interface_name";?> 请求耗时曲线'
  204. },
  205. subtitle: {
  206. text: ''
  207. },
  208. xAxis: {
  209. type: 'datetime',
  210. dateTimeLabelFormats: {
  211. hour: '%H:%M'
  212. }
  213. },
  214. yAxis: {
  215. title: {
  216. text: '平均耗时(单位:秒)'
  217. },
  218. min: 0
  219. },
  220. tooltip: {
  221. formatter: function() {
  222. return '<p style="color:'+this.series.color+';font-weight:bold;">'
  223. + this.series.name +
  224. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">时间:' + Highcharts.dateFormat('%m月%d日 %H:%M', this.x) +
  225. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">平均耗时:'+ this.y + '</p>';
  226. }
  227. },
  228. credits: {
  229. enabled: false,
  230. text: "jumei.com",
  231. href: "http://www.jumei.com"
  232. },
  233. series: [ {
  234. name: '成功曲线',
  235. data: [
  236. <?php echo $success_time_series_data;?>
  237. ],
  238. lineWidth: 2,
  239. marker:{
  240. radius: 1
  241. },
  242. pointInterval: 300*1000
  243. },
  244. {
  245. name: '失败曲线',
  246. data: [
  247. <?php echo $fail_time_series_data;?>
  248. ],
  249. lineWidth: 2,
  250. marker:{
  251. radius: 1
  252. },
  253. pointInterval: 300*1000,
  254. color : '#9C0D0D'
  255. } ]
  256. });
  257. </script>
  258. <table class="table table-hover table-condensed table-bordered">
  259. <thead>
  260. <tr>
  261. <th>时间</th><th>调用总数</th><th>平均耗时</th><th>成功调用总数</th><th>成功平均耗时</th><th>失败调用总数</th><th>失败平均耗时</th><th>成功率</th>
  262. </tr>
  263. </thead>
  264. <tbody>
  265. <?php echo $table_data;?>
  266. </tbody>
  267. </table>
  268. </div>
  269. </div>
  270. </div>