bug #3383572 [interface] Cannot execute saved query
[phpmyadmin/madhuracj.git] / server_status.php
blobc4254a37d71447b2fe58f3fc513564681f70a2a3
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',
345 'Queries' => 'query',
346 'Prepared_stmt_count' => 'query',
348 'Select_' => 'select',
349 'Sort_' => 'sort',
351 'Open_tables' => 'table',
352 'Opened_tables' => 'table',
353 'Open_table_definitions' => 'table',
354 'Opened_table_definitions' => 'table',
355 'Table_locks_' => 'table',
357 'Rpl_status' => 'repl',
358 'Slave_' => 'repl',
360 'Tc_' => 'tc',
362 'Ssl_' => 'ssl',
364 'Open_files' => 'files',
365 'Open_streams' => 'files',
366 'Opened_files' => 'files',
369 $sections = array(
370 // section => section name (description)
371 'com' => array('title' => ''),
372 'query' => array('title' => __('SQL query')),
373 'innodb' => array('title' => 'InnoDB'),
374 'ndb' => array('title' => 'NDB'),
375 'handler' => array('title' => __('Handler')),
376 'qcache' => array('title' => __('Query cache')),
377 'threads' => array('title' => __('Threads')),
378 'binlog_cache' => array('title' => __('Binary log')),
379 'created_tmp' => array('title' => __('Temporary data')),
380 'delayed' => array('title' => __('Delayed inserts')),
381 'key' => array('title' => __('Key cache')),
382 'select' => array('title' => __('Joins')),
383 'repl' => array('title' => __('Replication')),
384 'sort' => array('title' => __('Sorting')),
385 'table' => array('title' => __('Tables')),
386 'tc' => array('title' => __('Transaction coordinator')),
387 'files' => array('title' => __('Files')),
388 'ssl' => array('title' => 'SSL'),
392 * define some needfull links/commands
394 // variable or section name => (name => url)
395 $links = array();
397 $links['table'][__('Flush (close) all tables')]
398 = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
399 $links['table'][__('Show open tables')]
400 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
401 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
403 if ($server_master_status) {
404 $links['repl'][__('Show slave hosts')]
405 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
406 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
407 $links['repl'][__('Show master status')] = '#replication_master';
409 if ($server_slave_status) {
410 $links['repl'][__('Show slave status')] = '#replication_slave';
413 $links['repl']['doc'] = 'replication';
415 $links['qcache'][__('Flush query cache')]
416 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
417 PMA_generate_common_url();
418 $links['qcache']['doc'] = 'query_cache';
420 $links['threads'][__('Show processes')]
421 = 'server_processlist.php?' . PMA_generate_common_url();
422 $links['threads']['doc'] = 'mysql_threads';
424 $links['key']['doc'] = 'myisam_key_cache';
426 $links['binlog_cache']['doc'] = 'binary_log';
428 $links['Slow_queries']['doc'] = 'slow_query_log';
430 $links['innodb'][__('Variables')]
431 = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
432 $links['innodb'][__('InnoDB Status')]
433 = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
434 PMA_generate_common_url();
435 $links['innodb']['doc'] = 'innodb';
438 // sort status vars into arrays
439 foreach ($server_status as $name => $value) {
440 if (isset($allocations[$name])) {
441 $sections[$allocations[$name]]['vars'][$name] = $value;
442 unset($server_status[$name]);
443 } else {
444 foreach ($allocations as $filter => $section) {
445 if (preg_match('/^' . $filter . '/', $name)
446 && isset($server_status[$name])) {
447 unset($server_status[$name]);
448 $sections[$section]['vars'][$name] = $value;
453 unset($name, $value, $filter, $section, $allocations);
455 // rest
456 $sections['all']['vars'] =& $server_status;
458 $hour_factor = 3600 / $server_status['Uptime'];
461 * start output
464 <div id="statuslinks">
465 <a href="<?php echo
466 $PMA_PHP_SELF . '?' . PMA_generate_common_url(); ?>"
467 ><?php echo __('Refresh'); ?></a>
468 <a href="<?php echo
469 $PMA_PHP_SELF . '?flush=STATUS&amp;' . PMA_generate_common_url(); ?>"
470 ><?php echo _pgettext('for Show status', 'Reset'); ?></a>
471 <?php echo PMA_showMySQLDocu('server_status_variables','server_status_variables'); ?>
472 </div>
475 <?php
476 echo sprintf(__('This MySQL server has been running for %s. It started up on %s.'),
477 PMA_timespanFormat($server_status['Uptime']),
478 PMA_localisedDate($start_time)) . "\n";
480 </p>
482 <?php
483 if ($server_master_status || $server_slave_status) {
484 echo '<p>';
485 if ($server_master_status && $server_slave_status) {
486 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
487 } elseif ($server_master_status) {
488 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
489 } elseif ($server_slave_status) {
490 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
492 echo ' ';
493 echo __('For further information about replication status on the server, please visit the <a href=#replication>replication section</a>.');
494 echo '</p>';
498 <div id="sectionlinks">
499 <?php
500 foreach ($sections as $section_name => $section) {
501 if (! empty($section['vars']) && ! empty($section['title'])) {
502 echo '<a href="' . $PMA_PHP_SELF . '?' .
503 PMA_generate_common_url() . '#' . $section_name . '">' .
504 $section['title'] . '</a>' . "\n";
508 </div>
510 <h3><?php echo __('<b>Server traffic</b>: These tables show the network traffic statistics of this MySQL server since its startup.'); ?></h3>
512 <table id="serverstatustraffic" class="data">
513 <thead>
514 <tr>
515 <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>
516 <th>&oslash; <?php echo __('per hour'); ?></th>
517 </tr>
518 </thead>
519 <tbody>
520 <tr class="noclick odd">
521 <th class="name"><?php echo __('Received'); ?></th>
522 <td class="value"><?php echo
523 implode(' ',
524 PMA_formatByteDown($server_status['Bytes_received'], 2, 1)); ?></td>
525 <td class="value"><?php echo
526 implode(' ',
527 PMA_formatByteDown(
528 $server_status['Bytes_received'] * $hour_factor, 2, 1)); ?></td>
529 </tr>
530 <tr class="noclick even">
531 <th class="name"><?php echo __('Sent'); ?></th>
532 <td class="value"><?php echo
533 implode(' ',
534 PMA_formatByteDown($server_status['Bytes_sent'], 2, 1)); ?></td>
535 <td class="value"><?php echo
536 implode(' ',
537 PMA_formatByteDown(
538 $server_status['Bytes_sent'] * $hour_factor, 2, 1)); ?></td>
539 </tr>
540 <tr class="noclick odd">
541 <th class="name"><?php echo __('Total'); ?></th>
542 <td class="value"><?php echo
543 implode(' ',
544 PMA_formatByteDown(
545 $server_status['Bytes_received'] + $server_status['Bytes_sent'], 2, 1)
546 ); ?></td>
547 <td class="value"><?php echo
548 implode(' ',
549 PMA_formatByteDown(
550 ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
551 * $hour_factor, 2, 1)
552 ); ?></td>
553 </tr>
554 </tbody>
555 </table>
557 <table id="serverstatusconnections" class="data">
558 <thead>
559 <tr>
560 <th colspan="2"><?php echo __('Connections'); ?></th>
561 <th>&oslash; <?php echo __('per hour'); ?></th>
562 <th>%</th>
563 </tr>
564 </thead>
565 <tbody>
566 <tr class="noclick odd">
567 <th class="name"><?php echo __('max. concurrent connections'); ?></th>
568 <td class="value"><?php echo
569 PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
570 <td class="value">--- </td>
571 <td class="value">--- </td>
572 </tr>
573 <tr class="noclick even">
574 <th class="name"><?php echo __('Failed attempts'); ?></th>
575 <td class="value"><?php echo
576 PMA_formatNumber($server_status['Aborted_connects'], 4, 0); ?></td>
577 <td class="value"><?php echo
578 PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
579 4, 2); ?></td>
580 <td class="value"><?php echo
581 $server_status['Connections'] > 0
582 ? PMA_formatNumber(
583 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
584 0, 2) . '%'
585 : '--- '; ?></td>
586 </tr>
587 <tr class="noclick odd">
588 <th class="name"><?php echo __('Aborted'); ?></th>
589 <td class="value"><?php echo
590 PMA_formatNumber($server_status['Aborted_clients'], 4, 0); ?></td>
591 <td class="value"><?php echo
592 PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
593 4, 2); ?></td>
594 <td class="value"><?php echo
595 $server_status['Connections'] > 0
596 ? PMA_formatNumber(
597 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
598 0, 2) . '%'
599 : '--- '; ?></td>
600 </tr>
601 <tr class="noclick even">
602 <th class="name"><?php echo __('Total'); ?></th>
603 <td class="value"><?php echo
604 PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
605 <td class="value"><?php echo
606 PMA_formatNumber($server_status['Connections'] * $hour_factor,
607 4, 2); ?></td>
608 <td class="value"><?php echo
609 PMA_formatNumber(100, 0, 2); ?>%</td>
610 </tr>
611 </tbody>
612 </table>
614 <hr class="clearfloat" />
616 <h3 id="serverstatusqueries"><?php echo
617 sprintf(__('<b>Query statistics</b>: Since its startup, %s queries have been sent to the server.'),
618 PMA_formatNumber($server_status['Questions'], 0));
619 echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
620 ?></h3>
622 <table id="serverstatusqueriessummary" class="data">
623 <thead>
624 <tr>
625 <th><?php echo __('Total'); ?></th>
626 <th>&oslash; <?php echo __('per hour'); ?></th>
627 <th>&oslash; <?php echo __('per minute'); ?></th>
628 <th>&oslash; <?php echo __('per second'); ?></th>
629 </tr>
630 </thead>
631 <tbody>
632 <tr class="noclick odd">
633 <td class="value"><?php echo
634 PMA_formatNumber($server_status['Questions'], 4, 0); ?></td>
635 <td class="value"><?php echo
636 PMA_formatNumber($server_status['Questions'] * $hour_factor,
637 3, 2); ?></td>
638 <td class="value"><?php echo
639 PMA_formatNumber(
640 $server_status['Questions'] * 60 / $server_status['Uptime'],
641 3, 2); ?></td>
642 <td class="value"><?php echo
643 PMA_formatNumber(
644 $server_status['Questions'] / $server_status['Uptime'],
645 3, 2); ?></td>
646 </tr>
647 </tbody>
648 </table>
650 <div id="serverstatusqueriesdetails">
651 <?php
653 $used_queries = $sections['com']['vars'];
654 // reverse sort by value to show most used statements first
655 arsort($used_queries);
656 // remove all zero values from the end
657 // variable empty for Drizzle
658 if ($used_queries) {
659 while (end($used_queries) == 0) {
660 array_pop($used_queries);
664 // number of tables to split values into
665 $tables = 3;
666 $max_rows_per_table = (int) ceil(count($used_queries) / $tables);
667 $current_table = 0;
668 $odd_row = true;
669 $count_displayed_rows = 0;
670 $perc_factor = 100 / ($server_status['Questions'] - $server_status['Connections']);
672 foreach ($used_queries as $name => $value) {
673 $current_table++;
674 if ($count_displayed_rows === 0 || $count_displayed_rows === $max_rows_per_table) {
675 $odd_row = true;
676 if ($count_displayed_rows === $max_rows_per_table) {
677 echo ' </tbody>' . "\n";
678 echo ' </table>' . "\n";
679 $count_displayed_rows = 0;
682 <table id="serverstatusqueriesdetails<?php echo $current_table; ?>" class="data">
683 <col class="namecol" />
684 <col class="valuecol" span="3" />
685 <thead>
686 <tr><th colspan="2"><?php echo __('Query type'); ?></th>
687 <th>&oslash; <?php echo __('per hour'); ?></th>
688 <th>%</th>
689 </tr>
690 </thead>
691 <tbody>
692 <?php
693 } else {
694 $odd_row = !$odd_row;
696 $count_displayed_rows++;
698 // For the percentage column, use Questions - Connections, because
699 // the number of connections is not an item of the Query types
700 // but is included in Questions. Then the total of the percentages is 100.
701 $name = str_replace('Com_', '', $name);
702 $name = str_replace('_', ' ', $name);
704 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
705 <th class="name"><?php echo htmlspecialchars($name); ?></th>
706 <td class="value"><?php echo PMA_formatNumber($value, 4, 0); ?></td>
707 <td class="value"><?php echo
708 PMA_formatNumber($value * $hour_factor, 3, 3); ?></td>
709 <td class="value"><?php echo
710 PMA_formatNumber($value * $perc_factor, 0, 2); ?>%</td>
711 </tr>
712 <?php
715 </tbody>
716 </table>
717 <div class="clearfloat"></div>
718 </div>
720 <?php if ($used_queries): ?>
721 <div id="serverstatusquerieschart">
722 <?php
723 if (empty($_REQUEST["query_chart"])) {
724 echo '<a href="' . $PMA_PHP_SELF . '?' . $url_query
725 . '&amp;query_chart=1#serverstatusqueries"'
726 . 'title="' . __('Show query chart') . '">['
727 . __('Show query chart') . ']</a>';
728 PMA_Message::notice( __('Note: Generating the query chart can take a long time.'))->display();
729 } else {
730 echo PMA_chart_status($used_queries);
733 </div>
734 <?php endif; ?>
736 <div id="serverstatussection">
737 <?php
738 //Unset used variables
739 unset(
740 $tables, $max_rows_per_table, $current_table, $count_displayed_rows, $perc_factor,
741 $hour_factor, $sections['com'],
742 $server_status['Aborted_clients'], $server_status['Aborted_connects'],
743 $server_status['Max_used_connections'], $server_status['Bytes_received'],
744 $server_status['Bytes_sent'], $server_status['Connections'],
745 $server_status['Questions'], $server_status['Uptime'],
746 $used_queries
749 foreach ($sections as $section_name => $section) {
750 if (! empty($section['vars'])) {
752 <table class="data" id="serverstatussection<?php echo $section_name; ?>">
753 <caption class="tblHeaders">
754 <a class="top"
755 href="<?php echo $PMA_PHP_SELF . '?' .
756 PMA_generate_common_url() . '#serverstatus'; ?>"
757 name="<?php echo $section_name; ?>"><?php echo __('Begin'); ?>
758 <?php echo
759 ($GLOBALS['cfg']['MainPageIconic']
760 ? '<img src="' . $GLOBALS['pmaThemeImage'] .
761 's_asc.png" width="11" height="9" align="middle" alt="" />'
762 : ''); ?>
763 </a>
764 <?php
765 if (! empty($section['title'])) {
766 echo $section['title'];
769 </caption>
770 <col class="namecol" />
771 <col class="valuecol" />
772 <col class="descrcol" />
773 <thead>
774 <tr>
775 <th><?php echo __('Variable'); ?></th>
776 <th><?php echo __('Value'); ?></th>
777 <th><?php echo __('Description'); ?></th>
778 </tr>
779 </thead>
780 <?php
781 if (! empty($links[$section_name])) {
783 <tfoot>
784 <tr class="tblFooters">
785 <th colspan="3" class="tblFooters">
786 <?php
787 foreach ($links[$section_name] as $link_name => $link_url) {
788 if ('doc' == $link_name) {
789 echo PMA_showMySQLDocu($link_url, $link_url);
790 } else {
791 echo '<a href="' . $link_url . '">' . $link_name . '</a>' . "\n";
794 unset($link_url, $link_name);
796 </th>
797 </tr>
798 </tfoot>
799 <?php
802 <tbody>
803 <?php
804 $odd_row = false;
805 foreach ($section['vars'] as $name => $value) {
806 $odd_row = !$odd_row;
808 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
809 <th class="name"><?php echo htmlspecialchars($name) . PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); ?>
810 </th>
811 <td class="value"><?php
812 if (isset($alerts[$name])) {
813 if ($value > $alerts[$name]) {
814 echo '<span class="attention">';
815 } else {
816 echo '<span class="allfine">';
819 if ('%' === substr($name, -1, 1)) {
820 echo PMA_formatNumber($value, 0, 2) . ' %';
821 } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
822 echo PMA_formatNumber($value, 3, 1);
823 } elseif (is_numeric($value) && $value == (int) $value) {
824 echo PMA_formatNumber($value, 4, 0);
825 } elseif (is_numeric($value)) {
826 echo PMA_formatNumber($value, 3, 1);
827 } else {
828 echo htmlspecialchars($value);
830 if (isset($alerts[$name])) {
831 echo '</span>';
833 ?></td>
834 <td class="descr">
835 <?php
836 if (isset($GLOBALS['strShowStatus' . $name . 'Descr'])) {
837 echo $GLOBALS['strShowStatus' . $name . 'Descr'];
840 if (isset($links[$name])) {
841 foreach ($links[$name] as $link_name => $link_url) {
842 if ('doc' == $link_name) {
843 echo PMA_showMySQLDocu($link_url, $link_url);
844 } else {
845 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
846 "\n";
849 unset($link_url, $link_name);
852 </td>
853 </tr>
854 <?php
856 unset($name, $value);
858 </tbody>
859 </table>
860 <?php
863 unset($section_name, $section, $sections, $server_status, $odd_row, $alerts);
865 </div>
866 <?php
867 /* if the server works as master or slave in replication process, display useful information */
868 if ($server_master_status || $server_slave_status)
871 <hr class="clearfloat" />
873 <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
874 <?php
876 foreach ($replication_types as $type)
878 if (${"server_{$type}_status"}) {
879 PMA_replication_print_status_table($type);
882 unset($types);
886 </div>
888 <?php
890 * Sends the footer
892 require './libraries/footer.inc.php';