PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/pma/server_status.php

https://bitbucket.org/StasPiv/playzone
PHP | 843 lines | 664 code | 81 blank | 98 comment | 61 complexity | 8fb5b16ca0761fec6c0dc0acb5cff238 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0, LGPL-2.1
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * displays status variables with descriptions and some hints an optmizing
  5. * + reset status variables
  6. *
  7. * @version $Id: server_status.php 12377 2009-04-19 12:01:48Z lem9 $
  8. * @package phpMyAdmin
  9. */
  10. /**
  11. * no need for variables importing
  12. * @ignore
  13. */
  14. if (! defined('PMA_NO_VARIABLES_IMPORT')) {
  15. define('PMA_NO_VARIABLES_IMPORT', true);
  16. }
  17. require_once './libraries/common.inc.php';
  18. /**
  19. * Does the common work
  20. */
  21. require './libraries/server_common.inc.php';
  22. /**
  23. * Displays the links
  24. */
  25. require './libraries/server_links.inc.php';
  26. /**
  27. * Displays the sub-page heading
  28. */
  29. echo '<div id="serverstatus">' . "\n";
  30. echo '<h2>' . "\n"
  31. . ($GLOBALS['cfg']['MainPageIconic']
  32. ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] .
  33. 's_status.png" width="16" height="16" alt="" />'
  34. : '')
  35. . $strServerStatus . "\n"
  36. . '</h2>' . "\n";
  37. /**
  38. * flush status variables if requested
  39. */
  40. if (isset($_REQUEST['flush'])) {
  41. $_flush_commands = array(
  42. 'STATUS',
  43. 'TABLES',
  44. 'QUERY CACHE',
  45. );
  46. if (in_array($_REQUEST['flush'], $_flush_commands)) {
  47. PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
  48. }
  49. unset($_flush_commands);
  50. }
  51. /**
  52. * get status from server
  53. */
  54. $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
  55. /**
  56. * get master status from server
  57. */
  58. $server_master_status = PMA_DBI_fetch_result('SHOW MASTER STATUS');
  59. /**
  60. * get slave status from server
  61. */
  62. $server_slave_status = PMA_DBI_fetch_result('SHOW SLAVE STATUS');
  63. /**
  64. * for some calculations we require also some server settings
  65. */
  66. $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
  67. /**
  68. * starttime calculation
  69. */
  70. $start_time = PMA_DBI_fetch_value(
  71. 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
  72. /**
  73. * cleanup some deprecated values
  74. */
  75. $deprecated = array(
  76. 'Com_prepare_sql' => 'Com_stmt_prepare',
  77. 'Com_execute_sql' => 'Com_stmt_execute',
  78. 'Com_dealloc_sql' => 'Com_stmt_close',
  79. );
  80. foreach ($deprecated as $old => $new) {
  81. if (isset($server_status[$old])
  82. && isset($server_status[$new])) {
  83. unset($server_status[$old]);
  84. }
  85. }
  86. unset($deprecated);
  87. /**
  88. * calculate some values
  89. */
  90. // Key_buffer_fraction
  91. if (isset($server_status['Key_blocks_unused'])
  92. && isset($server_variables['key_cache_block_size'])
  93. && isset($server_variables['key_buffer_size'])) {
  94. $server_status['Key_buffer_fraction_%'] =
  95. 100
  96. - $server_status['Key_blocks_unused']
  97. * $server_variables['key_cache_block_size']
  98. / $server_variables['key_buffer_size']
  99. * 100;
  100. } elseif (
  101. isset($server_status['Key_blocks_used'])
  102. && isset($server_variables['key_buffer_size'])) {
  103. $server_status['Key_buffer_fraction_%'] =
  104. $server_status['Key_blocks_used']
  105. * 1024
  106. / $server_variables['key_buffer_size'];
  107. }
  108. // Ratio for key read/write
  109. if (isset($server_status['Key_writes'])
  110. && isset($server_status['Key_write_requests'])
  111. && $server_status['Key_write_requests'] > 0)
  112. $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
  113. if (isset($server_status['Key_reads'])
  114. && isset($server_status['Key_read_requests'])
  115. && $server_status['Key_read_requests'] > 0)
  116. $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
  117. // Threads_cache_hitrate
  118. if (isset($server_status['Threads_created'])
  119. && isset($server_status['Connections'])
  120. && $server_status['Connections'] > 0) {
  121. $server_status['Threads_cache_hitrate_%'] =
  122. 100
  123. - $server_status['Threads_created']
  124. / $server_status['Connections']
  125. * 100;
  126. }
  127. /**
  128. * define some alerts
  129. */
  130. // name => max value before alert
  131. $alerts = array(
  132. // lower is better
  133. // variable => max value
  134. 'Aborted_clients' => 0,
  135. 'Aborted_connects' => 0,
  136. 'Binlog_cache_disk_use' => 0,
  137. 'Created_tmp_disk_tables' => 0,
  138. 'Handler_read_rnd' => 0,
  139. 'Handler_read_rnd_next' => 0,
  140. 'Innodb_buffer_pool_pages_dirty' => 0,
  141. 'Innodb_buffer_pool_reads' => 0,
  142. 'Innodb_buffer_pool_wait_free' => 0,
  143. 'Innodb_log_waits' => 0,
  144. 'Innodb_row_lock_time_avg' => 10, // ms
  145. 'Innodb_row_lock_time_max' => 50, // ms
  146. 'Innodb_row_lock_waits' => 0,
  147. 'Slow_queries' => 0,
  148. 'Delayed_errors' => 0,
  149. 'Select_full_join' => 0,
  150. 'Select_range_check' => 0,
  151. 'Sort_merge_passes' => 0,
  152. 'Opened_tables' => 0,
  153. 'Table_locks_waited' => 0,
  154. 'Qcache_lowmem_prunes' => 0,
  155. 'Slow_launch_threads' => 0,
  156. // depends on Key_read_requests
  157. // normaly lower then 1:0.01
  158. 'Key_reads' => (0.01 * $server_status['Key_read_requests']),
  159. // depends on Key_write_requests
  160. // normaly nearly 1:1
  161. 'Key_writes' => (0.9 * $server_status['Key_write_requests']),
  162. 'Key_buffer_fraction' => 0.5,
  163. // alert if more than 95% of thread cache is in use
  164. 'Threads_cached' => 0.95 * $server_variables['thread_cache_size']
  165. // higher is better
  166. // variable => min value
  167. //'Handler read key' => '> ',
  168. );
  169. /**
  170. * split variables in sections
  171. */
  172. $allocations = array(
  173. // variable name => section
  174. 'Com_' => 'com',
  175. 'Innodb_' => 'innodb',
  176. 'Ndb_' => 'ndb',
  177. 'Ssl_' => 'ssl',
  178. 'Handler_' => 'handler',
  179. 'Qcache_' => 'qcache',
  180. 'Threads_' => 'threads',
  181. 'Slow_launch_threads' => 'threads',
  182. 'Binlog_cache_' => 'binlog_cache',
  183. 'Created_tmp_' => 'created_tmp',
  184. 'Key_' => 'key',
  185. 'Delayed_' => 'delayed',
  186. 'Not_flushed_delayed_rows' => 'delayed',
  187. 'Flush_commands' => 'query',
  188. 'Last_query_cost' => 'query',
  189. 'Slow_queries' => 'query',
  190. 'Select_' => 'select',
  191. 'Sort_' => 'sort',
  192. 'Open_tables' => 'table',
  193. 'Opened_tables' => 'table',
  194. 'Table_locks_' => 'table',
  195. 'Rpl_status' => 'repl',
  196. 'Slave_' => 'repl',
  197. 'Tc_' => 'tc',
  198. );
  199. $sections = array(
  200. // section => section name (description)
  201. 'com' => array('title' => ''),
  202. 'query' => array('title' => $strSQLQuery),
  203. 'innodb' => array('title' => 'InnoDB'),
  204. 'ndb' => array('title' => 'NDB'),
  205. 'ssl' => array('title' => 'SSL'),
  206. 'handler' => array('title' => $strHandler),
  207. 'qcache' => array('title' => $strQueryCache),
  208. 'threads' => array('title' => $strThreads),
  209. 'binlog_cache' => array('title' => $strBinaryLog),
  210. 'created_tmp' => array('title' => $strTempData),
  211. 'delayed' => array('title' => $strServerStatusDelayedInserts),
  212. 'key' => array('title' => $strKeyCache),
  213. 'select' => array('title' => $strJoins),
  214. 'repl' => array('title' => $strReplication),
  215. 'sort' => array('title' => $strSorting),
  216. 'table' => array('title' => $strNumTables),
  217. 'tc' => array('title' => $strTransactionCoordinator),
  218. );
  219. /**
  220. * replication types
  221. */
  222. $replication_types = array('master', 'slave');
  223. /**
  224. * define variables for master status
  225. */
  226. $master_variables = array(
  227. 'File',
  228. 'Position',
  229. 'Binlog_Do_DB',
  230. 'Binlog_Ignore_DB'
  231. );
  232. /**
  233. * Define variables for slave status
  234. */
  235. $slave_variables = array(
  236. 'Slave_IO_State',
  237. 'Master_Host',
  238. 'Master_User',
  239. 'Master_Port',
  240. 'Connect_Retry',
  241. 'Master_Log_File',
  242. 'Read_Master_Log_Pos',
  243. 'Relay_Log_File',
  244. 'Relay_Log_Pos',
  245. 'Relay_Master_Log_File',
  246. 'Slave_IO_Running',
  247. 'Slave_SQL_Running',
  248. 'Replicate_Do_DB',
  249. 'Replicate_Ignore_DB',
  250. 'Replicate_Do_Table',
  251. 'Replicate_Ignore_Table',
  252. 'Replicate_Wild_Do_Table',
  253. 'Replicate_Wild_Ignore_Table',
  254. 'Last_Errno',
  255. 'Last_Error',
  256. 'Skip_Counter',
  257. 'Exec_Master_Log_Pos',
  258. 'Relay_Log_Space',
  259. 'Until_Condition',
  260. 'Until_Log_File',
  261. 'Until_Log_Pos',
  262. 'Master_SSL_Allowed',
  263. 'Master_SSL_CA_File',
  264. 'Master_SSL_CA_Path',
  265. 'Master_SSL_Cert',
  266. 'Master_SSL_Cipher',
  267. 'Master_SSL_Key',
  268. 'Seconds_Behind_Master'
  269. );
  270. /**
  271. * define important variables, which need to be watched for correct running of replication in slave mode
  272. */
  273. $slave_variables_alerts = array(
  274. 'Slave_IO_Running' => 'No',
  275. 'Slave_SQL_Running' => 'No'
  276. );
  277. $slave_variables_oks = array(
  278. 'Slave_IO_Running' => 'Yes',
  279. 'Slave_SQL_Running' => 'Yes'
  280. );
  281. /**
  282. * define some needfull links/commands
  283. */
  284. // variable or section name => (name => url)
  285. $links = array();
  286. $links['table'][$strFlushTables]
  287. = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
  288. $links['table'][$strShowOpenTables]
  289. = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
  290. '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
  291. $links['repl'][$strShowSlaveHosts]
  292. = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
  293. '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
  294. $links['repl'][$strShowSlaveStatus]
  295. = 'sql.php?sql_query=' . urlencode('SHOW SLAVE STATUS') .
  296. '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
  297. $links['repl']['doc'] = 'replication';
  298. $links['qcache'][$strFlushQueryCache]
  299. = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
  300. PMA_generate_common_url();
  301. $links['qcache']['doc'] = 'query_cache';
  302. $links['threads'][$strMySQLShowProcess]
  303. = 'server_processlist.php?' . PMA_generate_common_url();
  304. $links['threads']['doc'] = 'mysql_threads';
  305. $links['key']['doc'] = 'myisam_key_cache';
  306. $links['binlog_cache']['doc'] = 'binary_log';
  307. $links['Slow_queries']['doc'] = 'slow_query_log';
  308. $links['innodb'][$strServerTabVariables]
  309. = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
  310. $links['innodb'][$strInnodbStat]
  311. = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
  312. PMA_generate_common_url();
  313. $links['innodb']['doc'] = 'innodb';
  314. // sort status vars into arrays
  315. foreach ($server_status as $name => $value) {
  316. if (isset($allocations[$name])) {
  317. $sections[$allocations[$name]]['vars'][$name] = $value;
  318. unset($server_status[$name]);
  319. } else {
  320. foreach ($allocations as $filter => $section) {
  321. if (preg_match('/^' . $filter . '/', $name)
  322. && isset($server_status[$name])) {
  323. unset($server_status[$name]);
  324. $sections[$section]['vars'][$name] = $value;
  325. }
  326. }
  327. }
  328. }
  329. unset($name, $value, $filter, $section, $allocations);
  330. // check which replication is available
  331. foreach ($replication_types as $type)
  332. {
  333. if (count(${"server_{$type}_status"}) > 0)
  334. ${"server_{$type}_status_run"} = true;
  335. else
  336. ${"server_{$type}_status_run"} = false;
  337. }
  338. // rest
  339. $sections['all']['vars'] =& $server_status;
  340. $hour_factor = 3600 / $server_status['Uptime'];
  341. /**
  342. * start output
  343. */
  344. ?>
  345. <div id="statuslinks">
  346. <a href="<?php echo
  347. $PMA_PHP_SELF . '?' . PMA_generate_common_url(); ?>"
  348. ><?php echo $strRefresh; ?></a>
  349. <a href="<?php echo
  350. $PMA_PHP_SELF . '?flush=STATUS&amp;' . PMA_generate_common_url(); ?>"
  351. ><?php echo $strShowStatusReset; ?></a>
  352. <?php echo PMA_showMySQLDocu('server_status_variables','server_status_variables'); ?>
  353. </div>
  354. <p>
  355. <?php
  356. echo sprintf($strServerStatusUptime,
  357. PMA_timespanFormat($server_status['Uptime']),
  358. PMA_localisedDate($start_time)) . "\n";
  359. ?>
  360. </p>
  361. <?php
  362. if ($server_master_status_run || $server_slave_status_run)
  363. {
  364. $replicationOut = "";
  365. foreach ($replication_types as $type)
  366. {
  367. if ($replicationOut != "")
  368. $replicationOut .= $strAndSmall . ' ';
  369. if (${"server_{$type}_status_run"})
  370. {
  371. $replicationOut .= '<b>' . $type . '</b> ';
  372. }
  373. }
  374. echo sprintf('<p>' . $strReplicationStatusInfo . '</p>', $replicationOut);
  375. }
  376. ?>
  377. <div id="sectionlinks">
  378. <?php
  379. foreach ($sections as $section_name => $section) {
  380. if (! empty($section['vars']) && ! empty($section['title'])) {
  381. echo '<a href="' . $PMA_PHP_SELF . '?' .
  382. PMA_generate_common_url() . '#' . $section_name . '">' .
  383. $section['title'] . '</a>' . "\n";
  384. }
  385. }
  386. ?>
  387. </div>
  388. <h3><?php echo $strServerTrafficNotes; ?></h3>
  389. <table id="serverstatustraffic" class="data">
  390. <thead>
  391. <tr>
  392. <th colspan="2"><?php echo $strTraffic . '&nbsp;' . PMA_showHint($strStatisticsOverrun); ?></th>
  393. <th>&oslash; <?php echo $strPerHour; ?></th>
  394. </tr>
  395. </thead>
  396. <tbody>
  397. <tr class="odd">
  398. <th class="name"><?php echo $strReceived; ?></th>
  399. <td class="value"><?php echo
  400. implode(' ',
  401. PMA_formatByteDown($server_status['Bytes_received'], 4)); ?></td>
  402. <td class="value"><?php echo
  403. implode(' ',
  404. PMA_formatByteDown(
  405. $server_status['Bytes_received'] * $hour_factor, 4)); ?></td>
  406. </tr>
  407. <tr class="even">
  408. <th class="name"><?php echo $strSent; ?></th>
  409. <td class="value"><?php echo
  410. implode(' ',
  411. PMA_formatByteDown($server_status['Bytes_sent'], 4)); ?></td>
  412. <td class="value"><?php echo
  413. implode(' ',
  414. PMA_formatByteDown(
  415. $server_status['Bytes_sent'] * $hour_factor, 4)); ?></td>
  416. </tr>
  417. <tr class="odd">
  418. <th class="name"><?php echo $strTotalUC; ?></th>
  419. <td class="value"><?php echo
  420. implode(' ',
  421. PMA_formatByteDown(
  422. $server_status['Bytes_received'] + $server_status['Bytes_sent'], 4)
  423. ); ?></td>
  424. <td class="value"><?php echo
  425. implode(' ',
  426. PMA_formatByteDown(
  427. ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
  428. * $hour_factor, 4)
  429. ); ?></td>
  430. </tr>
  431. </tbody>
  432. </table>
  433. <table id="serverstatusconnections" class="data">
  434. <thead>
  435. <tr>
  436. <th colspan="2"><?php echo $strConnections; ?></th>
  437. <th>&oslash; <?php echo $strPerHour; ?></th>
  438. <th>%</th>
  439. </tr>
  440. </thead>
  441. <tbody>
  442. <tr class="odd">
  443. <th class="name"><?php echo $strMaxConnects; ?></th>
  444. <td class="value"><?php echo
  445. PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
  446. <td class="value">--- </td>
  447. <td class="value">--- </td>
  448. </tr>
  449. <tr class="even">
  450. <th class="name"><?php echo $strFailedAttempts; ?></th>
  451. <td class="value"><?php echo
  452. PMA_formatNumber($server_status['Aborted_connects'], 4, 0); ?></td>
  453. <td class="value"><?php echo
  454. PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
  455. 4, 2); ?></td>
  456. <td class="value"><?php echo
  457. $server_status['Connections'] > 0
  458. ? PMA_formatNumber(
  459. $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
  460. 0, 2) . '%'
  461. : '--- '; ?></td>
  462. </tr>
  463. <tr class="odd">
  464. <th class="name"><?php echo $strAbortedClients; ?></th>
  465. <td class="value"><?php echo
  466. PMA_formatNumber($server_status['Aborted_clients'], 4, 0); ?></td>
  467. <td class="value"><?php echo
  468. PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
  469. 4, 2); ?></td>
  470. <td class="value"><?php echo
  471. $server_status['Connections'] > 0
  472. ? PMA_formatNumber(
  473. $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
  474. 0, 2) . '%'
  475. : '--- '; ?></td>
  476. </tr>
  477. <tr class="even">
  478. <th class="name"><?php echo $strTotalUC; ?></th>
  479. <td class="value"><?php echo
  480. PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
  481. <td class="value"><?php echo
  482. PMA_formatNumber($server_status['Connections'] * $hour_factor,
  483. 4, 2); ?></td>
  484. <td class="value"><?php echo
  485. PMA_formatNumber(100, 0, 2); ?>%</td>
  486. </tr>
  487. </tbody>
  488. </table>
  489. <hr class="clearfloat" />
  490. <h3><?php echo
  491. sprintf($strQueryStatistics,
  492. PMA_formatNumber($server_status['Questions'], 0)); ?></h3>
  493. <table id="serverstatusqueriessummary" class="data">
  494. <thead>
  495. <tr>
  496. <th><?php echo $strTotalUC; ?></th>
  497. <th>&oslash; <?php echo $strPerHour; ?></th>
  498. <th>&oslash; <?php echo $strPerMinute; ?></th>
  499. <th>&oslash; <?php echo $strPerSecond; ?></th>
  500. </tr>
  501. </thead>
  502. <tbody>
  503. <tr class="odd">
  504. <td class="value"><?php echo
  505. PMA_formatNumber($server_status['Questions'], 4, 0); ?></td>
  506. <td class="value"><?php echo
  507. PMA_formatNumber($server_status['Questions'] * $hour_factor,
  508. 3, 2); ?></td>
  509. <td class="value"><?php echo
  510. PMA_formatNumber(
  511. $server_status['Questions'] * 60 / $server_status['Uptime'],
  512. 3, 2); ?></td>
  513. <td class="value"><?php echo
  514. PMA_formatNumber(
  515. $server_status['Questions'] / $server_status['Uptime'],
  516. 3, 2); ?></td>
  517. </tr>
  518. </tbody>
  519. </table>
  520. <div id="serverstatusqueriesdetails">
  521. <?php
  522. // number of tables to split values into
  523. $tables = 2;
  524. $rows_per_table = (int) ceil(count($sections['com']['vars']) / $tables);
  525. $current_table = 0;
  526. $odd_row = true;
  527. $countRows = 0;
  528. $perc_factor = 100 / ($server_status['Questions'] - $server_status['Connections']);
  529. foreach ($sections['com']['vars'] as $name => $value) {
  530. $current_table++;
  531. if ($countRows === 0 || $countRows === $rows_per_table) {
  532. $odd_row = true;
  533. if ($countRows === $rows_per_table) {
  534. echo ' </tbody>' . "\n";
  535. echo ' </table>' . "\n";
  536. }
  537. ?>
  538. <table id="serverstatusqueriesdetails<?php echo $current_table; ?>" class="data">
  539. <col class="namecol" />
  540. <col class="valuecol" span="3" />
  541. <thead>
  542. <tr><th colspan="2"><?php echo $strQueryType; ?></th>
  543. <th>&oslash; <?php echo $strPerHour; ?></th>
  544. <th>%</th>
  545. </tr>
  546. </thead>
  547. <tbody>
  548. <?php
  549. } else {
  550. $odd_row = !$odd_row;
  551. }
  552. $countRows++;
  553. // For the percentage column, use Questions - Connections, because
  554. // the number of connections is not an item of the Query types
  555. // but is included in Questions. Then the total of the percentages is 100.
  556. $name = str_replace('Com_', '', $name);
  557. $name = str_replace('_', ' ', $name);
  558. ?>
  559. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  560. <th class="name"><?php echo htmlspecialchars($name); ?></th>
  561. <td class="value"><?php echo PMA_formatNumber($value, 4, 0); ?></td>
  562. <td class="value"><?php echo
  563. PMA_formatNumber($value * $hour_factor, 4, 2); ?></td>
  564. <td class="value"><?php echo
  565. PMA_formatNumber($value * $perc_factor, 0, 2); ?>%</td>
  566. </tr>
  567. <?php
  568. }
  569. ?>
  570. </tbody>
  571. </table>
  572. </div>
  573. <div id="serverstatussection">
  574. <?php
  575. //Unset used variables
  576. unset(
  577. $tables, $rows_per_table, $current_table, $countRows, $perc_factor,
  578. $hour_factor, $sections['com'],
  579. $server_status['Aborted_clients'], $server_status['Aborted_connects'],
  580. $server_status['Max_used_connections'], $server_status['Bytes_received'],
  581. $server_status['Bytes_sent'], $server_status['Connections'],
  582. $server_status['Questions'], $server_status['Uptime']
  583. );
  584. foreach ($sections as $section_name => $section) {
  585. if (! empty($section['vars'])) {
  586. ?>
  587. <table class="data" id="serverstatussection<?php echo $section_name; ?>">
  588. <caption class="tblHeaders">
  589. <a class="top"
  590. href="<?php echo $PMA_PHP_SELF . '?' .
  591. PMA_generate_common_url() . '#serverstatus'; ?>"
  592. name="<?php echo $section_name; ?>"><?php echo $strPos1; ?>
  593. <?php echo
  594. ($GLOBALS['cfg']['MainPageIconic']
  595. ? '<img src="' . $GLOBALS['pmaThemeImage'] .
  596. 's_asc.png" width="11" height="9" align="middle" alt="" />'
  597. : ''); ?>
  598. </a>
  599. <?php
  600. if (! empty($section['title'])) {
  601. echo $section['title'];
  602. }
  603. ?>
  604. </caption>
  605. <col class="namecol" />
  606. <col class="valuecol" />
  607. <col class="descrcol" />
  608. <thead>
  609. <tr>
  610. <th><?php echo $strVar; ?></th>
  611. <th><?php echo $strValue; ?></th>
  612. <th><?php echo $strDescription; ?></th>
  613. </tr>
  614. </thead>
  615. <?php
  616. if (! empty($links[$section_name])) {
  617. ?>
  618. <tfoot>
  619. <tr class="tblFooters">
  620. <th colspan="3" class="tblFooters">
  621. <?php
  622. foreach ($links[$section_name] as $link_name => $link_url) {
  623. if ('doc' == $link_name) {
  624. echo PMA_showMySQLDocu($link_url, $link_url);
  625. } else {
  626. echo '<a href="' . $link_url . '">' . $link_name . '</a>' . "\n";
  627. }
  628. }
  629. unset($link_url, $link_name);
  630. ?>
  631. </th>
  632. </tr>
  633. </tfoot>
  634. <?php
  635. }
  636. ?>
  637. <tbody>
  638. <?php
  639. $odd_row = false;
  640. foreach ($section['vars'] as $name => $value) {
  641. $odd_row = !$odd_row;
  642. ?>
  643. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  644. <th class="name"><?php echo htmlspecialchars($name); ?></th>
  645. <td class="value"><?php
  646. if (isset($alerts[$name])) {
  647. if ($value > $alerts[$name]) {
  648. echo '<span class="attention">';
  649. } else {
  650. echo '<span class="allfine">';
  651. }
  652. }
  653. if ('%' === substr($name, -1, 1)) {
  654. echo PMA_formatNumber($value, 0, 2) . ' %';
  655. } elseif (is_numeric($value) && $value == (int) $value) {
  656. echo PMA_formatNumber($value, 4, 0);
  657. } elseif (is_numeric($value)) {
  658. echo PMA_formatNumber($value, 4, 2);
  659. } else {
  660. echo htmlspecialchars($value);
  661. }
  662. if (isset($alerts[$name])) {
  663. echo '</span>';
  664. }
  665. ?></td>
  666. <td class="descr">
  667. <?php
  668. if (isset($GLOBALS['strShowStatus' . $name . 'Descr'])) {
  669. echo $GLOBALS['strShowStatus' . $name . 'Descr'];
  670. }
  671. if (isset($links[$name])) {
  672. foreach ($links[$name] as $link_name => $link_url) {
  673. if ('doc' == $link_name) {
  674. echo PMA_showMySQLDocu($link_url, $link_url);
  675. } else {
  676. echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
  677. "\n";
  678. }
  679. }
  680. unset($link_url, $link_name);
  681. }
  682. ?>
  683. </td>
  684. </tr>
  685. <?php
  686. }
  687. unset($name, $value);
  688. ?>
  689. </tbody>
  690. </table>
  691. <?php
  692. }
  693. }
  694. unset($section_name, $section, $sections, $server_status, $odd_row, $alerts);
  695. ?>
  696. </div>
  697. <?php
  698. /* if the server works as master or slave in replication process, display useful information */
  699. if ($server_master_status_run || $server_slave_status_run)
  700. {
  701. ?>
  702. <hr class="clearfloat" />
  703. <h3><a name="replication"></a><?php echo $strReplicationStatus; ?></h3>
  704. <?php
  705. foreach ($replication_types as $type)
  706. {
  707. if (${"server_{$type}_status_run"})
  708. {
  709. ?>
  710. <h4><?php echo ${"strReplicationStatus_{$type}"}; ?></h4>
  711. <?php
  712. ?>
  713. <table id="server<?php echo $type; ?>replicationsummary" class="data">
  714. <thead>
  715. <tr>
  716. <th><?php echo $strVar; ?></th>
  717. <th><?php echo $strValue; ?></th>
  718. </tr>
  719. </thead>
  720. <tbody>
  721. <?php
  722. $odd_row = true;
  723. foreach(${"{$type}_variables"} as $variable)
  724. {
  725. ?>
  726. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  727. <td class="name">
  728. <?php echo $variable; ?>
  729. </td>
  730. <td class="value">
  731. <?php
  732. if (${"{$type}_variables_alerts"}[$variable] == ${"server_{$type}_status"}[0][$variable])
  733. echo '<span class="attention">';
  734. if (${"{$type}_variables_oks"}[$variable] == ${"server_{$type}_status"}[0][$variable])
  735. echo '<span class="allfine">';
  736. else
  737. echo '<span>';
  738. echo ${"server_{$type}_status"}[0][$variable];
  739. echo '</span>';
  740. ?>
  741. </td>
  742. </tr>
  743. <?php
  744. $odd_row = ! $odd_row;
  745. }
  746. unset(${"server_{$type}_status"});
  747. ?>
  748. </tbody>
  749. </table>
  750. <?php
  751. }
  752. }
  753. unset($types);
  754. }
  755. ?>
  756. </div>
  757. <?php
  758. /**
  759. * Sends the footer
  760. */
  761. require_once './libraries/footer.inc.php';
  762. ?>