main.tpl.php 6.1 KB

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