main.tpl.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. credits: {
  97. enabled: false,
  98. },
  99. series: [{
  100. type: 'pie',
  101. name: '可用性',
  102. data: [
  103. {
  104. name: '可用',
  105. y: <?php echo $global_rate;?>,
  106. sliced: true,
  107. selected: true,
  108. color: '#2f7ed8'
  109. },
  110. {
  111. name: '不可用',
  112. y: <?php echo (100-$global_rate);?>,
  113. sliced: true,
  114. selected: true,
  115. color: '#910000'
  116. }
  117. ]
  118. }]
  119. });
  120. $('#code-pie').highcharts({
  121. chart: {
  122. plotBackgroundColor: null,
  123. plotBorderWidth: null,
  124. plotShadow: false
  125. },
  126. title: {
  127. text: '<?php echo $date;?> 返回码分布'
  128. },
  129. tooltip: {
  130. pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  131. },
  132. plotOptions: {
  133. pie: {
  134. allowPointSelect: true,
  135. cursor: 'pointer',
  136. dataLabels: {
  137. enabled: true,
  138. color: '#000000',
  139. connectorColor: '#000000',
  140. format: '<b>{point.name}</b>: {point.percentage:.1f} %'
  141. }
  142. }
  143. },
  144. credits: {
  145. enabled: false,
  146. },
  147. series: [{
  148. type: 'pie',
  149. name: '返回码分布',
  150. data: [
  151. <?php echo $code_pie_data;?>
  152. ]
  153. }]
  154. });
  155. $('#req-container').highcharts({
  156. chart: {
  157. type: 'spline'
  158. },
  159. title: {
  160. text: '<?php echo "$date $interface_name";?> 请求量曲线'
  161. },
  162. subtitle: {
  163. text: ''
  164. },
  165. xAxis: {
  166. type: 'datetime',
  167. dateTimeLabelFormats: {
  168. hour: '%H:%M'
  169. }
  170. },
  171. yAxis: {
  172. title: {
  173. text: '请求量(次/5分钟)'
  174. },
  175. min: 0
  176. },
  177. tooltip: {
  178. formatter: function() {
  179. return '<p style="color:'+this.series.color+';font-weight:bold;">'
  180. + this.series.name +
  181. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">时间:' + Highcharts.dateFormat('%m月%d日 %H:%M', this.x) +
  182. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">数量:'+ this.y + '</p>';
  183. }
  184. },
  185. credits: {
  186. enabled: false,
  187. },
  188. series: [ {
  189. name: '成功曲线',
  190. data: [
  191. <?php echo $success_series_data;?>
  192. ],
  193. lineWidth: 2,
  194. marker:{
  195. radius: 1
  196. },
  197. pointInterval: 300*1000
  198. },
  199. {
  200. name: '失败曲线',
  201. data: [
  202. <?php echo $fail_series_data;?>
  203. ],
  204. lineWidth: 2,
  205. marker:{
  206. radius: 1
  207. },
  208. pointInterval: 300*1000,
  209. color : '#9C0D0D'
  210. }]
  211. });
  212. $('#time-container').highcharts({
  213. chart: {
  214. type: 'spline'
  215. },
  216. title: {
  217. text: '<?php echo "$date $interface_name";?> 请求耗时曲线'
  218. },
  219. subtitle: {
  220. text: ''
  221. },
  222. xAxis: {
  223. type: 'datetime',
  224. dateTimeLabelFormats: {
  225. hour: '%H:%M'
  226. }
  227. },
  228. yAxis: {
  229. title: {
  230. text: '平均耗时(单位:秒)'
  231. },
  232. min: 0
  233. },
  234. tooltip: {
  235. formatter: function() {
  236. return '<p style="color:'+this.series.color+';font-weight:bold;">'
  237. + this.series.name +
  238. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">时间:' + Highcharts.dateFormat('%m月%d日 %H:%M', this.x) +
  239. '</p><br /><p style="color:'+this.series.color+';font-weight:bold;">平均耗时:'+ this.y + '</p>';
  240. }
  241. },
  242. credits: {
  243. enabled: false,
  244. },
  245. series: [ {
  246. name: '成功曲线',
  247. data: [
  248. <?php echo $success_time_series_data;?>
  249. ],
  250. lineWidth: 2,
  251. marker:{
  252. radius: 1
  253. },
  254. pointInterval: 300*1000
  255. },
  256. {
  257. name: '失败曲线',
  258. data: [
  259. <?php echo $fail_time_series_data;?>
  260. ],
  261. lineWidth: 2,
  262. marker:{
  263. radius: 1
  264. },
  265. pointInterval: 300*1000,
  266. color : '#9C0D0D'
  267. } ]
  268. });
  269. </script>
  270. <table class="table table-hover table-condensed table-bordered">
  271. <thead>
  272. <tr>
  273. <th>时间</th><th>调用总数</th><th>平均耗时</th><th>成功调用总数</th><th>成功平均耗时</th><th>失败调用总数</th><th>失败平均耗时</th><th>成功率</th>
  274. </tr>
  275. </thead>
  276. <tbody>
  277. <?php echo $table_data;?>
  278. </tbody>
  279. </table>
  280. </div>
  281. </div>
  282. </div>