I have a script that I was using for several years that monitored the activity of the MySQL database .. including the MB in and out processed.
Currently running v5.0.58, everything works except for the in/out traffic
<?
// Mysql Info
if (!$connect) {
$connect = mysql_connect("$db_machine", "xxxxxxxxxxxx", "xxxxxxxxxxxxx");
}
if ($kill_process == 'yes') {
$sql = "kill $process_id";
$go = mysql_query($sql);
if ($go) {
echo "<font size = '4' color = 'red'><b>Process $process_id Killed</font></b><br><br>";
}
}
$query = "show status";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
$var_name = $r["Variable_name"];
$value = $r["Value"];
if ($var_name == 'Bytes_received') {
$bytes_in = ($value /1024) /1024;
}
if ($var_name == 'Bytes_sent') {
$bytes_out = ($value /1024) /1024;
}
if ($var_name == 'Connections') {
$connections = $value;
}
if ($var_name == 'Slow_queries') {
$slow_queries = $value;
}
if ($var_name == 'Questions') {
$queries = $value;
}
if ($var_name == 'Key_reads') {
$key_reads = $value;
}
if ($var_name == 'Key_read_requests') {
$key_requests = $value;
}
if ($var_name == 'Uptime') {
$uptime_raw = $value;
$uptime = $uptime_raw;
$days = floor($uptime / (24*3600));
$uptime = $uptime - ($days * (24*3600));
$hours = floor($uptime / (3600));
$uptime = $uptime - ($hours * (3600));
$minutes = floor($uptime /(60));
$uptime = $uptime - ($minutes * 60);
$seconds = $uptime;
$uptime = "$days Days $hours:$minutes:$seconds";
}
}
?>
I also follow it with the basic table that shows the data:
<table width = 80% border = '1'>
<tr>
<td colspan = '2'>
<font size = '1' face = 'Verdana'><b>In:</b></font><br>
<font size = '1' face = 'Verdana'><? echo round($bytes_in, 2) ?> MB</font>
</td>
<td colspan = '2'>
<font size = '1' face = 'Verdana'><b>Out:</b></font><br>
<font size = '1' face = 'Verdana'><? echo round($bytes_out, 2); ?> MB</font>
</td>
</tr>
<tr>
<td>
<font size = '1' face = 'Verdana'><b>Connections:</b></font><br>
<font size = '1' face = 'Verdana'><? echo $connections ?></font>
</td>
<td>
<font size = '1' face = 'Verdana'><b>Queries:</b></font><br>
<font size = '1' face = 'Verdana'><? echo $queries ?></font>
</td>
<td>
<font size = '1' face = 'Verdana'><b>Slow Queries:</b></font><br>
<font size = '1' face = 'Verdana'><? echo $slow_queries ?></font>
</td>
<td>
<font size = '1' face = 'Verdana'><b>Key Eff:</b></font><br>
<font size = '1' face = 'Verdana'><?
$cached_precent = round(100-($key_reads/$key_requests) * 100, 2);
echo $cached_precent;?> %</font>
</td>
</tr>
<tr>
<td colspan = '2'>
<font size = '1' face = 'Verdana'><b>Uptime:</b></font><br>
<font size = '1' face = 'Verdana'><? echo $uptime ?></font>
</td>
<td colspan = '2'>
<font size = '1' face = 'Verdana'><b>Ave Queries/Sec:</b></font><br>
<font size = '1' face = 'Verdana'><? echo round($queries/$uptime_raw, 2); ?></font>
</td>
</tr>
</table>
Anyone know where the problem lies? I removed the second division and it exports 92 and 72, but never changes.