|
| 1 | +<html> |
| 2 | +<head> |
| 3 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 4 | + <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
| 6 | + <title>慢查询日志</title> |
| 7 | + |
| 8 | +<body> |
| 9 | + |
| 10 | +<style> |
| 11 | + td{border:1px solid red;} |
| 12 | +</style> |
| 13 | + |
| 14 | +<table style="table-layout:fixed;width:100%" border="1" cellpadding="1" cellspacing="0"> |
| 15 | +<thead> |
| 16 | +<tr> |
| 17 | +<th style="width:30%">抽象语句</th> |
| 18 | +<th style="width:10%">数据库</th> |
| 19 | +<th style="width:10%">用户名</th> |
| 20 | +<th style="width:10%">最近时间</th> |
| 21 | +<th style="width:5%">次数</th> |
| 22 | +<th style="width:5%">平均时间</th> |
| 23 | +</tr> |
| 24 | +</thead> |
| 25 | +<tbody> |
| 26 | + |
| 27 | +<?php |
| 28 | + require '../config.php'; |
| 29 | + $sql = "SELECT r.checksum,r.fingerprint,h.db_max,h.user_max,r.last_seen,SUM(h.ts_cnt) AS ts_cnt, |
| 30 | +ROUND(MIN(h.Query_time_min),3) AS Query_time_min,ROUND(MAX(h.Query_time_max),3) AS Query_time_max, |
| 31 | +ROUND(SUM(h.Query_time_sum)/SUM(h.ts_cnt),3) AS Query_time_avg,r.sample |
| 32 | +FROM mysql_slow_query_review AS r JOIN mysql_slow_query_review_history AS h |
| 33 | +ON r.checksum=h.checksum |
| 34 | +WHERE r.last_seen >= SUBDATE(NOW(),INTERVAL 1 DAY) |
| 35 | +GROUP BY r.checksum |
| 36 | +ORDER BY r.last_seen DESC,ts_cnt DESC LIMIT 100"; |
| 37 | + |
| 38 | + $result = mysqli_query($con,$sql); |
| 39 | + while($row = mysqli_fetch_array($result)) |
| 40 | + { |
| 41 | + echo "<tr>"; |
| 42 | + echo "<td width='30%'>" .$row['1'] ."</td>"; |
| 43 | + echo "<td align='center'>{$row['2']}</td>"; |
| 44 | + echo "<td align='center'>{$row['3']}</td>"; |
| 45 | + echo "<td align='center'>{$row['4']}</td>"; |
| 46 | + echo "<td align='center'>{$row['5']}</td>"; |
| 47 | + echo "<td align='center'>{$row['8']}</td>"; |
| 48 | + //echo "<td>{$row['6']}</td>"; |
| 49 | + //echo "<td>{$row['7']}</td>"; |
| 50 | + echo "</tr>"; |
| 51 | + } |
| 52 | + |
| 53 | + echo "</table>"; |
| 54 | + echo "</div>"; |
| 55 | + echo "</div>"; |
| 56 | + echo "</div>"; |
| 57 | + |
| 58 | +?> |
| 59 | + |
0 commit comments