main.tpl.php 6.0 KB

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