home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / server_status.php < prev    next >
Encoding:
PHP Script  |  2003-11-26  |  14.1 KB  |  305 lines

  1. <?php
  2. /* $Id: server_status.php,v 2.4 2003/11/26 22:52:24 rabus Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. /**
  7.  * Does the common work
  8.  */
  9. require('./server_common.inc.php');
  10.  
  11.  
  12. /**
  13.  * Displays the links
  14.  */
  15. require('./server_links.inc.php');
  16.  
  17.  
  18. /**
  19.  * InnoDB status
  20.  */
  21. if (!empty($innodbstatus)) {
  22.     echo '<h2>' . "\n"
  23.        . '    ' . $strInnodbStat . "\n"
  24.        . '</h2>' . "\n";
  25.     $sql_query = 'SHOW INNODB STATUS;';
  26.     $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
  27.     $row = PMA_mysql_fetch_row($res);
  28.     echo '<pre>' . "\n"
  29.        . htmlspecialchars($row[0]) . "\n"
  30.        . '</pre>' . "\n";
  31.     mysql_free_result($res);
  32.     require_once('./footer.inc.php');
  33. }
  34.  
  35. /**
  36.  * Displays the sub-page heading
  37.  */
  38. echo '<h2>' . "\n"
  39.    . '    ' . $strServerStatus . "\n"
  40.    . '</h2>' . "\n";
  41.  
  42.  
  43. /**
  44.  * Checks if the user is allowed to do what he tries to...
  45.  */
  46. if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
  47.     echo $strNoPrivileges;
  48.     require_once('./footer.inc.php');
  49. }
  50.  
  51.  
  52. /**
  53.  * Sends the query and buffers the result
  54.  */
  55. $res = @PMA_mysql_query('SHOW STATUS;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW STATUS;');
  56. while ($row = PMA_mysql_fetch_row($res)) {
  57.     $serverStatus[$row[0]] = $row[1];
  58. }
  59. @mysql_free_result($res);
  60. unset($res);
  61. unset($row);
  62.  
  63.  
  64. /**
  65.  * Displays the page
  66.  */
  67. //Uptime calculation
  68. $res = @PMA_mysql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
  69. $row = PMA_mysql_fetch_row($res);
  70. echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
  71. mysql_free_result($res);
  72. unset($res);
  73. unset($row);
  74. //Get query statistics
  75. $queryStats = array();
  76. $tmp_array = $serverStatus;
  77. foreach($tmp_array AS $name => $value) {
  78.     if (substr($name, 0, 4) == 'Com_') {
  79.         $queryStats[str_replace('_', ' ', substr($name, 4))] = $value;
  80.         unset($serverStatus[$name]);
  81.     }
  82. }
  83. unset($tmp_array);
  84. ?>
  85. <ul>
  86.     <li>
  87.         <!-- Server Traffic -->
  88.         <?php echo $strServerTrafficNotes; ?><br />
  89.         <table border="0">
  90.             <tr>
  91.                 <td valign="top">
  92.                     <table border="0">
  93.                         <tr>
  94.                             <th colspan="2"> <?php echo $strTraffic; ?> </th>
  95.                             <th> ø <?php echo $strPerHour; ?> </th>
  96.                         </tr>
  97.                         <tr>
  98.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strReceived; ?> </td>
  99.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?> </td>
  100.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?> </td>
  101.                         </tr>
  102.                         <tr>
  103.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strSent; ?> </td>
  104.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?> </td>
  105.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?> </td>
  106.                         </tr>
  107.                         <tr>
  108.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td>
  109.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?> </td>
  110.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?> </td>
  111.                         </tr>
  112.                     </table>
  113.                 </td>
  114.                 <td valign="top">
  115.                     <table border="0">
  116.                         <tr>
  117.                             <th colspan="2"> <?php echo $strConnections; ?> </th>
  118.                             <th> ø <?php echo $strPerHour; ?> </th>
  119.                             <th> % </th>
  120.                         </tr>
  121.                         <tr>
  122.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strFailedAttempts; ?> </td>
  123.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_connects'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  124.                             <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>
  125.                             <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>
  126.                         </tr>
  127.                         <tr>
  128.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strAbortedClients; ?> </td>
  129.                             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_clients'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  130.                             <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>
  131.                             <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>
  132.                         </tr>
  133.                         <tr>
  134.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td>
  135.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  136.                             <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>
  137.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(100, 2, $number_decimal_separator, $number_thousands_separator); ?> % </td>
  138.                         </tr>
  139.                     </table>
  140.                 </td>
  141.             </tr>
  142.         </table>
  143.     </li>
  144.     <br />
  145.     <li>
  146.         <!-- Queries -->
  147.         <?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)) . "\n"; ?>
  148.         <table border="0">
  149.             <tr>
  150.                 <td colspan="2">
  151.                     <br />
  152.                     <table border="0" align="right">
  153.                         <tr>
  154.                             <th> <?php echo $strTotalUC; ?> </th>
  155.                             <th> ø <?php echo $strPerHour; ?> </th>
  156.                             <th> ø <?php echo $strPerMinute; ?> </th>
  157.                             <th> ø <?php echo $strPerSecond; ?> </th>
  158.                         </tr>
  159.                         <tr>
  160.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  161.                             <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>
  162.                             <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>
  163.                             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td>
  164.                         </tr>
  165.                     </table>
  166.                 </td>
  167.             </tr>
  168.             <tr>
  169.                 <td valign="top">
  170.                     <table border="0">
  171.                         <tr>
  172.                             <th colspan="2"> <?php echo $strQueryType; ?> </th>
  173.                             <th> ø <?php echo $strPerHour; ?> </th>
  174.                             <th> % </th>
  175.                         </tr>
  176. <?php
  177.  
  178. $useBgcolorOne = TRUE;
  179. $countRows = 0;
  180. foreach ($queryStats as $name => $value) {
  181.  
  182. // For the percentage column, use Questions - Connections, because
  183. // the number of connections is not an item of the Query types
  184. // but is included in Questions. Then the total of the percentages is 100.
  185. ?>
  186.                         <tr>
  187.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars($name); ?> </td>
  188.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($value, 0, $number_decimal_separator, $number_thousands_separator); ?> </td>
  189.                             <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>
  190.                             <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>
  191.                         </tr>
  192. <?php
  193.     $useBgcolorOne = !$useBgcolorOne;
  194.     if (++$countRows == ceil(count($queryStats) / 2)) {
  195.         $useBgcolorOne = TRUE;
  196. ?>
  197.                     </table>
  198.                 </td>
  199.                 <td valign="top">
  200.                     <table border="0">
  201.                         <tr>
  202.                             <th colspan="2"> <?php echo $strQueryType; ?> </th>
  203.                             <th> ø <?php echo $strPerHour; ?> </th>
  204.                             <th> % </th>
  205.                         </tr>
  206. <?php
  207.     }
  208. }
  209. unset($countRows);
  210. unset($useBgcolorOne);
  211. ?>
  212.                     </table>
  213.                 </td>
  214.             </tr>
  215.         </table>
  216.     </li>
  217. <?php
  218. //Unset used variables
  219. unset($serverStatus['Aborted_clients']);
  220. unset($serverStatus['Aborted_connects']);
  221. unset($serverStatus['Bytes_received']);
  222. unset($serverStatus['Bytes_sent']);
  223. unset($serverStatus['Connections']);
  224. unset($serverStatus['Questions']);
  225. unset($serverStatus['Uptime']);
  226.  
  227. if (!empty($serverStatus)) {
  228. ?>
  229.     <br />
  230.     <li>
  231.         <!-- Other status variables -->
  232.         <b><?php echo $strMoreStatusVars; ?></b><br />
  233.         <table border="0">
  234.             <tr>
  235.                 <td valign="top">
  236.                     <table border="0">
  237.                         <tr>
  238.                             <th> <?php echo $strVar; ?> </th>
  239.                             <th> <?php echo $strValue; ?> </th>
  240.                         </tr>
  241. <?php
  242.     $useBgcolorOne = TRUE;
  243.     $countRows = 0;
  244.     foreach($serverStatus AS $name => $value) {
  245. ?>
  246.                         <tr>
  247.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?> </td>
  248.                             <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo htmlspecialchars($value); ?> </td>
  249.                         </tr>
  250. <?php
  251.         $useBgcolorOne = !$useBgcolorOne;
  252.         if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) {
  253.             $useBgcolorOne = TRUE;
  254. ?>
  255.                     </table>
  256.                 </td>
  257.                 <td valign="top">
  258.                     <table border="0">
  259.                         <tr>
  260.                             <th> <?php echo $strVar; ?> </th>
  261.                             <th> <?php echo $strValue; ?> </th>
  262.                         </tr>
  263. <?php
  264.         }
  265.     }
  266.     unset($useBgcolorOne);
  267. ?>
  268.                     </table>
  269.                 </td>
  270.             </tr>
  271.         </table>
  272.     </li>
  273. <?php
  274. }
  275. $res = PMA_mysql_query('SHOW VARIABLES LIKE "have_innodb";', $userlink);
  276. if ($res) {
  277.     $row = PMA_mysql_fetch_row($res);
  278.     if (!empty($row[1]) && $row[1] == 'YES') {
  279. ?>
  280.     <br />
  281.     <li>
  282.         <!-- InnoDB Status -->
  283.         <a href="./server_status.php?<?php echo $url_query; ?>&innodbstatus=1">
  284.             <b><?php echo $strInnodbStat; ?></b>
  285.         </a>
  286.     </li>
  287. <?php
  288.     }
  289. } else {
  290.     unset($res);
  291. }
  292. ?>
  293. </ul>
  294.  
  295.  
  296. <?php
  297.  
  298.  
  299. /**
  300.  * Sends the footer
  301.  */
  302. require_once('./footer.inc.php');
  303.  
  304. ?>
  305.