Ejemplo n.º 1
0
/**
 * Main routine to call the various status functions
 */
function generate_status()
{
    global $context, $command_line, $db_show_debug;
    $context['debug'] = empty($db_show_debug) ? false : true;
    show_header();
    if (strpos(strtolower(PHP_OS), 'win') === 0) {
        get_windows_data();
    } else {
        get_linux_data();
    }
    get_mysql_data();
    if ($command_line) {
        if (!empty($context['operating_system']['name'])) {
            echo 'Operating System:   ', trim($context['operating_system']['name']), "\n";
        }
        if (!empty($context['cpu_info'])) {
            echo 'Processor:          ', trim($context['cpu_info']['model']), ' @ ', trim($context['cpu_info']['hz']), $context['cpu_info']['frequency'], ' (may report lower if power saving is enabled)', "\n";
        }
        if ($context['debug'] && !empty($context['lastserverreboot'])) {
            echo 'Server Last Reboot:        ', date(DATE_RSS, $context['lastserverreboot']), "\n";
        }
        if (isset($context['load_averages'])) {
            echo 'Load averages:      ', implode(', ', $context['load_averages']), "\n";
        }
        if (!empty($context['running_processes'])) {
            echo 'Current processes:  ', count($context['running_processes']), ' (', !empty($context['num_sleeping_processes']) ? $context['num_sleeping_processes'] . ' sleeping, ' : '', $context['num_running_processes'], ' running, ', $context['num_zombie_processes'], ' zombie)', "\n";
        }
        if (!empty($context['top_cpu_usage'])) {
            echo 'Processes by CPU:   ';
            $temp = array();
            foreach ($context['top_cpu_usage'] as $proc) {
                $temp[$proc['percent']] = $proc['name'] . ($proc['number'] > 1 ? ' (' . $proc['number'] . ') ' : ' ') . number_format($proc['percent'], 1) . '%';
            }
            krsort($temp);
            echo implode(', ', $temp), "\n";
        }
        if (!empty($context['memory_usage'])) {
            echo 'Memory usage:       ', round($context['memory_usage']['used'] * 100 / $context['memory_usage']['total'], 3), '% (', formatBytes($context['memory_usage']['used']), ' / ', formatBytes($context['memory_usage']['total']), ')', "\n";
        }
        if (isset($context['memory_usage']['swap_used'])) {
            echo 'Swap usage:         ', round($context['memory_usage']['swap_used'] * 100 / max(1, $context['memory_usage']['swap_total']), 3), '% (', formatBytes($context['memory_usage']['swap_used']), ' / ', formatBytes($context['memory_usage']['swap_total']), ')', "\n";
        }
        if (!empty($context['mysql_processes']) || !empty($context['mysql_num_sleeping_processes']) || !empty($context['mysql_num_locked_processes'])) {
            echo 'MySQL processes:    ', $context['mysql_num_running_processes'] + $context['mysql_num_locked_processes'] + $context['mysql_num_sleeping_processes'], ' (', $context['mysql_num_sleeping_processes'], ' sleeping, ', $context['mysql_num_running_processes'], ' running, ', $context['mysql_num_locked_processes'], ' locked)', "\n";
        }
        if (!empty($context['mysql_statistics'])) {
            echo "\n", 'MySQL statistics:', "\n";
            foreach ($context['mysql_statistics'] as $stat) {
                $warning = isset($stat['max']) && $stat['value'] > $stat['max'] || isset($stat['min']) && $stat['value'] < $stat['min'];
                $warning = $warning ? '(should be ' . (isset($stat['min']) ? '>= ' . $stat['min'] . ' ' : '') . (isset($stat['max'], $stat['min']) ? 'and ' : '') . (isset($stat['max']) ? '<= ' . $stat['max'] : '') . ')' : '';
                echo sprintf('%-34s%-6.6s %34s', $stat['description'] . ':', round($stat['value'], 4), $warning), "\n";
            }
        }
        return;
    }
    echo '
		<div class="panel">
			<h2>Basic Information</h2>
			<div class="righttext">', $context['current_time'], '</div>
			<table class="status_table">';
    if (!empty($context['operating_system']['name'])) {
        echo '
				<tr>
					<th style="text-align: left;">Operating System:</th>
					<td>', $context['operating_system']['name'], '</td>
				</tr>';
    }
    if (!empty($context['cpu_info'])) {
        echo '
				<tr>
					<th style="text-align: left;">Processor:</th>
					<td>', strtr($context['cpu_info']['model'], array('(R)' => '&reg;')), ' (', $context['cpu_info']['hz'], $context['cpu_info']['frequency'], ')</td>
				</tr>';
    }
    if ($context['debug'] && !empty($context['lastserverreboot'])) {
        echo '
				<tr>
					<th style="text-align: left;">Server Last Reboot:</th>
					<td>', date(DATE_RSS, $context['lastserverreboot']), '</td>
				</tr>';
    }
    if (isset($context['load_averages'])) {
        echo '
				<tr>
					<th style="text-align: left;">Load averages:</th>
					<td>', implode(', ', $context['load_averages']), '</td>
				</tr>';
    }
    if (!empty($context['running_processes'])) {
        echo '
				<tr>
					<th style="text-align: left;">Current processes:</th>
					<td>', count($context['running_processes']), ' (', !empty($context['num_sleeping_processes']) ? $context['num_sleeping_processes'] . ' sleeping, ' : '', $context['num_running_processes'], ' running, ', $context['num_zombie_processes'], ' zombie)</td>
				</tr>';
    }
    if (!empty($context['top_cpu_usage'])) {
        echo '
				<tr>
					<th style="text-align: left;">Processes by CPU:</th>
					<td>';
        $temp = array();
        foreach ($context['top_cpu_usage'] as $proc) {
            $temp[$proc['percent']] = htmlspecialchars($proc['name']) . ' <em>(' . $proc['number'] . ')</em> ' . number_format($proc['percent'], 1) . '%';
        }
        krsort($temp);
        echo implode(', ', $temp);
        echo '
					</td>
				</tr>';
    }
    if (!empty($context['memory_usage'])) {
        echo '
				<tr>
					<th style="text-align: left;">Memory usage:</th>
					<td>
						Main: ', round($context['memory_usage']['used'] * 100 / $context['memory_usage']['total'], 3), '% (', formatBytes($context['memory_usage']['used']), ' / ', formatBytes($context['memory_usage']['total']), ')';
        if (isset($context['memory_usage']['swap_used'])) {
            echo '<br />
						Swap: ', round($context['memory_usage']['swap_used'] * 100 / max(1, $context['memory_usage']['swap_total']), 3), '% (', formatBytes($context['memory_usage']['swap_used']), ' / ', formatBytes($context['memory_usage']['swap_total']), ')';
        }
        echo '
					</td>
				</tr>';
    }
    echo '
			</table>
		</div>';
    if (!empty($context['mysql_processes']) || !empty($context['mysql_num_sleeping_processes']) || !empty($context['mysql_num_locked_processes'])) {
        echo '
		<div class="panel">
			<h2>MySQL processes</h2>

			<table class="status_table">
				<tr>
					<th style="text-align: left;">Total processes:</th>
					<td>', $context['mysql_num_running_processes'] + $context['mysql_num_locked_processes'] + $context['mysql_num_sleeping_processes'], ' (', $context['mysql_num_sleeping_processes'], ' sleeping, ', $context['mysql_num_running_processes'], ' running, ', $context['mysql_num_locked_processes'], ' locked)</td>
				</tr>
			</table>';
        if (!empty($context['mysql_processes'])) {
            echo '
			<br />
			<h2>Running processes</h2>

			<table class="status_table">
				<tr>
					<th style="width: 14ex;">State</th>
					<th style="width: 8ex;">Time</th>
					<th>Query</th>
				</tr>';
            foreach ($context['mysql_processes'] as $proc) {
                echo '
				<tr>
					<td>', $proc['state'], '</td>
					<td style="text-align: center;">', $proc['time'], 's</td>
					<td><div style="width: 100%; ', strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ? 'max-' : '', 'height: 7em; overflow: auto;"><pre style="margin: 0; border: 1px solid gray;">';
                $temp = explode("\n", $proc['query']);
                $min_indent = 0;
                foreach ($temp as $line) {
                    preg_match('/^(\\t*)/', $line, $x);
                    if (strlen($x[0]) < $min_indent || $min_indent == 0) {
                        $min_indent = strlen($x[0]);
                    }
                }
                if ($min_indent > 0) {
                    $proc['query'] = '';
                    foreach ($temp as $line) {
                        $proc['query'] .= preg_replace('~^\\t{0,' . $min_indent . '}~i', '', $line) . "\n";
                    }
                }
                // Now, let's clean up the query.
                $clean = '';
                $old_pos = 0;
                $pos = -1;
                while (true) {
                    $pos = strpos($proc['query'], '\'', $pos + 1);
                    if ($pos === false) {
                        break;
                    }
                    $clean .= substr($proc['query'], $old_pos, $pos - $old_pos);
                    $str_pos = $pos;
                    while (true) {
                        $pos1 = strpos($proc['query'], '\'', $pos + 1);
                        $pos2 = strpos($proc['query'], '\\', $pos + 1);
                        if ($pos1 === false) {
                            break;
                        } elseif ($pos2 == false || $pos2 > $pos1) {
                            $pos = $pos1;
                            break;
                        }
                        $pos = $pos2 + 1;
                    }
                    $str = substr($proc['query'], $str_pos, $pos - $str_pos + 1);
                    $clean .= strlen($str) < 12 ? $str : '\'%s\'';
                    $old_pos = $pos + 1;
                }
                $clean .= substr($proc['query'], $old_pos);
                echo strtr(htmlspecialchars($clean), array("\n" => '<br />', "\r" => ''));
                echo '</pre></div></td>
				</tr>';
            }
            echo '
			</table>';
        }
        echo '
		</div>';
    }
    if (!empty($context['mysql_statistics'])) {
        echo '
		<div class="panel">
			<h2>MySQL Statistics</h2>
			<div class="roundframe">It is extremely important you fully understand each change you make to a MySQL database server. If you don\'t understand the output, or if you don\'t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust. Always test your changes on staging environments, and always keep in mind that improvements in one area can negatively affect MySQL in other areas.</div>
			<table class="status_table">';
        // Has this server been running less than 2 days?
        if (!empty($context['mysql_status']['Uptime']['value']) && $context['mysql_status']['Uptime']['value'] < 86400 * 2) {
            echo '
				<tr>
					<th  colspan="2" style="color:red;">We have detected MySQL was restarted less than 48 Hours ago. These recommendations may not be accurate.</th>
				</tr>';
        } elseif (!empty($context['mysql_status']['Uptime']['value'])) {
            $days = floor($context['mysql_status']['Uptime']['value'] / 86400);
            $hours = floor(($context['mysql_status']['Uptime']['value'] - $days * 86400) / (60 * 60));
            $min = floor(($context['mysql_status']['Uptime']['value'] - ($days * 86400 + $hours * 3600)) / 60);
            echo '
				<tr>
					<th style="text-align: left;">MySQL Uptime:</th>
					<td>', $days, ' Day(s), ', $hours, ':', $min, ' Hour(s)</td>
				</tr>';
        }
        foreach ($context['mysql_statistics'] as $stat) {
            echo '
				<tr>
					<th style="text-align: left;">';
            // Good, Bad or Ugly
            if (isset($stat['health'])) {
                if ($stat['health'] == 0) {
                    echo '<i class="fa fa-check good"></i>';
                } elseif ($stat['health'] == 1) {
                    echo '<i class="fa fa-exclamation-triangle pass"></i>';
                } else {
                    echo '<i class="fa fa-times bad"></i>';
                }
            }
            // Show the cnf setting that this refers to
            echo $stat['description'], ':', isset($stat['setting']) ? '<br />
						<em style="font-size: smaller;">(' . $stat['setting'] . ')</em>' : '', '
					</th>
					<td>';
            // Show the value
            if (isset($stat['format'])) {
                echo '[ <em>' . $stat['format'] . '</em> ] ';
            } else {
                echo '[ <em>' . round($stat['value'], 3) . '</em> ] ';
            }
            // Let them know what it all means
            if (!empty($stat['note'])) {
                echo $stat['note'];
            }
            if (!empty($stat['explain'])) {
                echo '<br /><i class="fa fa-info-circle info"></i>' . $stat['explain'];
            }
            echo '
					</td>
				</tr>';
        }
        echo '
			</table>';
        if (isset($_GET['mysql_info'])) {
            echo '
			<br />
			<h2>MySQL status</h2>
			<table width="100%" cellpadding="2" cellspacing="0" border="0">';
            foreach ($context['mysql_status'] as $var) {
                echo '
				<tr>
					<th style="text-align: left;">', $var['name'], ':</th>
					<td>', $var['value'], '</td>
				</tr>';
            }
            echo '
			</table>

			<br />
			<h2>MySQL variables</h2>

			<table class="status_table>';
            foreach ($context['mysql_variables'] as $var) {
                echo '
				<tr>
					<th style="text-align: left;">', $var['name'], ':</th>
					<td>', $var['value'], '</td>
				</tr>';
            }
            echo '
			</table>';
        } else {
            echo '
			<br />
			<a href="', $_SERVER['PHP_SELF'], '?mysql_info=1">Show more information...</a><br />';
        }
        echo '
		</div>';
    }
    show_footer();
}
Ejemplo n.º 2
0
function generate_status()
{
    global $context, $command_line, $db_show_debug;
    $context['debug'] = empty($db_show_debug) ? false : true;
    show_header();
    if (strpos(strtolower(PHP_OS), 'win') === 0) {
        get_windows_data();
    } else {
        get_linux_data();
    }
    get_mysql_data();
    if ($command_line) {
        if (!empty($context['operating_system']['name'])) {
            echo 'Operating System:   ', trim($context['operating_system']['name']), "\n";
        }
        if (!empty($context['cpu_info'])) {
            echo 'Processor:          ', trim($context['cpu_info']['model']), ' (', trim($context['cpu_info']['hz']), $context['cpu_info']['frequency'], ')', "\n";
        }
        if ($context['debug'] && !empty($context['lastserverreboot'])) {
            echo 'Server Last Reboot:        ', date(DATE_RSS, $context['lastserverreboot']), "\n";
        }
        if (isset($context['load_averages'])) {
            echo 'Load averages:      ', implode(', ', $context['load_averages']), "\n";
        }
        if (!empty($context['running_processes'])) {
            echo 'Current processes:  ', count($context['running_processes']), ' (', !empty($context['num_sleeping_processes']) ? $context['num_sleeping_processes'] . ' sleeping, ' : '', $context['num_running_processes'], ' running, ', $context['num_zombie_processes'], ' zombie)', "\n";
        }
        if (!empty($context['top_cpu_usage'])) {
            echo 'Processes by CPU:   ';
            $temp = array();
            foreach ($context['top_cpu_usage'] as $proc) {
                $temp[$proc['percent']] = $proc['name'] . ($proc['number'] > 1 ? ' (' . $proc['number'] . ') ' : ' ') . number_format($proc['percent'], 1) . '%';
            }
            krsort($temp);
            echo implode(', ', $temp), "\n";
        }
        if (!empty($context['memory_usage'])) {
            echo 'Memory usage:       ', round($context['memory_usage']['used'] * 100 / $context['memory_usage']['total'], 3), '% (', $context['memory_usage']['used'], 'k / ', $context['memory_usage']['total'], 'k)', "\n";
        }
        if (isset($context['memory_usage']['swap_used'])) {
            echo 'Swap usage:         ', round($context['memory_usage']['swap_used'] * 100 / max(1, $context['memory_usage']['swap_total']), 3), '% (', $context['memory_usage']['swap_used'], 'k / ', $context['memory_usage']['swap_total'], 'k)', "\n";
        }
        if (!empty($context['mysql_processes']) || !empty($context['mysql_num_sleeping_processes']) || !empty($context['mysql_num_locked_processes'])) {
            echo 'MySQL processes:    ', $context['mysql_num_running_processes'] + $context['mysql_num_locked_processes'] + $context['mysql_num_sleeping_processes'], ' (', $context['mysql_num_sleeping_processes'], ' sleeping, ', $context['mysql_num_running_processes'], ' running, ', $context['mysql_num_locked_processes'], ' locked)', "\n";
        }
        if (!empty($context['mysql_statistics'])) {
            echo "\n", 'MySQL statistics:', "\n";
            foreach ($context['mysql_statistics'] as $stat) {
                $warning = isset($stat['max']) && $stat['value'] > $stat['max'] || isset($stat['min']) && $stat['value'] < $stat['min'];
                $warning = $warning ? '(should be ' . (isset($stat['min']) ? '>= ' . $stat['min'] . ' ' : '') . (isset($stat['max'], $stat['min']) ? 'and ' : '') . (isset($stat['max']) ? '<= ' . $stat['max'] : '') . ')' : '';
                echo sprintf('%-34s%-6.6s %34s', $stat['description'] . ':', round($stat['value'], 4), $warning), "\n";
            }
        }
        return;
    }
    echo '
		<div class="panel">
			<h2>Basic Information</h2>

			<div class="righttext">', $context['current_time'], '</div>
			<table width="100%" cellpadding="2" cellspacing="0" border="0">';
    if (!empty($context['operating_system']['name'])) {
        echo '
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">Operating System:</th>
					<td>', $context['operating_system']['name'], '</td>
				</tr>';
    }
    if (!empty($context['cpu_info'])) {
        echo '
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">Processor:</th>
					<td>', strtr($context['cpu_info']['model'], array('(R)' => '&reg;')), ' (', $context['cpu_info']['hz'], $context['cpu_info']['frequency'], ')</td>
				</tr>';
    }
    if ($context['debug'] && !empty($context['lastserverreboot'])) {
        echo '
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">Server Last Reboot:</th>
					<td>', date(DATE_RSS, $context['lastserverreboot']), '</td>
				</tr>';
    }
    if (isset($context['load_averages'])) {
        echo '
				<tr>
					<th style="text-align: left; width: 30%;">Load averages:</th>
					<td>', implode(', ', $context['load_averages']), '</td>
				</tr>';
    }
    if (!empty($context['running_processes'])) {
        echo '
				<tr>
					<th style="text-align: left; width: 30%;">Current processes:</th>
					<td>', count($context['running_processes']), ' (', !empty($context['num_sleeping_processes']) ? $context['num_sleeping_processes'] . ' sleeping, ' : '', $context['num_running_processes'], ' running, ', $context['num_zombie_processes'], ' zombie)</td>
				</tr>';
    }
    if (!empty($context['top_cpu_usage'])) {
        echo '
				<tr>
					<th style="text-align: left; width: 30%;">Processes by CPU:</th>
					<td>';
        $temp = array();
        foreach ($context['top_cpu_usage'] as $proc) {
            $temp[$proc['percent']] = htmlspecialchars($proc['name']) . ' <em>(' . $proc['number'] . ')</em> ' . number_format($proc['percent'], 1) . '%';
        }
        krsort($temp);
        echo implode(', ', $temp);
        echo '
					</td>
				</tr>';
    }
    if (!empty($context['memory_usage'])) {
        echo '
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">Memory usage:</th>
					<td>
						', round($context['memory_usage']['used'] * 100 / $context['memory_usage']['total'], 3), '% (', $context['memory_usage']['used'], 'k / ', $context['memory_usage']['total'], 'k)';
        if (isset($context['memory_usage']['swap_used'])) {
            echo '<br />
						Swap: ', round($context['memory_usage']['swap_used'] * 100 / max(1, $context['memory_usage']['swap_total']), 3), '% (', $context['memory_usage']['swap_used'], 'k / ', $context['memory_usage']['swap_total'], 'k)';
        }
        echo '
					</td>
				</tr>';
    }
    echo '
			</table>
		</div>';
    if (!empty($context['mysql_processes']) || !empty($context['mysql_num_sleeping_processes']) || !empty($context['mysql_num_locked_processes'])) {
        echo '
		<div class="panel">
			<h2>MySQL processes</h2>

			<table width="100%" cellpadding="2" cellspacing="0" border="0">
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">Total processes:</th>
					<td>', $context['mysql_num_running_processes'] + $context['mysql_num_locked_processes'] + $context['mysql_num_sleeping_processes'], ' (', $context['mysql_num_sleeping_processes'], ' sleeping, ', $context['mysql_num_running_processes'], ' running, ', $context['mysql_num_locked_processes'], ' locked)</td>
				</tr>
			</table>';
        if (!empty($context['mysql_processes'])) {
            echo '
			<br />
			<h2>Running processes</h2>

			<table width="100%" cellpadding="2" cellspacing="0" border="0" style="table-layout: fixed;">
				<tr>
					<th style="width: 14ex;">State</th>
					<th style="width: 8ex;">Time</th>
					<th>Query</th>
				</tr>';
            foreach ($context['mysql_processes'] as $proc) {
                echo '
				<tr>
					<td>', $proc['state'], '</td>
					<td style="text-align: center;">', $proc['time'], 's</td>
					<td><div style="width: 100%; ', strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ? 'max-' : '', 'height: 7em; overflow: auto;"><pre style="margin: 0; border: 1px solid gray;">';
                $temp = explode("\n", $proc['query']);
                $min_indent = 0;
                foreach ($temp as $line) {
                    preg_match('/^(\\t*)/', $line, $x);
                    if (strlen($x[0]) < $min_indent || $min_indent == 0) {
                        $min_indent = strlen($x[0]);
                    }
                }
                if ($min_indent > 0) {
                    $proc['query'] = '';
                    foreach ($temp as $line) {
                        $proc['query'] .= preg_replace('~^\\t{0,' . $min_indent . '}~i', '', $line) . "\n";
                    }
                }
                // Now, let's clean up the query.
                $clean = '';
                $old_pos = 0;
                $pos = -1;
                while (true) {
                    $pos = strpos($proc['query'], '\'', $pos + 1);
                    if ($pos === false) {
                        break;
                    }
                    $clean .= substr($proc['query'], $old_pos, $pos - $old_pos);
                    $str_pos = $pos;
                    while (true) {
                        $pos1 = strpos($proc['query'], '\'', $pos + 1);
                        $pos2 = strpos($proc['query'], '\\', $pos + 1);
                        if ($pos1 === false) {
                            break;
                        } elseif ($pos2 == false || $pos2 > $pos1) {
                            $pos = $pos1;
                            break;
                        }
                        $pos = $pos2 + 1;
                    }
                    $str = substr($proc['query'], $str_pos, $pos - $str_pos + 1);
                    $clean .= strlen($str) < 12 ? $str : '\'%s\'';
                    $old_pos = $pos + 1;
                }
                $clean .= substr($proc['query'], $old_pos);
                echo strtr(htmlspecialchars($clean), array("\n" => '<br />', "\r" => ''));
                echo '</pre></div></td>
				</tr>';
            }
            echo '
			</table>';
        }
        echo '
		</div>';
    }
    if (!empty($context['mysql_statistics'])) {
        echo '
		<div class="panel">
			<h2>MySQL Statistics</h2>

			<div class="righttext">MySQL ', $context['mysql_version'], '</div>
			<table width="100%" cellpadding="2" cellspacing="0" border="0">';
        // Has this server been running less than 1 day?
        if (!empty($context['lastserverreboot']) && time() - $context['lastserverreboot'] < 86400) {
            echo '
				<tr>
					<th valign="top" colspan="2" style="color: red;">We have detected this server was restarted less than 24 Hours ago. These recommendations may not be accurate.</td>
				</tr>';
        }
        foreach ($context['mysql_statistics'] as $stat) {
            $warning = isset($stat['max']) && $stat['value'] > $stat['max'] || isset($stat['min']) && $stat['value'] < $stat['min'];
            echo '
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">
						', $stat['description'], ':', isset($stat['setting']) ? '<br />
						<em style="font-size: smaller;' . ($warning ? 'font-weight: bold;' : '') . '">(' . $stat['setting'] . ')</em>' : '', '
					</th>
					<td>
						', round($stat['value'], 4);
            if (isset($stat['max']) || isset($stat['min'])) {
                echo '
						', $warning ? '<strong>' : '', '(should be ', isset($stat['min']) ? '&gt;= ' . $stat['min'] . ' ' : '', isset($stat['max'], $stat['min']) ? 'and ' : '', isset($stat['max']) ? '&lt;= ' . $stat['max'] : '', ')', $warning ? '</strong>' : '';
            }
            echo '
					</td>
				</tr>';
        }
        echo '
			</table>';
        if (isset($_GET['mysql_info'])) {
            echo '
			<br />
			<h2>MySQL status</h2>

			<table width="100%" cellpadding="2" cellspacing="0" border="0">';
            foreach ($context['mysql_status'] as $var) {
                echo '
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">', $var['name'], ':</th>
					<td>', $var['value'], '</td>
				</tr>';
            }
            echo '
			</table>

			<br />
			<h2>MySQL variables</h2>

			<table width="100%" cellpadding="2" cellspacing="0" border="0">';
            foreach ($context['mysql_variables'] as $var) {
                echo '
				<tr>
					<th valign="top" style="text-align: left; width: 30%;">', $var['name'], ':</th>
					<td>', $var['value'], '</td>
				</tr>';
            }
            echo '
			</table>';
        } else {
            echo '
			<br />
			<a href="', $_SERVER['PHP_SELF'], '?mysql_info=1">Show more information...</a><br />';
        }
        echo '
		</div>';
    }
    show_footer();
}