diff --git a/ChangeLog b/ChangeLog index 61954999c..fa353c76d 100755 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,10 @@ $Source$ * libraries/dbi/mysqli.dbi.lib.php: - fixed undefined MYSQLI_BINARY_FLAG constant - documentation + * server_status.php: + - RFE #1434196 More significant digits in /status + - replaced number_format() with PMA_formatNumber() + - coding standards 2006-02-19 Marc Delisle * libraries/common.lib.php: re-establish previous error reporting mode diff --git a/server_status.php b/server_status.php index 28859bd0a..5352974ba 100644 --- a/server_status.php +++ b/server_status.php @@ -5,10 +5,10 @@ * displays status variables with descriptions and some hints an optmizing * + reset status variables */ -if ( ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) { - define( 'PMA_NO_VARIABLES_IMPORT', true ); +if (! defined('PMA_NO_VARIABLES_IMPORT')) { + define('PMA_NO_VARIABLES_IMPORT', true); } -require_once('./libraries/common.lib.php'); +require_once './libraries/common.lib.php'; /** * Does the common work @@ -25,13 +25,12 @@ require './libraries/server_links.inc.php'; /** * Displays the sub-page heading */ -echo '' . "\n"; echo '
' . "\n"; echo '

' . "\n" . ($GLOBALS['cfg']['MainPageIconic'] - ? '' - : '' ) + ? '' + : '') . $strServerStatus . "\n" . '

' . "\n"; @@ -39,37 +38,37 @@ echo '

' . "\n" /** * flush status variables if requested */ -if ( isset( $_REQUEST['flush'] ) ) { +if (isset($_REQUEST['flush'])) { $_flush_commands = array( 'STATUS', 'TABLES', 'QUERY CACHE', ); - if ( in_array( $_REQUEST['flush'], $_flush_commands ) ) { + if (in_array($_REQUEST['flush'], $_flush_commands)) { PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';'); } - unset( $_flush_commands ); + unset($_flush_commands); } /** * get status from server */ -if ( PMA_MYSQL_INT_VERSION >= 50002 ) { - $server_status = PMA_DBI_fetch_result( 'SHOW GLOBAL STATUS', 0, 1 ); +if (PMA_MYSQL_INT_VERSION >= 50002) { + $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1); } else { - $server_status = PMA_DBI_fetch_result( 'SHOW STATUS', 0, 1 ); + $server_status = PMA_DBI_fetch_result('SHOW STATUS', 0, 1); } /** * for some calculations we require also some server settings */ -if ( PMA_MYSQL_INT_VERSION >= 40003 ) { - $server_variables = PMA_DBI_fetch_result( 'SHOW GLOBAL VARIABLES', 0, 1 ); +if (PMA_MYSQL_INT_VERSION >= 40003) { + $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1); } else { - $server_variables = PMA_DBI_fetch_result( 'SHOW VARIABLES', 0, 1 ); + $server_variables = PMA_DBI_fetch_result('SHOW VARIABLES', 0, 1); } @@ -77,7 +76,7 @@ if ( PMA_MYSQL_INT_VERSION >= 40003 ) { * starttime calculation */ $start_time = PMA_DBI_fetch_value( - 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime'] ); + 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']); /** @@ -89,22 +88,22 @@ $deprecated = array( 'Com_dealloc_sql' => 'Com_stmt_close', ); -foreach ( $deprecated as $old => $new ) { - if ( isset( $server_status[$old] ) - && isset( $server_status[$new] ) ) { - unset( $server_status[$old] ); +foreach ($deprecated as $old => $new) { + if (isset($server_status[$old]) + && isset($server_status[$new])) { + unset($server_status[$old]); } } -unset( $deprecated ); +unset($deprecated); /** * calculate some values */ // Key_buffer_fraction -if ( isset( $server_status['Key_blocks_unused'] ) - && isset( $server_variables['key_cache_block_size'] ) - && isset( $server_variables['key_buffer_size'] ) ) { +if (isset($server_status['Key_blocks_unused']) + && isset($server_variables['key_cache_block_size']) + && isset($server_variables['key_buffer_size'])) { $server_status['Key_buffer_fraction_%'] = 100 - $server_status['Key_blocks_unused'] @@ -112,16 +111,16 @@ if ( isset( $server_status['Key_blocks_unused'] ) / $server_variables['key_buffer_size'] * 100; } elseif ( - isset( $server_status['Key_blocks_used'] ) - && isset( $server_variables['key_buffer_size'] ) ) { + isset($server_status['Key_blocks_used']) + && isset($server_variables['key_buffer_size'])) { $server_status['Key_buffer_fraction_%'] = $server_status['Key_blocks_used'] * 1024 / $server_variables['key_buffer_size']; } // Threads_cache_hitrate -if ( isset( $server_status['Threads_created'] ) - && isset( $server_status['Connections'] ) ) { +if (isset($server_status['Threads_created']) + && isset($server_status['Connections'])) { $server_status['Threads_cache_hitrate_%'] = 100 - $server_status['Threads_created'] @@ -224,23 +223,23 @@ $allocations = array( $sections = array( // section => section name (description) - 'com' => array( 'title' => '' ), - 'query' => array( 'title' => '' ), - 'innodb' => array( 'title' => 'InnoDB' ), - 'ndb' => array( 'title' => 'NDB' ), - 'ssl' => array( 'title' => 'SSL' ), - 'handler' => array( 'title' => $strHandler ), - 'qcache' => array( 'title' => $strQueryCache ), - 'threads' => array( 'title' => $strThreads ), - 'binlog_cache' => array( 'title' => $strBinaryLog ), - 'created_tmp' => array( 'title' => $strTempData ), - 'delayed' => array( 'title' => $strServerStatusDelayedInserts ), - 'key' => array( 'title' => $strKeyCache ), - 'select' => array( 'title' => $strJoins ), - 'repl' => array( 'title' => $strReplication ), - 'sort' => array( 'title' => $strSorting ), - 'table' => array( 'title' => $strNumTables ), - 'tc' => array( 'title' => $strTransactionCoordinator ), + 'com' => array('title' => ''), + 'query' => array('title' => ''), + 'innodb' => array('title' => 'InnoDB'), + 'ndb' => array('title' => 'NDB'), + 'ssl' => array('title' => 'SSL'), + 'handler' => array('title' => $strHandler), + 'qcache' => array('title' => $strQueryCache), + 'threads' => array('title' => $strThreads), + 'binlog_cache' => array('title' => $strBinaryLog), + 'created_tmp' => array('title' => $strTempData), + 'delayed' => array('title' => $strServerStatusDelayedInserts), + 'key' => array('title' => $strKeyCache), + 'select' => array('title' => $strJoins), + 'repl' => array('title' => $strReplication), + 'sort' => array('title' => $strSorting), + 'table' => array('title' => $strNumTables), + 'tc' => array('title' => $strTransactionCoordinator), ); @@ -298,21 +297,21 @@ $links['innodb']['MySQL - ' . $strDocu] // sort status vars into arrays -foreach ( $server_status as $name => $value ) { - if ( isset( $allocations[$name] ) ) { +foreach ($server_status as $name => $value) { + if (isset($allocations[$name])) { $sections[$allocations[$name]]['vars'][$name] = $value; - unset( $server_status[$name] ); + unset($server_status[$name]); } else { - foreach ( $allocations as $filter => $section ) { - if ( preg_match( '/^' . $filter . '/', $name ) - && isset( $server_status[$name] ) ) { - unset( $server_status[$name] ); + foreach ($allocations as $filter => $section) { + if (preg_match('/^' . $filter . '/', $name) + && isset($server_status[$name])) { + unset($server_status[$name]); $sections[$section]['vars'][$name] = $value; } } } } -unset( $name, $value, $filter, $section, $allocations ); +unset($name, $value, $filter, $section, $allocations); // rest $sections['all']['vars'] =& $server_status; @@ -337,16 +336,16 @@ $hour_factor = 3600 / $server_status['Uptime'];

@@ -484,18 +476,18 @@ foreach ( $sections as $section_name => $section ) { + PMA_formatNumber($server_status['Questions'], 4, 0); ?> + PMA_formatNumber($server_status['Questions'] * $hour_factor, + 3, 2); ?> + 3, 2); ?> + 3, 2); ?>
@@ -504,16 +496,16 @@ foreach ( $sections as $section_name => $section ) { $value ) { +$perc_factor = 100 / ($server_status['Questions'] - $server_status['Connections']); +foreach ($sections['com']['vars'] as $name => $value) { $current_table++; - if ( $countRows === 0 || $countRows === $rows_per_table ) { + if ($countRows === 0 || $countRows === $rows_per_table) { $odd_row = true; - if ( $countRows === $rows_per_table ) { + if ($countRows === $rows_per_table) { echo ' ' . "\n"; echo ' ' . "\n"; } @@ -537,18 +529,16 @@ foreach ( $sections['com']['vars'] 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. - $name = str_replace( 'Com_', '', $name ); - $name = str_replace( '_', ' ', $name ); + $name = str_replace('Com_', '', $name); + $name = str_replace('_', ' ', $name); ?> - - + + + PMA_formatNumber($value * $hour_factor, 4, 2); ?> % + PMA_formatNumber($value * $perc_factor, 0, 2); ?>% $section ) { - if ( ! empty( $section['vars'] ) ) { +foreach ($sections as $section_name => $section) { + if (! empty($section['vars'])) { ?> @@ -621,60 +611,58 @@ if ( ! empty( $section['title'] ) ) { $value ) { + foreach ($section['vars'] as $name => $value) { $odd_row = !$odd_row; ?>
" name=""> ' - : '' ); ?> + : ''); ?> @@ -601,16 +591,16 @@ if ( ! empty( $section['title'] ) ) {
$link_url ) { + foreach ($links[$section_name] as $link_name => $link_url) { echo '' . $link_name . '' . "\n"; } - unset( $link_url, $link_name ); + unset($link_url, $link_name); ?>
$alerts[$name] ) { + if (isset($alerts[$name])) { + if ($value > $alerts[$name]) { echo ''; } else { echo ''; } } - if ( '%' === substr( $name, -1, 1 ) ) { - echo number_format( $value, 2, - $GLOBALS['number_decimal_separator'], - $GLOBALS['number_thousands_separator'] ) . ' %'; - } elseif ( is_numeric( $value ) && $value == (int) $value ) { - echo PMA_formatNumber( $value, 3, 0 ); - } elseif ( is_numeric( $value ) ) { - echo PMA_formatNumber( $value, 3, 2 ); + if ('%' === substr($name, -1, 1)) { + echo PMA_formatNumber($value, 0, 2) . ' %'; + } elseif (is_numeric($value) && $value == (int) $value) { + echo PMA_formatNumber($value, 4, 0); + } elseif (is_numeric($value)) { + echo PMA_formatNumber($value, 4, 2); } else { - echo htmlspecialchars( $value ); + echo htmlspecialchars($value); } - if ( isset( $alerts[$name] ) ) { + if (isset($alerts[$name])) { echo ''; } ?> $link_url ) { + if (isset($links[$name])) { + foreach ($links[$name] as $link_name => $link_url) { echo ' ' . $link_name . '' . "\n"; } - unset( $link_url, $link_name ); + unset($link_url, $link_name); } ?>