home *** CD-ROM | disk | FTP | other *** search
/ Freelog 70 / Freelog070.iso / Internet / EasyPHP / easyphp1-8_setup.exe / {app} / phpmyadmin / server_status.php < prev    next >
Encoding:
PHP Script  |  2004-10-19  |  14.5 KB  |  301 lines

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