Created
October 24, 2011 22:00
-
-
Save davidrenne/1310462 to your computer and use it in GitHub Desktop.
Show Process List HTML because pressing UP + ENTER in shell is annoying
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conn = mysql_connect('yourserver','yourusername','yourpassword'); | |
echo "<html><head><META HTTP-EQUIV='Refresh' CONTENT='2; URL=".$_SERVER['PHP_SELF']."'><body>"; | |
echo "<table><th>ID</th><th>DATABASE</th><th>QUERY</th><th>EXECUTION TIME</th><th>STATE</th>"; | |
$res = mysql_query("show processlist"); | |
while($row = mysql_fetch_assoc($res)) | |
{ | |
if (stristr($row['State'],"Has sent all binlog to slave")) | |
{ | |
continue; | |
} | |
$row['InfoNoLines'] = str_replace("\n","",$row['Info']); | |
$diff['processlist-'.$row['Id']] = "Id:{$row['Id']},Db:{$row['db']},Sql:{$row['InfoNoLines']},Tm:{$row['Time']},St:{$row['State']}"; | |
$style = ''; | |
if ($row['Time'] > 10 && $row['Time'] < 25) | |
{ | |
$style = 'color:red'; | |
} | |
elseif ($row['Time'] > 25) | |
{ | |
$style = 'color:red;font-size:25px;'; | |
} | |
echo "<tr style='$style'><td>{$row['Id']}</td><td>{$row['db']}</td><td style='max-width:200px;'>{$row['Info']}</td><td>{$row['Time']}</td><td>{$row['State']}</td></tr>"; | |
} | |
mysql_close($conn); | |
echo "</table>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment