Skip to content

Instantly share code, notes, and snippets.

@davidrenne
Created October 24, 2011 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidrenne/1310462 to your computer and use it in GitHub Desktop.
Save davidrenne/1310462 to your computer and use it in GitHub Desktop.
Show Process List HTML because pressing UP + ENTER in shell is annoying
<?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