307 lines
14 KiB
PHP
307 lines
14 KiB
PHP
<?php
|
|
/* $Id$ */
|
|
// vim: expandtab sw=4 ts=4 sts=4:
|
|
|
|
|
|
/**
|
|
* Does the common work
|
|
*/
|
|
require('./server_common.inc.php');
|
|
|
|
|
|
/**
|
|
* Displays the links
|
|
*/
|
|
require('./server_links.inc.php');
|
|
|
|
|
|
/**
|
|
* InnoDB status
|
|
*/
|
|
if (!empty($innodbstatus)) {
|
|
echo '<h2>' . "\n"
|
|
. ' ' . $strInnodbStat . "\n"
|
|
. '</h2>' . "\n";
|
|
$sql_query = 'SHOW INNODB STATUS;';
|
|
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
|
|
$row = PMA_mysql_fetch_row($res);
|
|
echo '<pre>' . "\n"
|
|
. htmlspecialchars($row[0]) . "\n"
|
|
. '</pre>' . "\n";
|
|
mysql_free_result($res);
|
|
include('./footer.inc.php');
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Displays the sub-page heading
|
|
*/
|
|
echo '<h2>' . "\n"
|
|
. ' ' . $strServerStatus . "\n"
|
|
. '</h2>' . "\n";
|
|
|
|
|
|
/**
|
|
* Checks if the user is allowed to do what he tries to...
|
|
*/
|
|
if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
|
|
echo $strNoPrivileges;
|
|
include('./footer.inc.php');
|
|
exit;
|
|
}
|
|
|
|
|
|
/**
|
|
* Sends the query and buffers the result
|
|
*/
|
|
$res = @PMA_mysql_query('SHOW STATUS;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW STATUS;');
|
|
while ($row = PMA_mysql_fetch_row($res)) {
|
|
$serverStatus[$row[0]] = $row[1];
|
|
}
|
|
@mysql_free_result($res);
|
|
unset($res);
|
|
unset($row);
|
|
|
|
|
|
/**
|
|
* Displays the page
|
|
*/
|
|
//Uptime calculation
|
|
$res = @PMA_mysql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
|
|
$row = PMA_mysql_fetch_row($res);
|
|
echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
|
|
mysql_free_result($res);
|
|
unset($res);
|
|
unset($row);
|
|
//Get query statistics
|
|
$queryStats = array();
|
|
$tmp_array = $serverStatus;
|
|
foreach($tmp_array AS $name => $value) {
|
|
if (substr($name, 0, 4) == 'Com_') {
|
|
$queryStats[str_replace('_', ' ', substr($name, 4))] = $value;
|
|
unset($serverStatus[$name]);
|
|
}
|
|
}
|
|
unset($tmp_array);
|
|
?>
|
|
<ul>
|
|
<li>
|
|
<!-- Server Traffic -->
|
|
<?php echo $strServerTrafficNotes; ?><br />
|
|
<table border="0">
|
|
<tr>
|
|
<td valign="top">
|
|
<table border="0">
|
|
<tr>
|
|
<th colspan="2"> <?php echo $strTraffic; ?> </th>
|
|
<th> ø <?php echo $strPerHour; ?> </th>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strReceived; ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?> </td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strSent; ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?> </td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?> </td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td valign="top">
|
|
<table border="0">
|
|
<tr>
|
|
<th colspan="2"> <?php echo $strConnections; ?> </th>
|
|
<th> ø <?php echo $strPerHour; ?> </th>
|
|
<th> % </th>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strFailedAttempts; ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_connects'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($serverStatus['Aborted_connects'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_connects'] * 100 / $serverStatus['Connections']), 2, $number_decimal_separator, $number_thousands_separator) . ' %' : '---'; ?> </td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strAbortedClients; ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_clients'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($serverStatus['Aborted_clients'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_clients'] * 100 / $serverStatus['Connections']), 2 , $number_decimal_separator, $number_thousands_separator) . ' %' : '---'; ?> </td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Connections'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(100, 2, $number_decimal_separator, $number_thousands_separator); ?> % </td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
<br />
|
|
<li>
|
|
<!-- Queries -->
|
|
<?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)) . "\n"; ?>
|
|
<table border="0">
|
|
<tr>
|
|
<td colspan="2">
|
|
<br />
|
|
<table border="0" align="right">
|
|
<tr>
|
|
<th> <?php echo $strTotalUC; ?> </th>
|
|
<th> ø <?php echo $strPerHour; ?> </th>
|
|
<th> ø <?php echo $strPerMinute; ?> </th>
|
|
<th> ø <?php echo $strPerSecond; ?> </th>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] * 60 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">
|
|
<table border="0">
|
|
<tr>
|
|
<th colspan="2"> <?php echo $strQueryType; ?> </th>
|
|
<th> ø <?php echo $strPerHour; ?> </th>
|
|
<th> % </th>
|
|
</tr>
|
|
<?php
|
|
|
|
$useBgcolorOne = TRUE;
|
|
$countRows = 0;
|
|
foreach ($queryStats as $name => $value) {
|
|
|
|
// For the percentage column, use Questions - Connections, because
|
|
// the number of connections is not an item of the Query types
|
|
// but is included in Questions. Then the total of the percentages is 100.
|
|
?>
|
|
<tr>
|
|
<td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars($name); ?> </td>
|
|
<td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($value, 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($value * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
|
|
<td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($value * 100 / ($serverStatus['Questions'] - $serverStatus['Connections'])), 2, $number_decimal_separator, $number_thousands_separator); ?> % </td>
|
|
</tr>
|
|
<?php
|
|
$useBgcolorOne = !$useBgcolorOne;
|
|
if (++$countRows == ceil(count($queryStats) / 2)) {
|
|
$useBgcolorOne = TRUE;
|
|
?>
|
|
</table>
|
|
</td>
|
|
<td valign="top">
|
|
<table border="0">
|
|
<tr>
|
|
<th colspan="2"> <?php echo $strQueryType; ?> </th>
|
|
<th> ø <?php echo $strPerHour; ?> </th>
|
|
<th> % </th>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
unset($countRows);
|
|
unset($useBgcolorOne);
|
|
?>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
<?php
|
|
//Unset used variables
|
|
unset($serverStatus['Aborted_clients']);
|
|
unset($serverStatus['Aborted_connects']);
|
|
unset($serverStatus['Bytes_received']);
|
|
unset($serverStatus['Bytes_sent']);
|
|
unset($serverStatus['Connections']);
|
|
unset($serverStatus['Questions']);
|
|
unset($serverStatus['Uptime']);
|
|
|
|
if (!empty($serverStatus)) {
|
|
?>
|
|
<br />
|
|
<li>
|
|
<!-- Other status variables -->
|
|
<b><?php echo $strMoreStatusVars; ?></b><br />
|
|
<table border="0">
|
|
<tr>
|
|
<td valign="top">
|
|
<table border="0">
|
|
<tr>
|
|
<th> <?php echo $strVar; ?> </th>
|
|
<th> <?php echo $strValue; ?> </th>
|
|
</tr>
|
|
<?php
|
|
$useBgcolorOne = TRUE;
|
|
$countRows = 0;
|
|
foreach($serverStatus AS $name => $value)= {
|
|
?>
|
|
<tr>
|
|
<td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?> </td>
|
|
<td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo htmlspecialchars($value); ?> </td>
|
|
</tr>
|
|
<?php
|
|
$useBgcolorOne = !$useBgcolorOne;
|
|
if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) {
|
|
$useBgcolorOne = TRUE;
|
|
?>
|
|
</table>
|
|
</td>
|
|
<td valign="top">
|
|
<table border="0">
|
|
<tr>
|
|
<th> <?php echo $strVar; ?> </th>
|
|
<th> <?php echo $strValue; ?> </th>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
unset($useBgcolorOne);
|
|
?>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
<?php
|
|
}
|
|
$res = PMA_mysql_query('SHOW VARIABLES LIKE "have_innodb";', $userlink);
|
|
if ($res) {
|
|
$row = PMA_mysql_fetch_row($res);
|
|
if (!empty($row[1]) && $row[1] == 'YES') {
|
|
?>
|
|
<br />
|
|
<li>
|
|
<!-- InnoDB Status -->
|
|
<a href="./server_status.php?<?php echo $url_query; ?>&innodbstatus=1">
|
|
<b><?php echo $strInnodbStat; ?></b>
|
|
</a>
|
|
</li>
|
|
<?php
|
|
}
|
|
} else {
|
|
unset($res);
|
|
}
|
|
?>
|
|
</ul>
|
|
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
* Sends the footer
|
|
*/
|
|
require('./footer.inc.php');
|
|
|
|
?>
|