2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * displays status variables with descriptions and some hints an optmizing
5 * + reset status variables
12 * no need for variables importing
15 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
16 define('PMA_NO_VARIABLES_IMPORT', true);
18 require_once './libraries/common.inc.php';
21 * Does the common work
23 require './libraries/server_common.inc.php';
29 require './libraries/server_links.inc.php';
34 require './libraries/replication.inc.php';
35 require_once './libraries/replication_gui.lib.php';
38 * Messages are built using the message name
40 $strShowStatusBinlog_cache_disk_useDescr = __('The number of transactions that used the temporary binary log cache but that exceeded the value of binlog_cache_size and used a temporary file to store statements from the transaction.');
41 $strShowStatusBinlog_cache_useDescr = __('The number of transactions that used the temporary binary log cache.');
42 $strShowStatusCreated_tmp_disk_tablesDescr = __('The number of temporary tables on disk created automatically by the server while executing statements. If Created_tmp_disk_tables is big, you may want to increase the tmp_table_size value to cause temporary tables to be memory-based instead of disk-based.');
43 $strShowStatusCreated_tmp_filesDescr = __('How many temporary files mysqld has created.');
44 $strShowStatusCreated_tmp_tablesDescr = __('The number of in-memory temporary tables created automatically by the server while executing statements.');
45 $strShowStatusDelayed_errorsDescr = __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).');
46 $strShowStatusDelayed_insert_threadsDescr = __('The number of INSERT DELAYED handler threads in use. Every different table on which one uses INSERT DELAYED gets its own thread.');
47 $strShowStatusDelayed_writesDescr = __('The number of INSERT DELAYED rows written.');
48 $strShowStatusFlush_commandsDescr = __('The number of executed FLUSH statements.');
49 $strShowStatusHandler_commitDescr = __('The number of internal COMMIT statements.');
50 $strShowStatusHandler_deleteDescr = __('The number of times a row was deleted from a table.');
51 $strShowStatusHandler_discoverDescr = __('The MySQL server can ask the NDB Cluster storage engine if it knows about a table with a given name. This is called discovery. Handler_discover indicates the number of time tables have been discovered.');
52 $strShowStatusHandler_read_firstDescr = __('The number of times the first entry was read from an index. If this is high, it suggests that the server is doing a lot of full index scans; for example, SELECT col1 FROM foo, assuming that col1 is indexed.');
53 $strShowStatusHandler_read_keyDescr = __('The number of requests to read a row based on a key. If this is high, it is a good indication that your queries and tables are properly indexed.');
54 $strShowStatusHandler_read_nextDescr = __('The number of requests to read the next row in key order. This is incremented if you are querying an index column with a range constraint or if you are doing an index scan.');
55 $strShowStatusHandler_read_prevDescr = __('The number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.');
56 $strShowStatusHandler_read_rndDescr = __('The number of requests to read a row based on a fixed position. This is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan whole tables or you have joins that don\'t use keys properly.');
57 $strShowStatusHandler_read_rnd_nextDescr = __('The number of requests to read the next row in the data file. This is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.');
58 $strShowStatusHandler_rollbackDescr = __('The number of internal ROLLBACK statements.');
59 $strShowStatusHandler_updateDescr = __('The number of requests to update a row in a table.');
60 $strShowStatusHandler_writeDescr = __('The number of requests to insert a row in a table.');
61 $strShowStatusInnodb_buffer_pool_pages_dataDescr = __('The number of pages containing data (dirty or clean).');
62 $strShowStatusInnodb_buffer_pool_pages_dirtyDescr = __('The number of pages currently dirty.');
63 $strShowStatusInnodb_buffer_pool_pages_flushedDescr = __('The number of buffer pool pages that have been requested to be flushed.');
64 $strShowStatusInnodb_buffer_pool_pages_freeDescr = __('The number of free pages.');
65 $strShowStatusInnodb_buffer_pool_pages_latchedDescr = __('The number of latched pages in InnoDB buffer pool. These are pages currently being read or written or that can\'t be flushed or removed for some other reason.');
66 $strShowStatusInnodb_buffer_pool_pages_miscDescr = __('The number of pages busy because they have been allocated for administrative overhead such as row locks or the adaptive hash index. This value can also be calculated as Innodb_buffer_pool_pages_total - Innodb_buffer_pool_pages_free - Innodb_buffer_pool_pages_data.');
67 $strShowStatusInnodb_buffer_pool_pages_totalDescr = __('Total size of buffer pool, in pages.');
68 $strShowStatusInnodb_buffer_pool_read_ahead_rndDescr = __('The number of "random" read-aheads InnoDB initiated. This happens when a query is to scan a large portion of a table but in random order.');
69 $strShowStatusInnodb_buffer_pool_read_ahead_seqDescr = __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.');
70 $strShowStatusInnodb_buffer_pool_read_requestsDescr = __('The number of logical read requests InnoDB has done.');
71 $strShowStatusInnodb_buffer_pool_readsDescr = __('The number of logical reads that InnoDB could not satisfy from buffer pool and had to do a single-page read.');
72 $strShowStatusInnodb_buffer_pool_wait_freeDescr = __('Normally, writes to the InnoDB buffer pool happen in the background. However, if it\'s necessary to read or create a page and no clean pages are available, it\'s necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size was set properly, this value should be small.');
73 $strShowStatusInnodb_buffer_pool_write_requestsDescr = __('The number writes done to the InnoDB buffer pool.');
74 $strShowStatusInnodb_data_fsyncsDescr = __('The number of fsync() operations so far.');
75 $strShowStatusInnodb_data_pending_fsyncsDescr = __('The current number of pending fsync() operations.');
76 $strShowStatusInnodb_data_pending_readsDescr = __('The current number of pending reads.');
77 $strShowStatusInnodb_data_pending_writesDescr = __('The current number of pending writes.');
78 $strShowStatusInnodb_data_readDescr = __('The amount of data read so far, in bytes.');
79 $strShowStatusInnodb_data_readsDescr = __('The total number of data reads.');
80 $strShowStatusInnodb_data_writesDescr = __('The total number of data writes.');
81 $strShowStatusInnodb_data_writtenDescr = __('The amount of data written so far, in bytes.');
82 $strShowStatusInnodb_dblwr_pages_writtenDescr = __('The number of pages that have been written for doublewrite operations.');
83 $strShowStatusInnodb_dblwr_writesDescr = __('The number of doublewrite operations that have been performed.');
84 $strShowStatusInnodb_log_waitsDescr = __('The number of waits we had because log buffer was too small and we had to wait for it to be flushed before continuing.');
85 $strShowStatusInnodb_log_write_requestsDescr = __('The number of log write requests.');
86 $strShowStatusInnodb_log_writesDescr = __('The number of physical writes to the log file.');
87 $strShowStatusInnodb_os_log_fsyncsDescr = __('The number of fsync() writes done to the log file.');
88 $strShowStatusInnodb_os_log_pending_fsyncsDescr = __('The number of pending log file fsyncs.');
89 $strShowStatusInnodb_os_log_pending_writesDescr = __('Pending log file writes.');
90 $strShowStatusInnodb_os_log_writtenDescr = __('The number of bytes written to the log file.');
91 $strShowStatusInnodb_pages_createdDescr = __('The number of pages created.');
92 $strShowStatusInnodb_page_sizeDescr = __('The compiled-in InnoDB page size (default 16KB). Many values are counted in pages; the page size allows them to be easily converted to bytes.');
93 $strShowStatusInnodb_pages_readDescr = __('The number of pages read.');
94 $strShowStatusInnodb_pages_writtenDescr = __('The number of pages written.');
95 $strShowStatusInnodb_row_lock_current_waitsDescr = __('The number of row locks currently being waited for.');
96 $strShowStatusInnodb_row_lock_time_avgDescr = __('The average time to acquire a row lock, in milliseconds.');
97 $strShowStatusInnodb_row_lock_timeDescr = __('The total time spent in acquiring row locks, in milliseconds.');
98 $strShowStatusInnodb_row_lock_time_maxDescr = __('The maximum time to acquire a row lock, in milliseconds.');
99 $strShowStatusInnodb_row_lock_waitsDescr = __('The number of times a row lock had to be waited for.');
100 $strShowStatusInnodb_rows_deletedDescr = __('The number of rows deleted from InnoDB tables.');
101 $strShowStatusInnodb_rows_insertedDescr = __('The number of rows inserted in InnoDB tables.');
102 $strShowStatusInnodb_rows_readDescr = __('The number of rows read from InnoDB tables.');
103 $strShowStatusInnodb_rows_updatedDescr = __('The number of rows updated in InnoDB tables.');
104 $strShowStatusKey_blocks_not_flushedDescr = __('The number of key blocks in the key cache that have changed but haven\'t yet been flushed to disk. It used to be known as Not_flushed_key_blocks.');
105 $strShowStatusKey_blocks_unusedDescr = __('The number of unused blocks in the key cache. You can use this value to determine how much of the key cache is in use.');
106 $strShowStatusKey_blocks_usedDescr = __('The number of used blocks in the key cache. This value is a high-water mark that indicates the maximum number of blocks that have ever been in use at one time.');
107 $strShowStatusKey_read_requestsDescr = __('The number of requests to read a key block from the cache.');
108 $strShowStatusKey_readsDescr = __('The number of physical reads of a key block from disk. If Key_reads is big, then your key_buffer_size value is probably too small. The cache miss rate can be calculated as Key_reads/Key_read_requests.');
109 $strShowStatusKey_write_requestsDescr = __('The number of requests to write a key block to the cache.');
110 $strShowStatusKey_writesDescr = __('The number of physical writes of a key block to disk.');
111 $strShowStatusLast_query_costDescr = __('The total cost of the last compiled query as computed by the query optimizer. Useful for comparing the cost of different query plans for the same query. The default value of 0 means that no query has been compiled yet.');
112 $strShowStatusNot_flushed_delayed_rowsDescr = __('The number of rows waiting to be written in INSERT DELAYED queues.');
113 $strShowStatusOpened_tablesDescr = __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.');
114 $strShowStatusOpen_filesDescr = __('The number of files that are open.');
115 $strShowStatusOpen_streamsDescr = __('The number of streams that are open (used mainly for logging).');
116 $strShowStatusOpen_tablesDescr = __('The number of tables that are open.');
117 $strShowStatusQcache_free_blocksDescr = __('The number of free memory blocks in query cache.');
118 $strShowStatusQcache_free_memoryDescr = __('The amount of free memory for query cache.');
119 $strShowStatusQcache_hitsDescr = __('The number of cache hits.');
120 $strShowStatusQcache_insertsDescr = __('The number of queries added to the cache.');
121 $strShowStatusQcache_lowmem_prunesDescr = __('The number of queries that have been removed from the cache to free up memory for caching new queries. This information can help you tune the query cache size. The query cache uses a least recently used (LRU) strategy to decide which queries to remove from the cache.');
122 $strShowStatusQcache_not_cachedDescr = __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).');
123 $strShowStatusQcache_queries_in_cacheDescr = __('The number of queries registered in the cache.');
124 $strShowStatusQcache_total_blocksDescr = __('The total number of blocks in the query cache.');
125 $strShowStatusReset = _pgettext('$strShowStatusReset', 'Reset');
126 $strShowStatusRpl_statusDescr = __('The status of failsafe replication (not yet implemented).');
127 $strShowStatusSelect_full_joinDescr = __('The number of joins that do not use indexes. If this value is not 0, you should carefully check the indexes of your tables.');
128 $strShowStatusSelect_full_range_joinDescr = __('The number of joins that used a range search on a reference table.');
129 $strShowStatusSelect_range_checkDescr = __('The number of joins without keys that check for key usage after each row. (If this is not 0, you should carefully check the indexes of your tables.)');
130 $strShowStatusSelect_rangeDescr = __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)');
131 $strShowStatusSelect_scanDescr = __('The number of joins that did a full scan of the first table.');
132 $strShowStatusSlave_open_temp_tablesDescr = __('The number of temporary tables currently open by the slave SQL thread.');
133 $strShowStatusSlave_retried_transactionsDescr = __('Total (since startup) number of times the replication slave SQL thread has retried transactions.');
134 $strShowStatusSlave_runningDescr = __('This is ON if this server is a slave that is connected to a master.');
135 $strShowStatusSlow_launch_threadsDescr = __('The number of threads that have taken more than slow_launch_time seconds to create.');
136 $strShowStatusSlow_queriesDescr = __('The number of queries that have taken more than long_query_time seconds.');
137 $strShowStatusSort_merge_passesDescr = __('The number of merge passes the sort algorithm has had to do. If this value is large, you should consider increasing the value of the sort_buffer_size system variable.');
138 $strShowStatusSort_rangeDescr = __('The number of sorts that were done with ranges.');
139 $strShowStatusSort_rowsDescr = __('The number of sorted rows.');
140 $strShowStatusSort_scanDescr = __('The number of sorts that were done by scanning the table.');
141 $strShowStatusTable_locks_immediateDescr = __('The number of times that a table lock was acquired immediately.');
142 $strShowStatusTable_locks_waitedDescr = __('The number of times that a table lock could not be acquired immediately and a wait was needed. If this is high, and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.');
143 $strShowStatusThreads_cachedDescr = __('The number of threads in the thread cache. The cache hit rate can be calculated as Threads_created/Connections. If this value is red you should raise your thread_cache_size.');
144 $strShowStatusThreads_connectedDescr = __('The number of currently open connections.');
145 $strShowStatusThreads_createdDescr = __('The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. (Normally this doesn\'t give a notable performance improvement if you have a good thread implementation.)');
146 $strShowStatusThreads_runningDescr = __('The number of threads that are not sleeping.');
149 * Displays the sub-page heading
151 echo '<div id="serverstatus">' . "\n";
153 . ($GLOBALS['cfg']['MainPageIconic']
154 ?
'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] .
155 's_status.png" width="16" height="16" alt="" />'
157 . __('Runtime Information') . "\n"
162 * flush status variables if requested
164 if (isset($_REQUEST['flush'])) {
165 $_flush_commands = array(
171 if (in_array($_REQUEST['flush'], $_flush_commands)) {
172 PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
174 unset($_flush_commands);
179 * get status from server
181 $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
184 * for some calculations we require also some server settings
186 $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
189 * starttime calculation
191 $start_time = PMA_DBI_fetch_value(
192 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
196 * cleanup some deprecated values
199 'Com_prepare_sql' => 'Com_stmt_prepare',
200 'Com_execute_sql' => 'Com_stmt_execute',
201 'Com_dealloc_sql' => 'Com_stmt_close',
204 foreach ($deprecated as $old => $new) {
205 if (isset($server_status[$old])
206 && isset($server_status[$new])) {
207 unset($server_status[$old]);
214 * calculate some values
216 // Key_buffer_fraction
217 if (isset($server_status['Key_blocks_unused'])
218 && isset($server_variables['key_cache_block_size'])
219 && isset($server_variables['key_buffer_size'])) {
220 $server_status['Key_buffer_fraction_%'] =
222 - $server_status['Key_blocks_unused']
223 * $server_variables['key_cache_block_size']
224 / $server_variables['key_buffer_size']
227 isset($server_status['Key_blocks_used'])
228 && isset($server_variables['key_buffer_size'])) {
229 $server_status['Key_buffer_fraction_%'] =
230 $server_status['Key_blocks_used']
232 / $server_variables['key_buffer_size'];
235 // Ratio for key read/write
236 if (isset($server_status['Key_writes'])
237 && isset($server_status['Key_write_requests'])
238 && $server_status['Key_write_requests'] > 0)
239 $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
241 if (isset($server_status['Key_reads'])
242 && isset($server_status['Key_read_requests'])
243 && $server_status['Key_read_requests'] > 0)
244 $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
246 // Threads_cache_hitrate
247 if (isset($server_status['Threads_created'])
248 && isset($server_status['Connections'])
249 && $server_status['Connections'] > 0) {
250 $server_status['Threads_cache_hitrate_%'] =
252 - $server_status['Threads_created']
253 / $server_status['Connections']
257 // Format Uptime_since_flush_status : show as days, hours, minutes, seconds
258 if (isset($server_status['Uptime_since_flush_status'])) {
259 $server_status['Uptime_since_flush_status'] = PMA_timespanFormat($server_status['Uptime_since_flush_status']);
265 // name => max value before alert
268 // variable => max value
269 'Aborted_clients' => 0,
270 'Aborted_connects' => 0,
272 'Binlog_cache_disk_use' => 0,
274 'Created_tmp_disk_tables' => 0,
276 'Handler_read_rnd' => 0,
277 'Handler_read_rnd_next' => 0,
279 'Innodb_buffer_pool_pages_dirty' => 0,
280 'Innodb_buffer_pool_reads' => 0,
281 'Innodb_buffer_pool_wait_free' => 0,
282 'Innodb_log_waits' => 0,
283 'Innodb_row_lock_time_avg' => 10, // ms
284 'Innodb_row_lock_time_max' => 50, // ms
285 'Innodb_row_lock_waits' => 0,
288 'Delayed_errors' => 0,
289 'Select_full_join' => 0,
290 'Select_range_check' => 0,
291 'Sort_merge_passes' => 0,
292 'Opened_tables' => 0,
293 'Table_locks_waited' => 0,
294 'Qcache_lowmem_prunes' => 0,
295 'Slow_launch_threads' => 0,
297 // depends on Key_read_requests
298 // normaly lower then 1:0.01
299 'Key_reads' => (0.01 * $server_status['Key_read_requests']),
300 // depends on Key_write_requests
301 // normaly nearly 1:1
302 'Key_writes' => (0.9 * $server_status['Key_write_requests']),
304 'Key_buffer_fraction' => 0.5,
306 // alert if more than 95% of thread cache is in use
307 'Threads_cached' => 0.95 * $server_variables['thread_cache_size']
310 // variable => min value
311 //'Handler read key' => '> ',
316 * split variables in sections
318 $allocations = array(
319 // variable name => section
322 'Innodb_' => 'innodb',
324 'Handler_' => 'handler',
325 'Qcache_' => 'qcache',
326 'Threads_' => 'threads',
327 'Slow_launch_threads' => 'threads',
329 'Binlog_cache_' => 'binlog_cache',
330 'Created_tmp_' => 'created_tmp',
333 'Delayed_' => 'delayed',
334 'Not_flushed_delayed_rows' => 'delayed',
336 'Flush_commands' => 'query',
337 'Last_query_cost' => 'query',
338 'Slow_queries' => 'query',
340 'Select_' => 'select',
343 'Open_tables' => 'table',
344 'Opened_tables' => 'table',
345 'Table_locks_' => 'table',
347 'Rpl_status' => 'repl',
356 // section => section name (description)
357 'com' => array('title' => ''),
358 'query' => array('title' => __('SQL query')),
359 'innodb' => array('title' => 'InnoDB'),
360 'ndb' => array('title' => 'NDB'),
361 'handler' => array('title' => __('Handler')),
362 'qcache' => array('title' => __('Query cache')),
363 'threads' => array('title' => __('Threads')),
364 'binlog_cache' => array('title' => __('Binary log')),
365 'created_tmp' => array('title' => __('Temporary data')),
366 'delayed' => array('title' => __('Delayed inserts')),
367 'key' => array('title' => __('Key cache')),
368 'select' => array('title' => __('Joins')),
369 'repl' => array('title' => __('Replication')),
370 'sort' => array('title' => __('Sorting')),
371 'table' => array('title' => __('Tables')),
372 'tc' => array('title' => __('Transaction coordinator')),
373 'ssl' => array('title' => 'SSL'),
377 * define some needfull links/commands
379 // variable or section name => (name => url)
382 $links['table'][__('Flush (close) all tables')]
383 = $PMA_PHP_SELF . '?flush=TABLES&' . PMA_generate_common_url();
384 $links['table'][__('Show open tables')]
385 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
386 '&goto=server_status.php&' . PMA_generate_common_url();
388 if ($server_master_status) {
389 $links['repl'][__('Show slave hosts')]
390 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
391 '&goto=server_status.php&' . PMA_generate_common_url();
392 $links['repl'][__('Show master status')] = '#replication_master';
394 if ($server_slave_status) {
395 $links['repl'][__('Show slave status')] = '#replication_slave';
398 $links['repl']['doc'] = 'replication';
400 $links['qcache'][__('Flush query cache')]
401 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&' .
402 PMA_generate_common_url();
403 $links['qcache']['doc'] = 'query_cache';
405 $links['threads'][__('Show processes')]
406 = 'server_processlist.php?' . PMA_generate_common_url();
407 $links['threads']['doc'] = 'mysql_threads';
409 $links['key']['doc'] = 'myisam_key_cache';
411 $links['binlog_cache']['doc'] = 'binary_log';
413 $links['Slow_queries']['doc'] = 'slow_query_log';
415 $links['innodb'][__('Variables')]
416 = 'server_engines.php?engine=InnoDB&' . PMA_generate_common_url();
417 $links['innodb'][__('InnoDB Status')]
418 = 'server_engines.php?engine=InnoDB&page=Status&' .
419 PMA_generate_common_url();
420 $links['innodb']['doc'] = 'innodb';
423 // sort status vars into arrays
424 foreach ($server_status as $name => $value) {
425 if (isset($allocations[$name])) {
426 $sections[$allocations[$name]]['vars'][$name] = $value;
427 unset($server_status[$name]);
429 foreach ($allocations as $filter => $section) {
430 if (preg_match('/^' . $filter . '/', $name)
431 && isset($server_status[$name])) {
432 unset($server_status[$name]);
433 $sections[$section]['vars'][$name] = $value;
438 unset($name, $value, $filter, $section, $allocations);
441 $sections['all']['vars'] =& $server_status;
443 $hour_factor = 3600 / $server_status['Uptime'];
449 <div id
="statuslinks">
451 $PMA_PHP_SELF . '?' . PMA_generate_common_url(); ?>"
452 ><?php
echo __('Refresh'); ?
></a
>
454 $PMA_PHP_SELF . '?flush=STATUS&' . PMA_generate_common_url(); ?>"
455 ><?php
echo _pgettext('for Show status', 'Reset'); ?
></a
>
456 <?php
echo PMA_showMySQLDocu('server_status_variables','server_status_variables'); ?
>
461 echo sprintf(__('This MySQL server has been running for %s. It started up on %s.'),
462 PMA_timespanFormat($server_status['Uptime']),
463 PMA_localisedDate($start_time)) . "\n";
468 if ($server_master_status ||
$server_slave_status) {
470 if ($server_master_status && $server_slave_status) {
471 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
472 } elseif ($server_master_status) {
473 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
474 } elseif ($server_slave_status) {
475 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
477 echo __('For further information about replication status on the server, please visit the <a href=#replication>replication section</a>.');
482 <div id
="sectionlinks">
484 foreach ($sections as $section_name => $section) {
485 if (! empty($section['vars']) && ! empty($section['title'])) {
486 echo '<a href="' . $PMA_PHP_SELF . '?' .
487 PMA_generate_common_url() . '#' . $section_name . '">' .
488 $section['title'] . '</a>' . "\n";
494 <h3
><?php
echo __('<b>Server traffic</b>: These tables show the network traffic statistics of this MySQL server since its startup.'); ?
></h3
>
496 <table id
="serverstatustraffic" class="data">
499 <th colspan
="2"><?php
echo __('Traffic') . ' ' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?
></th
>
500 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
505 <th
class="name"><?php
echo __('Received'); ?
></th
>
506 <td
class="value"><?php
echo
508 PMA_formatByteDown($server_status['Bytes_received'], 2, 1)); ?
></td
>
509 <td
class="value"><?php
echo
512 $server_status['Bytes_received'] * $hour_factor, 2, 1)); ?
></td
>
515 <th
class="name"><?php
echo __('Sent'); ?
></th
>
516 <td
class="value"><?php
echo
518 PMA_formatByteDown($server_status['Bytes_sent'], 2, 1)); ?
></td
>
519 <td
class="value"><?php
echo
522 $server_status['Bytes_sent'] * $hour_factor, 2, 1)); ?
></td
>
525 <th
class="name"><?php
echo __('Total'); ?
></th
>
526 <td
class="value"><?php
echo
529 $server_status['Bytes_received'] +
$server_status['Bytes_sent'], 2, 1)
531 <td
class="value"><?php
echo
534 ($server_status['Bytes_received'] +
$server_status['Bytes_sent'])
535 * $hour_factor, 2, 1)
541 <table id
="serverstatusconnections" class="data">
544 <th colspan
="2"><?php
echo __('Connections'); ?
></th
>
545 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
551 <th
class="name"><?php
echo __('max. concurrent connections'); ?
></th
>
552 <td
class="value"><?php
echo
553 PMA_formatNumber($server_status['Max_used_connections'], 0); ?
> </td
>
554 <td
class="value">--- </td
>
555 <td
class="value">--- </td
>
558 <th
class="name"><?php
echo __('Failed attempts'); ?
></th
>
559 <td
class="value"><?php
echo
560 PMA_formatNumber($server_status['Aborted_connects'], 4, 0); ?
></td
>
561 <td
class="value"><?php
echo
562 PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
564 <td
class="value"><?php
echo
565 $server_status['Connections'] > 0
567 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
572 <th
class="name"><?php
echo __('Aborted'); ?
></th
>
573 <td
class="value"><?php
echo
574 PMA_formatNumber($server_status['Aborted_clients'], 4, 0); ?
></td
>
575 <td
class="value"><?php
echo
576 PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
578 <td
class="value"><?php
echo
579 $server_status['Connections'] > 0
581 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
586 <th
class="name"><?php
echo __('Total'); ?
></th
>
587 <td
class="value"><?php
echo
588 PMA_formatNumber($server_status['Connections'], 4, 0); ?
></td
>
589 <td
class="value"><?php
echo
590 PMA_formatNumber($server_status['Connections'] * $hour_factor,
592 <td
class="value"><?php
echo
593 PMA_formatNumber(100, 0, 2); ?
>%
</td
>
598 <hr
class="clearfloat" />
601 sprintf(__('<b>Query statistics</b>: Since its startup, %s queries have been sent to the server.'),
602 PMA_formatNumber($server_status['Questions'], 0)); ?
></h3
>
604 <table id
="serverstatusqueriessummary" class="data">
607 <th
><?php
echo __('Total'); ?
></th
>
608 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
609 <th
>ø
; <?php
echo __('per minute'); ?
></th
>
610 <th
>ø
; <?php
echo __('per second'); ?
></th
>
615 <td
class="value"><?php
echo
616 PMA_formatNumber($server_status['Questions'], 4, 0); ?
></td
>
617 <td
class="value"><?php
echo
618 PMA_formatNumber($server_status['Questions'] * $hour_factor,
620 <td
class="value"><?php
echo
622 $server_status['Questions'] * 60 / $server_status['Uptime'],
624 <td
class="value"><?php
echo
626 $server_status['Questions'] / $server_status['Uptime'],
632 <div id
="serverstatusqueriesdetails">
635 $used_queries = $sections['com']['vars'];
636 // reverse sort by value to show most used statements first
637 arsort($used_queries);
638 // remove all zero values from the end
639 while (end($used_queries) == 0) {
640 array_pop($used_queries);
643 // number of tables to split values into
645 $max_rows_per_table = (int) ceil(count($used_queries) / $tables);
648 $count_displayed_rows = 0;
649 $perc_factor = 100 / ($server_status['Questions'] - $server_status['Connections']);
651 foreach ($used_queries as $name => $value) {
653 if ($count_displayed_rows === 0 ||
$count_displayed_rows === $max_rows_per_table) {
655 if ($count_displayed_rows === $max_rows_per_table) {
656 echo ' </tbody>' . "\n";
657 echo ' </table>' . "\n";
658 $count_displayed_rows = 0;
661 <table id
="serverstatusqueriesdetails<?php echo $current_table; ?>" class="data">
662 <col
class="namecol" />
663 <col
class="valuecol" span
="3" />
665 <tr
><th colspan
="2"><?php
echo __('Query type'); ?
></th
>
666 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
673 $odd_row = !$odd_row;
675 $count_displayed_rows++
;
677 // For the percentage column, use Questions - Connections, because
678 // the number of connections is not an item of the Query types
679 // but is included in Questions. Then the total of the percentages is 100.
680 $name = str_replace('Com_', '', $name);
681 $name = str_replace('_', ' ', $name);
683 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
684 <th
class="name"><?php
echo htmlspecialchars($name); ?
></th
>
685 <td
class="value"><?php
echo PMA_formatNumber($value, 4, 0); ?
></td
>
686 <td
class="value"><?php
echo
687 PMA_formatNumber($value * $hour_factor, 3, 3); ?
></td
>
688 <td
class="value"><?php
echo
689 PMA_formatNumber($value * $perc_factor, 0, 2); ?
>%
</td
>
698 <div id
="serverstatussection">
700 //Unset used variables
702 $tables, $max_rows_per_table, $current_table, $count_displayed_rows, $perc_factor,
703 $hour_factor, $sections['com'],
704 $server_status['Aborted_clients'], $server_status['Aborted_connects'],
705 $server_status['Max_used_connections'], $server_status['Bytes_received'],
706 $server_status['Bytes_sent'], $server_status['Connections'],
707 $server_status['Questions'], $server_status['Uptime'],
711 foreach ($sections as $section_name => $section) {
712 if (! empty($section['vars'])) {
714 <table
class="data" id
="serverstatussection<?php echo $section_name; ?>">
715 <caption
class="tblHeaders">
717 href
="<?php echo $PMA_PHP_SELF . '?' .
718 PMA_generate_common_url() . '#serverstatus'; ?>"
719 name
="<?php echo $section_name; ?>"><?php
echo __('Begin'); ?
>
721 ($GLOBALS['cfg']['MainPageIconic']
722 ?
'<img src="' . $GLOBALS['pmaThemeImage'] .
723 's_asc.png" width="11" height="9" align="middle" alt="" />'
727 if (! empty($section['title'])) {
728 echo $section['title'];
732 <col
class="namecol" />
733 <col
class="valuecol" />
734 <col
class="descrcol" />
737 <th
><?php
echo __('Variable'); ?
></th
>
738 <th
><?php
echo __('Value'); ?
></th
>
739 <th
><?php
echo __('Description'); ?
></th
>
743 if (! empty($links[$section_name])) {
746 <tr
class="tblFooters">
747 <th colspan
="3" class="tblFooters">
749 foreach ($links[$section_name] as $link_name => $link_url) {
750 if ('doc' == $link_name) {
751 echo PMA_showMySQLDocu($link_url, $link_url);
753 echo '<a href="' . $link_url . '">' . $link_name . '</a>' . "\n";
756 unset($link_url, $link_name);
767 foreach ($section['vars'] as $name => $value) {
768 $odd_row = !$odd_row;
770 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
771 <th
class="name"><?php
echo htmlspecialchars($name); ?
></th
>
772 <td
class="value"><?php
773 if (isset($alerts[$name])) {
774 if ($value > $alerts[$name]) {
775 echo '<span class="attention">';
777 echo '<span class="allfine">';
780 if ('%' === substr($name, -1, 1)) {
781 echo PMA_formatNumber($value, 0, 2) . ' %';
782 } elseif (is_numeric($value) && $value == (int) $value) {
783 echo PMA_formatNumber($value, 3, 1);
784 } elseif (is_numeric($value)) {
785 echo PMA_formatNumber($value, 3, 1);
787 echo htmlspecialchars($value);
789 if (isset($alerts[$name])) {
795 if (isset($GLOBALS['strShowStatus' . $name . 'Descr'])) {
796 echo $GLOBALS['strShowStatus' . $name . 'Descr'];
799 if (isset($links[$name])) {
800 foreach ($links[$name] as $link_name => $link_url) {
801 if ('doc' == $link_name) {
802 echo PMA_showMySQLDocu($link_url, $link_url);
804 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
808 unset($link_url, $link_name);
815 unset($name, $value);
822 unset($section_name, $section, $sections, $server_status, $odd_row, $alerts);
826 /* if the server works as master or slave in replication process, display useful information */
827 if ($server_master_status ||
$server_slave_status)
830 <hr
class="clearfloat" />
832 <h3
><a name
="replication"></a
><?php
echo __('Replication status'); ?
></h3
>
835 foreach ($replication_types as $type)
837 if ($
{"server_{$type}_status"}) {
838 PMA_replication_print_status_table($type);
851 require_once './libraries/footer.inc.php';