PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/phpMyAdmin_old/server_status.php

https://bitbucket.org/steve_delbar/iepsm-projet-de-d-veloppement-internet-2013
PHP | 261 lines | 214 code | 18 blank | 29 comment | 12 complexity | cb9b7299209320f72bf84e613338d92d MD5 | raw file
  1. <?php
  2. /* $Id: server_status.php,v 2.12 2005/03/06 01:06:46 rabus Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4. /**
  5. * Does the common work
  6. */
  7. require('./server_common.inc.php');
  8. /**
  9. * Displays the links
  10. */
  11. require('./server_links.inc.php');
  12. /**
  13. * Displays the sub-page heading
  14. */
  15. echo '<h2>' . "\n"
  16. . ($GLOBALS['cfg']['MainPageIconic'] ? '<img src="' . $GLOBALS['pmaThemeImage'] . 's_status.png" width="16" height="16" border="0" hspace="2" align="middle" />' : '' )
  17. . ' ' . $strServerStatus . "\n"
  18. . '</h2>' . "\n";
  19. /**
  20. * Checks if the user is allowed to do what he tries to...
  21. */
  22. if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
  23. echo $strNoPrivileges;
  24. require_once('./footer.inc.php');
  25. }
  26. /**
  27. * Sends the query and buffers the result
  28. */
  29. $res = PMA_DBI_query('SHOW STATUS;');
  30. while ($row = PMA_DBI_fetch_row($res)) {
  31. $serverStatus[$row[0]] = $row[1];
  32. }
  33. PMA_DBI_free_result($res);
  34. unset($res, $row);
  35. /**
  36. * Displays the page
  37. */
  38. //Uptime calculation
  39. $res = PMA_DBI_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
  40. $row = PMA_DBI_fetch_row($res);
  41. echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
  42. PMA_DBI_free_result($res);
  43. unset($res, $row);
  44. //Get query statistics
  45. $queryStats = array();
  46. $tmp_array = $serverStatus;
  47. foreach ($tmp_array AS $name => $value) {
  48. if (substr($name, 0, 4) == 'Com_') {
  49. $queryStats[str_replace('_', ' ', substr($name, 4))] = $value;
  50. unset($serverStatus[$name]);
  51. }
  52. }
  53. unset($tmp_array);
  54. ?>
  55. <ul>
  56. <li>
  57. <!-- Server Traffic -->
  58. <?php echo $strServerTrafficNotes; ?><br />
  59. <table border="0" cellpadding="5" cellspacing="0">
  60. <tr>
  61. <td valign="top">
  62. <table border="0" cellpadding="2" cellspacing="1">
  63. <tr>
  64. <th colspan="2">&nbsp;<?php echo $strTraffic; ?>&nbsp;</th>
  65. <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
  66. </tr>
  67. <tr>
  68. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strReceived; ?>&nbsp;</td>
  69. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?>&nbsp;</td>
  70. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
  71. </tr>
  72. <tr>
  73. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strSent; ?>&nbsp;</td>
  74. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?>&nbsp;</td>
  75. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
  76. </tr>
  77. <tr>
  78. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
  79. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?>&nbsp;</td>
  80. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
  81. </tr>
  82. </table>
  83. </td>
  84. <td valign="top">
  85. <table border="0" cellpadding="2" cellspacing="1">
  86. <tr>
  87. <th colspan="2">&nbsp;<?php echo $strConnections; ?>&nbsp;</th>
  88. <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
  89. <th>&nbsp;%&nbsp;</th>
  90. </tr>
  91. <tr>
  92. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strFailedAttempts; ?>&nbsp;</td>
  93. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Aborted_connects'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  94. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Aborted_connects'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  95. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_connects'] * 100 / $serverStatus['Connections']), 2, $number_decimal_separator, $number_thousands_separator) . '&nbsp;%' : '---'; ?>&nbsp;</td>
  96. </tr>
  97. <tr>
  98. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strAbortedClients; ?>&nbsp;</td>
  99. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Aborted_clients'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  100. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Aborted_clients'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  101. <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_clients'] * 100 / $serverStatus['Connections']), 2 , $number_decimal_separator, $number_thousands_separator) . '&nbsp;%' : '---'; ?>&nbsp;</td>
  102. </tr>
  103. <tr>
  104. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
  105. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  106. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Connections'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  107. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(100, 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;%&nbsp;</td>
  108. </tr>
  109. </table>
  110. </td>
  111. </tr>
  112. </table>
  113. </li>
  114. <li>
  115. <!-- Queries -->
  116. <?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)) . "\n"; ?>
  117. <table border="0" cellpadding="5" cellspacing="0">
  118. <tr>
  119. <td colspan="2">
  120. <table border="0" cellpadding="2" cellspacing="1" width="100%">
  121. <tr>
  122. <th>&nbsp;<?php echo $strTotalUC; ?>&nbsp;</th>
  123. <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
  124. <th>&nbsp;&oslash;&nbsp;<?php echo $strPerMinute; ?>&nbsp;</th>
  125. <th>&nbsp;&oslash;&nbsp;<?php echo $strPerSecond; ?>&nbsp;</th>
  126. </tr>
  127. <tr>
  128. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  129. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  130. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] * 60 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  131. <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  132. </tr>
  133. </table>
  134. </td>
  135. </tr>
  136. <tr>
  137. <td valign="top">
  138. <table border="0" cellpadding="2" cellspacing="1">
  139. <tr>
  140. <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
  141. <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
  142. <th>&nbsp;%&nbsp;</th>
  143. </tr>
  144. <?php
  145. $useBgcolorOne = TRUE;
  146. $countRows = 0;
  147. foreach ($queryStats as $name => $value) {
  148. // For the percentage column, use Questions - Connections, because
  149. // the number of connections is not an item of the Query types
  150. // but is included in Questions. Then the total of the percentages is 100.
  151. ?>
  152. <tr>
  153. <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars($name); ?>&nbsp;</td>
  154. <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($value, 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  155. <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($value * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
  156. <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($value * 100 / ($serverStatus['Questions'] - $serverStatus['Connections'])), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;%&nbsp;</td>
  157. </tr>
  158. <?php
  159. $useBgcolorOne = !$useBgcolorOne;
  160. if (++$countRows == ceil(count($queryStats) / 2)) {
  161. $useBgcolorOne = TRUE;
  162. ?>
  163. </table>
  164. </td>
  165. <td valign="top">
  166. <table border="0" cellpadding="2" cellspacing="1">
  167. <tr>
  168. <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
  169. <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
  170. <th>&nbsp;%&nbsp;</th>
  171. </tr>
  172. <?php
  173. }
  174. }
  175. unset($countRows);
  176. unset($useBgcolorOne);
  177. ?>
  178. </table>
  179. </td>
  180. </tr>
  181. </table>
  182. </li>
  183. <?php
  184. //Unset used variables
  185. unset($serverStatus['Aborted_clients']);
  186. unset($serverStatus['Aborted_connects']);
  187. unset($serverStatus['Bytes_received']);
  188. unset($serverStatus['Bytes_sent']);
  189. unset($serverStatus['Connections']);
  190. unset($serverStatus['Questions']);
  191. unset($serverStatus['Uptime']);
  192. if (!empty($serverStatus)) {
  193. ?>
  194. <li>
  195. <!-- Other status variables -->
  196. <b><?php echo $strMoreStatusVars; ?></b><br />
  197. <table border="0" cellpadding="5" cellspacing="0">
  198. <tr>
  199. <td valign="top">
  200. <table border="0" cellpadding="2" cellspacing="1">
  201. <tr>
  202. <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
  203. <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
  204. </tr>
  205. <?php
  206. $useBgcolorOne = TRUE;
  207. $countRows = 0;
  208. foreach ($serverStatus AS $name => $value) {
  209. ?>
  210. <tr>
  211. <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?>&nbsp;</td>
  212. <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo htmlspecialchars($value); ?>&nbsp;</td>
  213. </tr>
  214. <?php
  215. $useBgcolorOne = !$useBgcolorOne;
  216. if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) {
  217. $useBgcolorOne = TRUE;
  218. ?>
  219. </table>
  220. </td>
  221. <td valign="top">
  222. <table border="0" cellpadding="2" cellspacing="1">
  223. <tr>
  224. <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
  225. <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
  226. </tr>
  227. <?php
  228. }
  229. }
  230. unset($useBgcolorOne);
  231. ?>
  232. </table>
  233. </td>
  234. </tr>
  235. </table>
  236. </li>
  237. <?php
  238. }
  239. /**
  240. * Sends the footer
  241. */
  242. require_once('./footer.inc.php');
  243. ?>