' . "\n";
echo '
' . "\n"
. ($GLOBALS['cfg']['MainPageIconic']
? '
'
: '')
. __('Runtime Information') . "\n"
. '
' . "\n";
/**
* flush status variables if requested
*/
if (isset($_REQUEST['flush'])) {
$_flush_commands = array(
'STATUS',
'TABLES',
'QUERY CACHE',
);
if (in_array($_REQUEST['flush'], $_flush_commands)) {
PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
}
unset($_flush_commands);
}
/**
* get status from server
*/
$server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
/**
* for some calculations we require also some server settings
*/
$server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
/**
* starttime calculation
*/
$start_time = PMA_DBI_fetch_value(
'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
/**
* cleanup some deprecated values
*/
$deprecated = array(
'Com_prepare_sql' => 'Com_stmt_prepare',
'Com_execute_sql' => 'Com_stmt_execute',
'Com_dealloc_sql' => 'Com_stmt_close',
);
foreach ($deprecated as $old => $new) {
if (isset($server_status[$old])
&& isset($server_status[$new])) {
unset($server_status[$old]);
}
}
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'])) {
$server_status['Key_buffer_fraction_%'] =
100
- $server_status['Key_blocks_unused']
* $server_variables['key_cache_block_size']
/ $server_variables['key_buffer_size']
* 100;
} elseif (
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'];
}
// Ratio for key read/write
if (isset($server_status['Key_writes'])
&& isset($server_status['Key_write_requests'])
&& $server_status['Key_write_requests'] > 0)
$server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
if (isset($server_status['Key_reads'])
&& isset($server_status['Key_read_requests'])
&& $server_status['Key_read_requests'] > 0)
$server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
// Threads_cache_hitrate
if (isset($server_status['Threads_created'])
&& isset($server_status['Connections'])
&& $server_status['Connections'] > 0) {
$server_status['Threads_cache_hitrate_%'] =
100
- $server_status['Threads_created']
/ $server_status['Connections']
* 100;
}
// Format Uptime_since_flush_status : show as days, hours, minutes, seconds
if (isset($server_status['Uptime_since_flush_status'])) {
$server_status['Uptime_since_flush_status'] = PMA_timespanFormat($server_status['Uptime_since_flush_status']);
}
/**
* define some alerts
*/
// name => max value before alert
$alerts = array(
// lower is better
// variable => max value
'Aborted_clients' => 0,
'Aborted_connects' => 0,
'Binlog_cache_disk_use' => 0,
'Created_tmp_disk_tables' => 0,
'Handler_read_rnd' => 0,
'Handler_read_rnd_next' => 0,
'Innodb_buffer_pool_pages_dirty' => 0,
'Innodb_buffer_pool_reads' => 0,
'Innodb_buffer_pool_wait_free' => 0,
'Innodb_log_waits' => 0,
'Innodb_row_lock_time_avg' => 10, // ms
'Innodb_row_lock_time_max' => 50, // ms
'Innodb_row_lock_waits' => 0,
'Slow_queries' => 0,
'Delayed_errors' => 0,
'Select_full_join' => 0,
'Select_range_check' => 0,
'Sort_merge_passes' => 0,
'Opened_tables' => 0,
'Table_locks_waited' => 0,
'Qcache_lowmem_prunes' => 0,
'Slow_launch_threads' => 0,
// depends on Key_read_requests
// normaly lower then 1:0.01
'Key_reads' => (0.01 * $server_status['Key_read_requests']),
// depends on Key_write_requests
// normaly nearly 1:1
'Key_writes' => (0.9 * $server_status['Key_write_requests']),
'Key_buffer_fraction' => 0.5,
// alert if more than 95% of thread cache is in use
'Threads_cached' => 0.95 * $server_variables['thread_cache_size']
// higher is better
// variable => min value
//'Handler read key' => '> ',
);
/**
* split variables in sections
*/
$allocations = array(
// variable name => section
'Com_' => 'com',
'Innodb_' => 'innodb',
'Ndb_' => 'ndb',
'Handler_' => 'handler',
'Qcache_' => 'qcache',
'Threads_' => 'threads',
'Slow_launch_threads' => 'threads',
'Binlog_cache_' => 'binlog_cache',
'Created_tmp_' => 'created_tmp',
'Key_' => 'key',
'Delayed_' => 'delayed',
'Not_flushed_delayed_rows' => 'delayed',
'Flush_commands' => 'query',
'Last_query_cost' => 'query',
'Slow_queries' => 'query',
'Select_' => 'select',
'Sort_' => 'sort',
'Open_tables' => 'table',
'Opened_tables' => 'table',
'Table_locks_' => 'table',
'Rpl_status' => 'repl',
'Slave_' => 'repl',
'Tc_' => 'tc',
'Ssl_' => 'ssl',
);
$sections = array(
// section => section name (description)
'com' => array('title' => ''),
'query' => array('title' => __('SQL query')),
'innodb' => array('title' => 'InnoDB'),
'ndb' => array('title' => 'NDB'),
'handler' => array('title' => __('Handler')),
'qcache' => array('title' => __('Query cache')),
'threads' => array('title' => __('Threads')),
'binlog_cache' => array('title' => __('Binary log')),
'created_tmp' => array('title' => __('Temporary data')),
'delayed' => array('title' => __('Delayed inserts')),
'key' => array('title' => __('Key cache')),
'select' => array('title' => __('Joins')),
'repl' => array('title' => __('Replication')),
'sort' => array('title' => __('Sorting')),
'table' => array('title' => __('Tables')),
'tc' => array('title' => __('Transaction coordinator')),
'ssl' => array('title' => 'SSL'),
);
/**
* define some needfull links/commands
*/
// variable or section name => (name => url)
$links = array();
$links['table'][__('Flush (close) all tables')]
= $PMA_PHP_SELF . '?flush=TABLES&' . PMA_generate_common_url();
$links['table'][__('Show open tables')]
= 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
'&goto=server_status.php&' . PMA_generate_common_url();
if ($server_master_status) {
$links['repl'][__('Show slave hosts')]
= 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
'&goto=server_status.php&' . PMA_generate_common_url();
$links['repl'][__('Show master status')] = '#replication_master';
}
if ($server_slave_status) {
$links['repl'][__('Show slave status')] = '#replication_slave';
}
$links['repl']['doc'] = 'replication';
$links['qcache'][__('Flush query cache')]
= $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&' .
PMA_generate_common_url();
$links['qcache']['doc'] = 'query_cache';
$links['threads'][__('Show processes')]
= 'server_processlist.php?' . PMA_generate_common_url();
$links['threads']['doc'] = 'mysql_threads';
$links['key']['doc'] = 'myisam_key_cache';
$links['binlog_cache']['doc'] = 'binary_log';
$links['Slow_queries']['doc'] = 'slow_query_log';
$links['innodb'][__('Variables')]
= 'server_engines.php?engine=InnoDB&' . PMA_generate_common_url();
$links['innodb'][__('InnoDB Status')]
= 'server_engines.php?engine=InnoDB&page=Status&' .
PMA_generate_common_url();
$links['innodb']['doc'] = 'innodb';
// sort status vars into arrays
foreach ($server_status as $name => $value) {
if (isset($allocations[$name])) {
$sections[$allocations[$name]]['vars'][$name] = $value;
unset($server_status[$name]);
} else {
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);
// rest
$sections['all']['vars'] =& $server_status;
$hour_factor = 3600 / $server_status['Uptime'];
/**
* start output
*/
?>
';
if ($server_master_status && $server_slave_status) {
echo __('This MySQL server works as master and slave in replication process.');
} elseif ($server_master_status) {
echo __('This MySQL server works as master in replication process.');
} elseif ($server_slave_status) {
echo __('This MySQL server works as slave in replication process.');
}
echo __('For further information about replication status on the server, please visit the replication section.');
echo '';
}
?>
Server traffic: These tables show the network traffic statistics of this MySQL server since its startup.'); ?>
|
ø |
% |
|
|
--- |
--- |
|
|
|
0
? PMA_formatNumber(
$server_status['Aborted_connects'] * 100 / $server_status['Connections'],
0, 2) . '%'
: '--- '; ?> |
|
|
|
0
? PMA_formatNumber(
$server_status['Aborted_clients'] * 100 / $server_status['Connections'],
0, 2) . '%'
: '--- '; ?> |
|
|
|
% |
Query statistics: Since its startup, %s queries have been sent to the server.'),
PMA_formatNumber($server_status['Questions'], 0)); ?>
$value) {
$current_table++;
if ($count_displayed_rows === 0 || $count_displayed_rows === $max_rows_per_table) {
$odd_row = true;
if ($count_displayed_rows === $max_rows_per_table) {
echo ' ' . "\n";
echo ' ' . "\n";
$count_displayed_rows = 0;
}
?>
$value) {
$key = str_replace(array('Com_', '_'), array('', ' '), $key);
$chart_data[ucwords($key)] = (int)$value;
}
echo PMA_chart_pie(__('Query type'), $chart_data);
?>
$section) {
if (! empty($section['vars'])) {
?>
|
|
|
$value) {
$odd_row = !$odd_row;
?>
|
$alerts[$name]) {
echo '';
} else {
echo '';
}
}
if ('%' === substr($name, -1, 1)) {
echo PMA_formatNumber($value, 0, 2) . ' %';
} elseif (is_numeric($value) && $value == (int) $value) {
echo PMA_formatNumber($value, 3, 1);
} elseif (is_numeric($value)) {
echo PMA_formatNumber($value, 3, 1);
} else {
echo htmlspecialchars($value);
}
if (isset($alerts[$name])) {
echo '';
}
?> |
$link_url) {
if ('doc' == $link_name) {
echo PMA_showMySQLDocu($link_url, $link_url);
} else {
echo ' ' . $link_name . '' .
"\n";
}
}
unset($link_url, $link_name);
}
?>
|