Merge remote branch 'origin/master'
[phpmyadmin-themes.git] / server_status.php
blob520bb51f3dfa3a4fc02dc6cdc066ca2759d7d930
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
7 * @package phpMyAdmin
8 */
10 /**
11 * no need for variables importing
12 * @ignore
14 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
15 define('PMA_NO_VARIABLES_IMPORT', true);
17 require_once './libraries/common.inc.php';
19 $GLOBALS['js_include'][] = 'pMap.js';
21 /**
22 * Does the common work
24 require './libraries/server_common.inc.php';
27 /**
28 * Displays the links
30 require './libraries/server_links.inc.php';
32 /**
33 * Replication library
35 require './libraries/replication.inc.php';
36 require_once './libraries/replication_gui.lib.php';
38 /**
39 * Chart generation
41 require_once './libraries/chart.lib.php';
43 /**
44 * Messages are built using the message name
46 $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.');
47 $strShowStatusBinlog_cache_useDescr = __('The number of transactions that used the temporary binary log cache.');
48 $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.');
49 $strShowStatusCreated_tmp_filesDescr = __('How many temporary files mysqld has created.');
50 $strShowStatusCreated_tmp_tablesDescr = __('The number of in-memory temporary tables created automatically by the server while executing statements.');
51 $strShowStatusDelayed_errorsDescr = __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).');
52 $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.');
53 $strShowStatusDelayed_writesDescr = __('The number of INSERT DELAYED rows written.');
54 $strShowStatusFlush_commandsDescr = __('The number of executed FLUSH statements.');
55 $strShowStatusHandler_commitDescr = __('The number of internal COMMIT statements.');
56 $strShowStatusHandler_deleteDescr = __('The number of times a row was deleted from a table.');
57 $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.');
58 $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.');
59 $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.');
60 $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.');
61 $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.');
62 $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.');
63 $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.');
64 $strShowStatusHandler_rollbackDescr = __('The number of internal ROLLBACK statements.');
65 $strShowStatusHandler_updateDescr = __('The number of requests to update a row in a table.');
66 $strShowStatusHandler_writeDescr = __('The number of requests to insert a row in a table.');
67 $strShowStatusInnodb_buffer_pool_pages_dataDescr = __('The number of pages containing data (dirty or clean).');
68 $strShowStatusInnodb_buffer_pool_pages_dirtyDescr = __('The number of pages currently dirty.');
69 $strShowStatusInnodb_buffer_pool_pages_flushedDescr = __('The number of buffer pool pages that have been requested to be flushed.');
70 $strShowStatusInnodb_buffer_pool_pages_freeDescr = __('The number of free pages.');
71 $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.');
72 $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.');
73 $strShowStatusInnodb_buffer_pool_pages_totalDescr = __('Total size of buffer pool, in pages.');
74 $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.');
75 $strShowStatusInnodb_buffer_pool_read_ahead_seqDescr = __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.');
76 $strShowStatusInnodb_buffer_pool_read_requestsDescr = __('The number of logical read requests InnoDB has done.');
77 $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.');
78 $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.');
79 $strShowStatusInnodb_buffer_pool_write_requestsDescr = __('The number writes done to the InnoDB buffer pool.');
80 $strShowStatusInnodb_data_fsyncsDescr = __('The number of fsync() operations so far.');
81 $strShowStatusInnodb_data_pending_fsyncsDescr = __('The current number of pending fsync() operations.');
82 $strShowStatusInnodb_data_pending_readsDescr = __('The current number of pending reads.');
83 $strShowStatusInnodb_data_pending_writesDescr = __('The current number of pending writes.');
84 $strShowStatusInnodb_data_readDescr = __('The amount of data read so far, in bytes.');
85 $strShowStatusInnodb_data_readsDescr = __('The total number of data reads.');
86 $strShowStatusInnodb_data_writesDescr = __('The total number of data writes.');
87 $strShowStatusInnodb_data_writtenDescr = __('The amount of data written so far, in bytes.');
88 $strShowStatusInnodb_dblwr_pages_writtenDescr = __('The number of pages that have been written for doublewrite operations.');
89 $strShowStatusInnodb_dblwr_writesDescr = __('The number of doublewrite operations that have been performed.');
90 $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.');
91 $strShowStatusInnodb_log_write_requestsDescr = __('The number of log write requests.');
92 $strShowStatusInnodb_log_writesDescr = __('The number of physical writes to the log file.');
93 $strShowStatusInnodb_os_log_fsyncsDescr = __('The number of fsync() writes done to the log file.');
94 $strShowStatusInnodb_os_log_pending_fsyncsDescr = __('The number of pending log file fsyncs.');
95 $strShowStatusInnodb_os_log_pending_writesDescr = __('Pending log file writes.');
96 $strShowStatusInnodb_os_log_writtenDescr = __('The number of bytes written to the log file.');
97 $strShowStatusInnodb_pages_createdDescr = __('The number of pages created.');
98 $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.');
99 $strShowStatusInnodb_pages_readDescr = __('The number of pages read.');
100 $strShowStatusInnodb_pages_writtenDescr = __('The number of pages written.');
101 $strShowStatusInnodb_row_lock_current_waitsDescr = __('The number of row locks currently being waited for.');
102 $strShowStatusInnodb_row_lock_time_avgDescr = __('The average time to acquire a row lock, in milliseconds.');
103 $strShowStatusInnodb_row_lock_timeDescr = __('The total time spent in acquiring row locks, in milliseconds.');
104 $strShowStatusInnodb_row_lock_time_maxDescr = __('The maximum time to acquire a row lock, in milliseconds.');
105 $strShowStatusInnodb_row_lock_waitsDescr = __('The number of times a row lock had to be waited for.');
106 $strShowStatusInnodb_rows_deletedDescr = __('The number of rows deleted from InnoDB tables.');
107 $strShowStatusInnodb_rows_insertedDescr = __('The number of rows inserted in InnoDB tables.');
108 $strShowStatusInnodb_rows_readDescr = __('The number of rows read from InnoDB tables.');
109 $strShowStatusInnodb_rows_updatedDescr = __('The number of rows updated in InnoDB tables.');
110 $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.');
111 $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.');
112 $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.');
113 $strShowStatusKey_read_requestsDescr = __('The number of requests to read a key block from the cache.');
114 $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.');
115 $strShowStatusKey_write_requestsDescr = __('The number of requests to write a key block to the cache.');
116 $strShowStatusKey_writesDescr = __('The number of physical writes of a key block to disk.');
117 $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.');
118 $strShowStatusNot_flushed_delayed_rowsDescr = __('The number of rows waiting to be written in INSERT DELAYED queues.');
119 $strShowStatusOpened_tablesDescr = __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.');
120 $strShowStatusOpen_filesDescr = __('The number of files that are open.');
121 $strShowStatusOpen_streamsDescr = __('The number of streams that are open (used mainly for logging).');
122 $strShowStatusOpen_tablesDescr = __('The number of tables that are open.');
123 $strShowStatusQcache_free_blocksDescr = __('The number of free memory blocks in query cache.');
124 $strShowStatusQcache_free_memoryDescr = __('The amount of free memory for query cache.');
125 $strShowStatusQcache_hitsDescr = __('The number of cache hits.');
126 $strShowStatusQcache_insertsDescr = __('The number of queries added to the cache.');
127 $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.');
128 $strShowStatusQcache_not_cachedDescr = __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).');
129 $strShowStatusQcache_queries_in_cacheDescr = __('The number of queries registered in the cache.');
130 $strShowStatusQcache_total_blocksDescr = __('The total number of blocks in the query cache.');
131 $strShowStatusReset = _pgettext('$strShowStatusReset', 'Reset');
132 $strShowStatusRpl_statusDescr = __('The status of failsafe replication (not yet implemented).');
133 $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.');
134 $strShowStatusSelect_full_range_joinDescr = __('The number of joins that used a range search on a reference table.');
135 $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.)');
136 $strShowStatusSelect_rangeDescr = __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)');
137 $strShowStatusSelect_scanDescr = __('The number of joins that did a full scan of the first table.');
138 $strShowStatusSlave_open_temp_tablesDescr = __('The number of temporary tables currently open by the slave SQL thread.');
139 $strShowStatusSlave_retried_transactionsDescr = __('Total (since startup) number of times the replication slave SQL thread has retried transactions.');
140 $strShowStatusSlave_runningDescr = __('This is ON if this server is a slave that is connected to a master.');
141 $strShowStatusSlow_launch_threadsDescr = __('The number of threads that have taken more than slow_launch_time seconds to create.');
142 $strShowStatusSlow_queriesDescr = __('The number of queries that have taken more than long_query_time seconds.');
143 $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.');
144 $strShowStatusSort_rangeDescr = __('The number of sorts that were done with ranges.');
145 $strShowStatusSort_rowsDescr = __('The number of sorted rows.');
146 $strShowStatusSort_scanDescr = __('The number of sorts that were done by scanning the table.');
147 $strShowStatusTable_locks_immediateDescr = __('The number of times that a table lock was acquired immediately.');
148 $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.');
149 $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.');
150 $strShowStatusThreads_connectedDescr = __('The number of currently open connections.');
151 $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.)');
152 $strShowStatusThreads_runningDescr = __('The number of threads that are not sleeping.');
155 * Displays the sub-page heading
157 echo '<div id="serverstatus">' . "\n";
158 echo '<h2>' . "\n"
159 . ($GLOBALS['cfg']['MainPageIconic']
160 ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] .
161 's_status.png" width="16" height="16" alt="" />'
162 : '')
163 . __('Runtime Information') . "\n"
164 . '</h2>' . "\n";
168 * flush status variables if requested
170 if (isset($_REQUEST['flush'])) {
171 $_flush_commands = array(
172 'STATUS',
173 'TABLES',
174 'QUERY CACHE',
177 if (in_array($_REQUEST['flush'], $_flush_commands)) {
178 PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
180 unset($_flush_commands);
185 * get status from server
187 $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
190 * for some calculations we require also some server settings
192 $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
195 * starttime calculation
197 $start_time = PMA_DBI_fetch_value(
198 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
202 * cleanup some deprecated values
204 $deprecated = array(
205 'Com_prepare_sql' => 'Com_stmt_prepare',
206 'Com_execute_sql' => 'Com_stmt_execute',
207 'Com_dealloc_sql' => 'Com_stmt_close',
210 foreach ($deprecated as $old => $new) {
211 if (isset($server_status[$old])
212 && isset($server_status[$new])) {
213 unset($server_status[$old]);
216 unset($deprecated);
220 * calculate some values
222 // Key_buffer_fraction
223 if (isset($server_status['Key_blocks_unused'])
224 && isset($server_variables['key_cache_block_size'])
225 && isset($server_variables['key_buffer_size'])) {
226 $server_status['Key_buffer_fraction_%'] =
228 - $server_status['Key_blocks_unused']
229 * $server_variables['key_cache_block_size']
230 / $server_variables['key_buffer_size']
231 * 100;
232 } elseif (
233 isset($server_status['Key_blocks_used'])
234 && isset($server_variables['key_buffer_size'])) {
235 $server_status['Key_buffer_fraction_%'] =
236 $server_status['Key_blocks_used']
237 * 1024
238 / $server_variables['key_buffer_size'];
241 // Ratio for key read/write
242 if (isset($server_status['Key_writes'])
243 && isset($server_status['Key_write_requests'])
244 && $server_status['Key_write_requests'] > 0)
245 $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
247 if (isset($server_status['Key_reads'])
248 && isset($server_status['Key_read_requests'])
249 && $server_status['Key_read_requests'] > 0)
250 $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
252 // Threads_cache_hitrate
253 if (isset($server_status['Threads_created'])
254 && isset($server_status['Connections'])
255 && $server_status['Connections'] > 0) {
256 $server_status['Threads_cache_hitrate_%'] =
258 - $server_status['Threads_created']
259 / $server_status['Connections']
260 * 100;
263 // Format Uptime_since_flush_status : show as days, hours, minutes, seconds
264 if (isset($server_status['Uptime_since_flush_status'])) {
265 $server_status['Uptime_since_flush_status'] = PMA_timespanFormat($server_status['Uptime_since_flush_status']);
269 * define some alerts
271 // name => max value before alert
272 $alerts = array(
273 // lower is better
274 // variable => max value
275 'Aborted_clients' => 0,
276 'Aborted_connects' => 0,
278 'Binlog_cache_disk_use' => 0,
280 'Created_tmp_disk_tables' => 0,
282 'Handler_read_rnd' => 0,
283 'Handler_read_rnd_next' => 0,
285 'Innodb_buffer_pool_pages_dirty' => 0,
286 'Innodb_buffer_pool_reads' => 0,
287 'Innodb_buffer_pool_wait_free' => 0,
288 'Innodb_log_waits' => 0,
289 'Innodb_row_lock_time_avg' => 10, // ms
290 'Innodb_row_lock_time_max' => 50, // ms
291 'Innodb_row_lock_waits' => 0,
293 'Slow_queries' => 0,
294 'Delayed_errors' => 0,
295 'Select_full_join' => 0,
296 'Select_range_check' => 0,
297 'Sort_merge_passes' => 0,
298 'Opened_tables' => 0,
299 'Table_locks_waited' => 0,
300 'Qcache_lowmem_prunes' => 0,
301 'Slow_launch_threads' => 0,
303 // depends on Key_read_requests
304 // normaly lower then 1:0.01
305 'Key_reads' => (0.01 * $server_status['Key_read_requests']),
306 // depends on Key_write_requests
307 // normaly nearly 1:1
308 'Key_writes' => (0.9 * $server_status['Key_write_requests']),
310 'Key_buffer_fraction' => 0.5,
312 // alert if more than 95% of thread cache is in use
313 'Threads_cached' => 0.95 * $server_variables['thread_cache_size']
315 // higher is better
316 // variable => min value
317 //'Handler read key' => '> ',
322 * split variables in sections
324 $allocations = array(
325 // variable name => section
327 'Com_' => 'com',
328 'Innodb_' => 'innodb',
329 'Ndb_' => 'ndb',
330 'Handler_' => 'handler',
331 'Qcache_' => 'qcache',
332 'Threads_' => 'threads',
333 'Slow_launch_threads' => 'threads',
335 'Binlog_cache_' => 'binlog_cache',
336 'Created_tmp_' => 'created_tmp',
337 'Key_' => 'key',
339 'Delayed_' => 'delayed',
340 'Not_flushed_delayed_rows' => 'delayed',
342 'Flush_commands' => 'query',
343 'Last_query_cost' => 'query',
344 'Slow_queries' => 'query',
346 'Select_' => 'select',
347 'Sort_' => 'sort',
349 'Open_tables' => 'table',
350 'Opened_tables' => 'table',
351 'Table_locks_' => 'table',
353 'Rpl_status' => 'repl',
354 'Slave_' => 'repl',
356 'Tc_' => 'tc',
358 'Ssl_' => 'ssl',
361 $sections = array(
362 // section => section name (description)
363 'com' => array('title' => ''),
364 'query' => array('title' => __('SQL query')),
365 'innodb' => array('title' => 'InnoDB'),
366 'ndb' => array('title' => 'NDB'),
367 'handler' => array('title' => __('Handler')),
368 'qcache' => array('title' => __('Query cache')),
369 'threads' => array('title' => __('Threads')),
370 'binlog_cache' => array('title' => __('Binary log')),
371 'created_tmp' => array('title' => __('Temporary data')),
372 'delayed' => array('title' => __('Delayed inserts')),
373 'key' => array('title' => __('Key cache')),
374 'select' => array('title' => __('Joins')),
375 'repl' => array('title' => __('Replication')),
376 'sort' => array('title' => __('Sorting')),
377 'table' => array('title' => __('Tables')),
378 'tc' => array('title' => __('Transaction coordinator')),
379 'ssl' => array('title' => 'SSL'),
383 * define some needfull links/commands
385 // variable or section name => (name => url)
386 $links = array();
388 $links['table'][__('Flush (close) all tables')]
389 = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
390 $links['table'][__('Show open tables')]
391 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
392 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
394 if ($server_master_status) {
395 $links['repl'][__('Show slave hosts')]
396 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
397 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
398 $links['repl'][__('Show master status')] = '#replication_master';
400 if ($server_slave_status) {
401 $links['repl'][__('Show slave status')] = '#replication_slave';
404 $links['repl']['doc'] = 'replication';
406 $links['qcache'][__('Flush query cache')]
407 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
408 PMA_generate_common_url();
409 $links['qcache']['doc'] = 'query_cache';
411 $links['threads'][__('Show processes')]
412 = 'server_processlist.php?' . PMA_generate_common_url();
413 $links['threads']['doc'] = 'mysql_threads';
415 $links['key']['doc'] = 'myisam_key_cache';
417 $links['binlog_cache']['doc'] = 'binary_log';
419 $links['Slow_queries']['doc'] = 'slow_query_log';
421 $links['innodb'][__('Variables')]
422 = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
423 $links['innodb'][__('InnoDB Status')]
424 = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
425 PMA_generate_common_url();
426 $links['innodb']['doc'] = 'innodb';
429 // sort status vars into arrays
430 foreach ($server_status as $name => $value) {
431 if (isset($allocations[$name])) {
432 $sections[$allocations[$name]]['vars'][$name] = $value;
433 unset($server_status[$name]);
434 } else {
435 foreach ($allocations as $filter => $section) {
436 if (preg_match('/^' . $filter . '/', $name)
437 && isset($server_status[$name])) {
438 unset($server_status[$name]);
439 $sections[$section]['vars'][$name] = $value;
444 unset($name, $value, $filter, $section, $allocations);
446 // rest
447 $sections['all']['vars'] =& $server_status;
449 $hour_factor = 3600 / $server_status['Uptime'];
452 * start output
455 <div id="statuslinks">
456 <a href="<?php echo
457 $PMA_PHP_SELF . '?' . PMA_generate_common_url(); ?>"
458 ><?php echo __('Refresh'); ?></a>
459 <a href="<?php echo
460 $PMA_PHP_SELF . '?flush=STATUS&amp;' . PMA_generate_common_url(); ?>"
461 ><?php echo _pgettext('for Show status', 'Reset'); ?></a>
462 <?php echo PMA_showMySQLDocu('server_status_variables','server_status_variables'); ?>
463 </div>
466 <?php
467 echo sprintf(__('This MySQL server has been running for %s. It started up on %s.'),
468 PMA_timespanFormat($server_status['Uptime']),
469 PMA_localisedDate($start_time)) . "\n";
471 </p>
473 <?php
474 if ($server_master_status || $server_slave_status) {
475 echo '<p>';
476 if ($server_master_status && $server_slave_status) {
477 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
478 } elseif ($server_master_status) {
479 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
480 } elseif ($server_slave_status) {
481 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
483 echo __('For further information about replication status on the server, please visit the <a href=#replication>replication section</a>.');
484 echo '</p>';
488 <div id="sectionlinks">
489 <?php
490 foreach ($sections as $section_name => $section) {
491 if (! empty($section['vars']) && ! empty($section['title'])) {
492 echo '<a href="' . $PMA_PHP_SELF . '?' .
493 PMA_generate_common_url() . '#' . $section_name . '">' .
494 $section['title'] . '</a>' . "\n";
498 </div>
500 <h3><?php echo __('<b>Server traffic</b>: These tables show the network traffic statistics of this MySQL server since its startup.'); ?></h3>
502 <table id="serverstatustraffic" class="data">
503 <thead>
504 <tr>
505 <th colspan="2"><?php echo __('Traffic') . '&nbsp;' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?></th>
506 <th>&oslash; <?php echo __('per hour'); ?></th>
507 </tr>
508 </thead>
509 <tbody>
510 <tr class="odd">
511 <th class="name"><?php echo __('Received'); ?></th>
512 <td class="value"><?php echo
513 implode(' ',
514 PMA_formatByteDown($server_status['Bytes_received'], 2, 1)); ?></td>
515 <td class="value"><?php echo
516 implode(' ',
517 PMA_formatByteDown(
518 $server_status['Bytes_received'] * $hour_factor, 2, 1)); ?></td>
519 </tr>
520 <tr class="even">
521 <th class="name"><?php echo __('Sent'); ?></th>
522 <td class="value"><?php echo
523 implode(' ',
524 PMA_formatByteDown($server_status['Bytes_sent'], 2, 1)); ?></td>
525 <td class="value"><?php echo
526 implode(' ',
527 PMA_formatByteDown(
528 $server_status['Bytes_sent'] * $hour_factor, 2, 1)); ?></td>
529 </tr>
530 <tr class="odd">
531 <th class="name"><?php echo __('Total'); ?></th>
532 <td class="value"><?php echo
533 implode(' ',
534 PMA_formatByteDown(
535 $server_status['Bytes_received'] + $server_status['Bytes_sent'], 2, 1)
536 ); ?></td>
537 <td class="value"><?php echo
538 implode(' ',
539 PMA_formatByteDown(
540 ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
541 * $hour_factor, 2, 1)
542 ); ?></td>
543 </tr>
544 </tbody>
545 </table>
547 <table id="serverstatusconnections" class="data">
548 <thead>
549 <tr>
550 <th colspan="2"><?php echo __('Connections'); ?></th>
551 <th>&oslash; <?php echo __('per hour'); ?></th>
552 <th>%</th>
553 </tr>
554 </thead>
555 <tbody>
556 <tr class="odd">
557 <th class="name"><?php echo __('max. concurrent connections'); ?></th>
558 <td class="value"><?php echo
559 PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
560 <td class="value">--- </td>
561 <td class="value">--- </td>
562 </tr>
563 <tr class="even">
564 <th class="name"><?php echo __('Failed attempts'); ?></th>
565 <td class="value"><?php echo
566 PMA_formatNumber($server_status['Aborted_connects'], 4, 0); ?></td>
567 <td class="value"><?php echo
568 PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
569 4, 2); ?></td>
570 <td class="value"><?php echo
571 $server_status['Connections'] > 0
572 ? PMA_formatNumber(
573 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
574 0, 2) . '%'
575 : '--- '; ?></td>
576 </tr>
577 <tr class="odd">
578 <th class="name"><?php echo __('Aborted'); ?></th>
579 <td class="value"><?php echo
580 PMA_formatNumber($server_status['Aborted_clients'], 4, 0); ?></td>
581 <td class="value"><?php echo
582 PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
583 4, 2); ?></td>
584 <td class="value"><?php echo
585 $server_status['Connections'] > 0
586 ? PMA_formatNumber(
587 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
588 0, 2) . '%'
589 : '--- '; ?></td>
590 </tr>
591 <tr class="even">
592 <th class="name"><?php echo __('Total'); ?></th>
593 <td class="value"><?php echo
594 PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
595 <td class="value"><?php echo
596 PMA_formatNumber($server_status['Connections'] * $hour_factor,
597 4, 2); ?></td>
598 <td class="value"><?php echo
599 PMA_formatNumber(100, 0, 2); ?>%</td>
600 </tr>
601 </tbody>
602 </table>
604 <hr class="clearfloat" />
606 <h3><?php echo
607 sprintf(__('<b>Query statistics</b>: Since its startup, %s queries have been sent to the server.'),
608 PMA_formatNumber($server_status['Questions'], 0)); ?></h3>
610 <table id="serverstatusqueriessummary" class="data">
611 <thead>
612 <tr>
613 <th><?php echo __('Total'); ?></th>
614 <th>&oslash; <?php echo __('per hour'); ?></th>
615 <th>&oslash; <?php echo __('per minute'); ?></th>
616 <th>&oslash; <?php echo __('per second'); ?></th>
617 </tr>
618 </thead>
619 <tbody>
620 <tr class="odd">
621 <td class="value"><?php echo
622 PMA_formatNumber($server_status['Questions'], 4, 0); ?></td>
623 <td class="value"><?php echo
624 PMA_formatNumber($server_status['Questions'] * $hour_factor,
625 3, 2); ?></td>
626 <td class="value"><?php echo
627 PMA_formatNumber(
628 $server_status['Questions'] * 60 / $server_status['Uptime'],
629 3, 2); ?></td>
630 <td class="value"><?php echo
631 PMA_formatNumber(
632 $server_status['Questions'] / $server_status['Uptime'],
633 3, 2); ?></td>
634 </tr>
635 </tbody>
636 </table>
638 <div id="serverstatusqueriesdetails">
639 <?php
641 $used_queries = $sections['com']['vars'];
642 // reverse sort by value to show most used statements first
643 arsort($used_queries);
644 // remove all zero values from the end
645 while (end($used_queries) == 0) {
646 array_pop($used_queries);
649 // number of tables to split values into
650 $tables = 3;
651 $max_rows_per_table = (int) ceil(count($used_queries) / $tables);
652 $current_table = 0;
653 $odd_row = true;
654 $count_displayed_rows = 0;
655 $perc_factor = 100 / ($server_status['Questions'] - $server_status['Connections']);
657 foreach ($used_queries as $name => $value) {
658 $current_table++;
659 if ($count_displayed_rows === 0 || $count_displayed_rows === $max_rows_per_table) {
660 $odd_row = true;
661 if ($count_displayed_rows === $max_rows_per_table) {
662 echo ' </tbody>' . "\n";
663 echo ' </table>' . "\n";
664 $count_displayed_rows = 0;
667 <table id="serverstatusqueriesdetails<?php echo $current_table; ?>" class="data">
668 <col class="namecol" />
669 <col class="valuecol" span="3" />
670 <thead>
671 <tr><th colspan="2"><?php echo __('Query type'); ?></th>
672 <th>&oslash; <?php echo __('per hour'); ?></th>
673 <th>%</th>
674 </tr>
675 </thead>
676 <tbody>
677 <?php
678 } else {
679 $odd_row = !$odd_row;
681 $count_displayed_rows++;
683 // For the percentage column, use Questions - Connections, because
684 // the number of connections is not an item of the Query types
685 // but is included in Questions. Then the total of the percentages is 100.
686 $name = str_replace('Com_', '', $name);
687 $name = str_replace('_', ' ', $name);
689 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
690 <th class="name"><?php echo htmlspecialchars($name); ?></th>
691 <td class="value"><?php echo PMA_formatNumber($value, 4, 0); ?></td>
692 <td class="value"><?php echo
693 PMA_formatNumber($value * $hour_factor, 3, 3); ?></td>
694 <td class="value"><?php echo
695 PMA_formatNumber($value * $perc_factor, 0, 2); ?>%</td>
696 </tr>
697 <?php
700 </tbody>
701 </table>
702 <div class="clearfloat"></div>
703 </div>
705 <div>
706 <?php
707 echo PMA_chart_status($used_queries);
709 </div>
711 <div id="serverstatussection">
712 <?php
713 //Unset used variables
714 unset(
715 $tables, $max_rows_per_table, $current_table, $count_displayed_rows, $perc_factor,
716 $hour_factor, $sections['com'],
717 $server_status['Aborted_clients'], $server_status['Aborted_connects'],
718 $server_status['Max_used_connections'], $server_status['Bytes_received'],
719 $server_status['Bytes_sent'], $server_status['Connections'],
720 $server_status['Questions'], $server_status['Uptime'],
721 $used_queries
724 foreach ($sections as $section_name => $section) {
725 if (! empty($section['vars'])) {
727 <table class="data" id="serverstatussection<?php echo $section_name; ?>">
728 <caption class="tblHeaders">
729 <a class="top"
730 href="<?php echo $PMA_PHP_SELF . '?' .
731 PMA_generate_common_url() . '#serverstatus'; ?>"
732 name="<?php echo $section_name; ?>"><?php echo __('Begin'); ?>
733 <?php echo
734 ($GLOBALS['cfg']['MainPageIconic']
735 ? '<img src="' . $GLOBALS['pmaThemeImage'] .
736 's_asc.png" width="11" height="9" align="middle" alt="" />'
737 : ''); ?>
738 </a>
739 <?php
740 if (! empty($section['title'])) {
741 echo $section['title'];
744 </caption>
745 <col class="namecol" />
746 <col class="valuecol" />
747 <col class="descrcol" />
748 <thead>
749 <tr>
750 <th><?php echo __('Variable'); ?></th>
751 <th><?php echo __('Value'); ?></th>
752 <th><?php echo __('Description'); ?></th>
753 </tr>
754 </thead>
755 <?php
756 if (! empty($links[$section_name])) {
758 <tfoot>
759 <tr class="tblFooters">
760 <th colspan="3" class="tblFooters">
761 <?php
762 foreach ($links[$section_name] as $link_name => $link_url) {
763 if ('doc' == $link_name) {
764 echo PMA_showMySQLDocu($link_url, $link_url);
765 } else {
766 echo '<a href="' . $link_url . '">' . $link_name . '</a>' . "\n";
769 unset($link_url, $link_name);
771 </th>
772 </tr>
773 </tfoot>
774 <?php
777 <tbody>
778 <?php
779 $odd_row = false;
780 foreach ($section['vars'] as $name => $value) {
781 $odd_row = !$odd_row;
783 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
784 <th class="name"><?php echo htmlspecialchars($name); ?></th>
785 <td class="value"><?php
786 if (isset($alerts[$name])) {
787 if ($value > $alerts[$name]) {
788 echo '<span class="attention">';
789 } else {
790 echo '<span class="allfine">';
793 if ('%' === substr($name, -1, 1)) {
794 echo PMA_formatNumber($value, 0, 2) . ' %';
795 } elseif (is_numeric($value) && $value == (int) $value) {
796 echo PMA_formatNumber($value, 3, 1);
797 } elseif (is_numeric($value)) {
798 echo PMA_formatNumber($value, 3, 1);
799 } else {
800 echo htmlspecialchars($value);
802 if (isset($alerts[$name])) {
803 echo '</span>';
805 ?></td>
806 <td class="descr">
807 <?php
808 if (isset($GLOBALS['strShowStatus' . $name . 'Descr'])) {
809 echo $GLOBALS['strShowStatus' . $name . 'Descr'];
812 if (isset($links[$name])) {
813 foreach ($links[$name] as $link_name => $link_url) {
814 if ('doc' == $link_name) {
815 echo PMA_showMySQLDocu($link_url, $link_url);
816 } else {
817 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
818 "\n";
821 unset($link_url, $link_name);
824 </td>
825 </tr>
826 <?php
828 unset($name, $value);
830 </tbody>
831 </table>
832 <?php
835 unset($section_name, $section, $sections, $server_status, $odd_row, $alerts);
837 </div>
838 <?php
839 /* if the server works as master or slave in replication process, display useful information */
840 if ($server_master_status || $server_slave_status)
843 <hr class="clearfloat" />
845 <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
846 <?php
848 foreach ($replication_types as $type)
850 if (${"server_{$type}_status"}) {
851 PMA_replication_print_status_table($type);
854 unset($types);
858 </div>
860 <?php
862 * Sends the footer
864 require './libraries/footer.inc.php';