2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * functions for displaying server status variables
7 * @usedby server_status_variables.php
11 if (! defined('PHPMYADMIN')) {
16 * Returns the html for the list filter
18 * @param PMA_ServerStatusData $ServerStatusData Server status data
22 function PMA_getHtmlForFilter($ServerStatusData)
25 if (! empty($_REQUEST['filterAlert'])) {
26 $filterAlert = ' checked="checked"';
29 if (! empty($_REQUEST['filterText'])) {
30 $filterText = htmlspecialchars($_REQUEST['filterText']);
33 if (! empty($_REQUEST['dontFormat'])) {
34 $dontFormat = ' checked="checked"';
38 $retval .= '<fieldset id="tableFilter">';
39 $retval .= '<legend>' . __('Filters') . '</legend>';
40 $retval .= '<form action="server_status_variables.php'
41 . PMA_URL_getCommon() . '">';
42 $retval .= '<input type="submit" value="' . __('Refresh') . '" />';
43 $retval .= '<div class="formelement">';
44 $retval .= '<label for="filterText">' . __('Containing the word:') . '</label>';
45 $retval .= '<input name="filterText" type="text" id="filterText" '
46 . 'style="vertical-align: baseline;" value="' . $filterText . '" />';
48 $retval .= '<div class="formelement">';
49 $retval .= '<input' . $filterAlert . ' type="checkbox" '
50 . 'name="filterAlert" id="filterAlert" />';
51 $retval .= '<label for="filterAlert">';
52 $retval .= __('Show only alert values');
53 $retval .= '</label>';
55 $retval .= '<div class="formelement">';
56 $retval .= '<select id="filterCategory" name="filterCategory">';
57 $retval .= '<option value="">' . __('Filter by category…') . '</option>';
59 foreach ($ServerStatusData->sections
as $section_id => $section_name) {
60 if (isset($ServerStatusData->categoryUsed
[$section_id])) {
61 if (! empty($_REQUEST['filterCategory'])
62 && $_REQUEST['filterCategory'] == $section_id
64 $selected = ' selected="selected"';
68 $retval .= '<option' . $selected . ' value="' . $section_id . '">';
69 $retval .= htmlspecialchars($section_name) . '</option>';
72 $retval .= '</select>';
74 $retval .= '<div class="formelement">';
75 $retval .= '<input' . $dontFormat . ' type="checkbox" '
76 . 'name="dontFormat" id="dontFormat" />';
77 $retval .= '<label for="dontFormat">';
78 $retval .= __('Show unformatted values');
79 $retval .= '</label>';
82 $retval .= '</fieldset>';
88 * Prints the suggestion links
90 * @param PMA_ServerStatusData $ServerStatusData Server status data
94 function PMA_getHtmlForLinkSuggestions($ServerStatusData)
96 $retval = '<div id="linkSuggestions" class="defaultLinks" '
97 . 'style="display:none">';
98 $retval .= '<p class="notice">' . __('Related links:');
99 foreach ($ServerStatusData->links
as $section_name => $section_links) {
100 $retval .= '<span class="status_' . $section_name . '"> ';
102 foreach ($section_links as $link_name => $link_url) {
106 if ('doc' == $link_name) {
107 $retval .= PMA_Util
::showMySQLDocu($link_url);
109 $retval .= '<a href="' . $link_url . '">' . $link_name . '</a>';
113 $retval .= '</span>';
115 unset($link_url, $link_name, $i);
123 * Returns a table with variables information
125 * @param PMA_ServerStatusData $ServerStatusData Server status data
129 function PMA_getHtmlForVariablesList($ServerStatusData)
132 $strShowStatus = PMA_getStatusVariablesDescriptions();
136 // name => max value before alert
139 // variable => max value
140 'Aborted_clients' => 0,
141 'Aborted_connects' => 0,
143 'Binlog_cache_disk_use' => 0,
145 'Created_tmp_disk_tables' => 0,
147 'Handler_read_rnd' => 0,
148 'Handler_read_rnd_next' => 0,
150 'Innodb_buffer_pool_pages_dirty' => 0,
151 'Innodb_buffer_pool_reads' => 0,
152 'Innodb_buffer_pool_wait_free' => 0,
153 'Innodb_log_waits' => 0,
154 'Innodb_row_lock_time_avg' => 10, // ms
155 'Innodb_row_lock_time_max' => 50, // ms
156 'Innodb_row_lock_waits' => 0,
159 'Delayed_errors' => 0,
160 'Select_full_join' => 0,
161 'Select_range_check' => 0,
162 'Sort_merge_passes' => 0,
163 'Opened_tables' => 0,
164 'Table_locks_waited' => 0,
165 'Qcache_lowmem_prunes' => 0,
167 'Qcache_free_blocks' =>
168 isset($ServerStatusData->status
['Qcache_total_blocks'])
169 ?
$ServerStatusData->status
['Qcache_total_blocks'] / 5
171 'Slow_launch_threads' => 0,
173 // depends on Key_read_requests
174 // normally lower then 1:0.01
175 'Key_reads' => isset($ServerStatusData->status
['Key_read_requests'])
176 ?
(0.01 * $ServerStatusData->status
['Key_read_requests']) : 0,
177 // depends on Key_write_requests
178 // normally nearly 1:1
179 'Key_writes' => isset($ServerStatusData->status
['Key_write_requests'])
180 ?
(0.9 * $ServerStatusData->status
['Key_write_requests']) : 0,
182 'Key_buffer_fraction' => 0.5,
184 // alert if more than 95% of thread cache is in use
185 'Threads_cached' => isset($ServerStatusData->variables
['thread_cache_size'])
186 ?
0.95 * $ServerStatusData->variables
['thread_cache_size'] : 0
189 // variable => min value
190 //'Handler read key' => '> ',
193 $retval .= PMA_getHtmlForRenderVariables(
203 * Returns HTML for render variables list
205 * @param PMA_ServerStatusData $ServerStatusData Server status data
206 * @param Array $alerts Alert Array
207 * @param Array $strShowStatus Status Array
211 function PMA_getHtmlForRenderVariables($ServerStatusData, $alerts, $strShowStatus)
213 $retval = '<table class="data noclick" id="serverstatusvariables">';
214 $retval .= '<col class="namecol" />';
215 $retval .= '<col class="valuecol" />';
216 $retval .= '<col class="descrcol" />';
217 $retval .= '<thead>';
219 $retval .= '<th>' . __('Variable') . '</th>';
220 $retval .= '<th>' . __('Value') . '</th>';
221 $retval .= '<th>' . __('Description') . '</th>';
223 $retval .= '</thead>';
224 $retval .= '<tbody>';
227 foreach ($ServerStatusData->status
as $name => $value) {
228 $odd_row = !$odd_row;
229 $retval .= '<tr class="' . ($odd_row ?
'odd' : 'even')
230 . (isset($ServerStatusData->allocationMap
[$name])
231 ?
' s_' . $ServerStatusData->allocationMap
[$name]
235 $retval .= '<th class="name">';
236 $retval .= htmlspecialchars(str_replace('_', ' ', $name));
237 // Fields containing % are calculated,
238 // they can not be described in MySQL documentation
239 if (/*overload*/mb_strpos($name, '%') === false) {
240 $retval .= PMA_Util
::showMySQLDocu(
241 'server-status-variables',
248 $retval .= '<td class="value"><span class="formatted">';
249 if (isset($alerts[$name])) {
250 if ($value > $alerts[$name]) {
251 $retval .= '<span class="attention">';
253 $retval .= '<span class="allfine">';
256 if (substr($name, -1) === '%') {
257 $retval .= htmlspecialchars(PMA_Util
::formatNumber($value, 0, 2)) . ' %';
258 } elseif (strpos($name, 'Uptime') !== false) {
259 $retval .= htmlspecialchars(
260 PMA_Util
::timespanFormat($value)
262 } elseif (is_numeric($value) && $value > 1000) {
263 $retval .= '<abbr title="'
264 // makes available the raw value as a title
265 . htmlspecialchars(PMA_Util
::formatNumber($value, 0))
267 . htmlspecialchars(PMA_Util
::formatNumber($value, 3, 1))
269 } elseif (is_numeric($value)) {
270 $retval .= htmlspecialchars(PMA_Util
::formatNumber($value, 3, 1));
272 $retval .= htmlspecialchars($value);
274 if (isset($alerts[$name])) {
275 $retval .= '</span>';
277 $retval .= '</span>';
278 $retval .= '<span style="display:none;" class="original">';
279 if (isset($alerts[$name])) {
280 if ($value > $alerts[$name]) {
281 $retval .= '<span class="attention">';
283 $retval .= '<span class="allfine">';
287 if (isset($alerts[$name])) {
288 $retval .= '</span>';
290 $retval .= '</span>';
292 $retval .= '<td class="descr">';
294 if (isset($strShowStatus[$name])) {
295 $retval .= $strShowStatus[$name];
298 if (isset($ServerStatusData->links
[$name])) {
299 foreach ($ServerStatusData->links
[$name] as $link_name => $link_url) {
300 if ('doc' == $link_name) {
301 $retval .= PMA_Util
::showMySQLDocu($link_url);
303 $retval .= ' <a href="' . $link_url . '">' . $link_name . '</a>';
306 unset($link_url, $link_name);
311 $retval .= '</tbody>';
312 $retval .= '</table>';
318 * Returns a list of variable descriptions
322 function PMA_getStatusVariablesDescriptions()
325 * Messages are built using the message name
328 'Aborted_clients' => __(
329 'The number of connections that were aborted because the client died'
330 . ' without closing the connection properly.'
332 'Aborted_connects' => __(
333 'The number of failed attempts to connect to the MySQL server.'
335 'Binlog_cache_disk_use' => __(
336 'The number of transactions that used the temporary binary log cache'
337 . ' but that exceeded the value of binlog_cache_size and used a'
338 . ' temporary file to store statements from the transaction.'
340 'Binlog_cache_use' => __(
341 'The number of transactions that used the temporary binary log cache.'
344 'The number of connection attempts (successful or not)'
345 . ' to the MySQL server.'
347 'Created_tmp_disk_tables' => __(
348 'The number of temporary tables on disk created automatically by'
349 . ' the server while executing statements. If'
350 . ' Created_tmp_disk_tables is big, you may want to increase the'
351 . ' tmp_table_size value to cause temporary tables to be'
352 . ' memory-based instead of disk-based.'
354 'Created_tmp_files' => __(
355 'How many temporary files mysqld has created.'
357 'Created_tmp_tables' => __(
358 'The number of in-memory temporary tables created automatically'
359 . ' by the server while executing statements.'
361 'Delayed_errors' => __(
362 'The number of rows written with INSERT DELAYED for which some'
363 . ' error occurred (probably duplicate key).'
365 'Delayed_insert_threads' => __(
366 'The number of INSERT DELAYED handler threads in use. Every'
367 . ' different table on which one uses INSERT DELAYED gets'
370 'Delayed_writes' => __(
371 'The number of INSERT DELAYED rows written.'
373 'Flush_commands' => __(
374 'The number of executed FLUSH statements.'
376 'Handler_commit' => __(
377 'The number of internal COMMIT statements.'
379 'Handler_delete' => __(
380 'The number of times a row was deleted from a table.'
382 'Handler_discover' => __(
383 'The MySQL server can ask the NDB Cluster storage engine if it'
384 . ' knows about a table with a given name. This is called discovery.'
385 . ' Handler_discover indicates the number of time tables have been'
388 'Handler_read_first' => __(
389 'The number of times the first entry was read from an index. If this'
390 . ' is high, it suggests that the server is doing a lot of full'
391 . ' index scans; for example, SELECT col1 FROM foo, assuming that'
392 . ' col1 is indexed.'
394 'Handler_read_key' => __(
395 'The number of requests to read a row based on a key. If this is'
396 . ' high, it is a good indication that your queries and tables'
397 . ' are properly indexed.'
399 'Handler_read_next' => __(
400 'The number of requests to read the next row in key order. This is'
401 . ' incremented if you are querying an index column with a range'
402 . ' constraint or if you are doing an index scan.'
404 'Handler_read_prev' => __(
405 'The number of requests to read the previous row in key order.'
406 . ' This read method is mainly used to optimize ORDER BY … DESC.'
408 'Handler_read_rnd' => __(
409 'The number of requests to read a row based on a fixed position.'
410 . ' This is high if you are doing a lot of queries that require'
411 . ' sorting of the result. You probably have a lot of queries that'
412 . ' require MySQL to scan whole tables or you have joins that'
413 . ' don\'t use keys properly.'
415 'Handler_read_rnd_next' => __(
416 'The number of requests to read the next row in the data file.'
417 . ' This is high if you are doing a lot of table scans. Generally'
418 . ' this suggests that your tables are not properly indexed or that'
419 . ' your queries are not written to take advantage of the indexes'
422 'Handler_rollback' => __(
423 'The number of internal ROLLBACK statements.'
425 'Handler_update' => __(
426 'The number of requests to update a row in a table.'
428 'Handler_write' => __(
429 'The number of requests to insert a row in a table.'
431 'Innodb_buffer_pool_pages_data' => __(
432 'The number of pages containing data (dirty or clean).'
434 'Innodb_buffer_pool_pages_dirty' => __(
435 'The number of pages currently dirty.'
437 'Innodb_buffer_pool_pages_flushed' => __(
438 'The number of buffer pool pages that have been requested'
441 'Innodb_buffer_pool_pages_free' => __(
442 'The number of free pages.'
444 'Innodb_buffer_pool_pages_latched' => __(
445 'The number of latched pages in InnoDB buffer pool. These are pages'
446 . ' currently being read or written or that can\'t be flushed or'
447 . ' removed for some other reason.'
449 'Innodb_buffer_pool_pages_misc' => __(
450 'The number of pages busy because they have been allocated for'
451 . ' administrative overhead such as row locks or the adaptive'
452 . ' hash index. This value can also be calculated as'
453 . ' Innodb_buffer_pool_pages_total - Innodb_buffer_pool_pages_free'
454 . ' - Innodb_buffer_pool_pages_data.'
456 'Innodb_buffer_pool_pages_total' => __(
457 'Total size of buffer pool, in pages.'
459 'Innodb_buffer_pool_read_ahead_rnd' => __(
460 'The number of "random" read-aheads InnoDB initiated. This happens'
461 . ' when a query is to scan a large portion of a table but in'
464 'Innodb_buffer_pool_read_ahead_seq' => __(
465 'The number of sequential read-aheads InnoDB initiated. This'
466 . ' happens when InnoDB does a sequential full table scan.'
468 'Innodb_buffer_pool_read_requests' => __(
469 'The number of logical read requests InnoDB has done.'
471 'Innodb_buffer_pool_reads' => __(
472 'The number of logical reads that InnoDB could not satisfy'
473 . ' from buffer pool and had to do a single-page read.'
475 'Innodb_buffer_pool_wait_free' => __(
476 'Normally, writes to the InnoDB buffer pool happen in the'
477 . ' background. However, if it\'s necessary to read or create a page'
478 . ' and no clean pages are available, it\'s necessary to wait for'
479 . ' pages to be flushed first. This counter counts instances of'
480 . ' these waits. If the buffer pool size was set properly, this'
481 . ' value should be small.'
483 'Innodb_buffer_pool_write_requests' => __(
484 'The number writes done to the InnoDB buffer pool.'
486 'Innodb_data_fsyncs' => __(
487 'The number of fsync() operations so far.'
489 'Innodb_data_pending_fsyncs' => __(
490 'The current number of pending fsync() operations.'
492 'Innodb_data_pending_reads' => __(
493 'The current number of pending reads.'
495 'Innodb_data_pending_writes' => __(
496 'The current number of pending writes.'
498 'Innodb_data_read' => __(
499 'The amount of data read so far, in bytes.'
501 'Innodb_data_reads' => __(
502 'The total number of data reads.'
504 'Innodb_data_writes' => __(
505 'The total number of data writes.'
507 'Innodb_data_written' => __(
508 'The amount of data written so far, in bytes.'
510 'Innodb_dblwr_pages_written' => __(
511 'The number of pages that have been written for'
512 . ' doublewrite operations.'
514 'Innodb_dblwr_writes' => __(
515 'The number of doublewrite operations that have been performed.'
517 'Innodb_log_waits' => __(
518 'The number of waits we had because log buffer was too small and'
519 . ' we had to wait for it to be flushed before continuing.'
521 'Innodb_log_write_requests' => __(
522 'The number of log write requests.'
524 'Innodb_log_writes' => __(
525 'The number of physical writes to the log file.'
527 'Innodb_os_log_fsyncs' => __(
528 'The number of fsync() writes done to the log file.'
530 'Innodb_os_log_pending_fsyncs' => __(
531 'The number of pending log file fsyncs.'
533 'Innodb_os_log_pending_writes' => __(
534 'Pending log file writes.'
536 'Innodb_os_log_written' => __(
537 'The number of bytes written to the log file.'
539 'Innodb_pages_created' => __(
540 'The number of pages created.'
542 'Innodb_page_size' => __(
543 'The compiled-in InnoDB page size (default 16KB). Many values are'
544 . ' counted in pages; the page size allows them to be easily'
545 . ' converted to bytes.'
547 'Innodb_pages_read' => __(
548 'The number of pages read.'
550 'Innodb_pages_written' => __(
551 'The number of pages written.'
553 'Innodb_row_lock_current_waits' => __(
554 'The number of row locks currently being waited for.'
556 'Innodb_row_lock_time_avg' => __(
557 'The average time to acquire a row lock, in milliseconds.'
559 'Innodb_row_lock_time' => __(
560 'The total time spent in acquiring row locks, in milliseconds.'
562 'Innodb_row_lock_time_max' => __(
563 'The maximum time to acquire a row lock, in milliseconds.'
565 'Innodb_row_lock_waits' => __(
566 'The number of times a row lock had to be waited for.'
568 'Innodb_rows_deleted' => __(
569 'The number of rows deleted from InnoDB tables.'
571 'Innodb_rows_inserted' => __(
572 'The number of rows inserted in InnoDB tables.'
574 'Innodb_rows_read' => __(
575 'The number of rows read from InnoDB tables.'
577 'Innodb_rows_updated' => __(
578 'The number of rows updated in InnoDB tables.'
580 'Key_blocks_not_flushed' => __(
581 'The number of key blocks in the key cache that have changed but'
582 . ' haven\'t yet been flushed to disk. It used to be known as'
583 . ' Not_flushed_key_blocks.'
585 'Key_blocks_unused' => __(
586 'The number of unused blocks in the key cache. You can use this'
587 . ' value to determine how much of the key cache is in use.'
589 'Key_blocks_used' => __(
590 'The number of used blocks in the key cache. This value is a'
591 . ' high-water mark that indicates the maximum number of blocks'
592 . ' that have ever been in use at one time.'
594 'Key_buffer_fraction_%' => __(
595 'Percentage of used key cache (calculated value)'
597 'Key_read_requests' => __(
598 'The number of requests to read a key block from the cache.'
601 'The number of physical reads of a key block from disk. If Key_reads'
602 . ' is big, then your key_buffer_size value is probably too small.'
603 . ' The cache miss rate can be calculated as'
604 . ' Key_reads/Key_read_requests.'
606 'Key_read_ratio_%' => __(
607 'Key cache miss calculated as rate of physical reads compared'
608 . ' to read requests (calculated value)'
610 'Key_write_requests' => __(
611 'The number of requests to write a key block to the cache.'
614 'The number of physical writes of a key block to disk.'
616 'Key_write_ratio_%' => __(
617 'Percentage of physical writes compared'
618 . ' to write requests (calculated value)'
620 'Last_query_cost' => __(
621 'The total cost of the last compiled query as computed by the query'
622 . ' optimizer. Useful for comparing the cost of different query'
623 . ' plans for the same query. The default value of 0 means that'
624 . ' no query has been compiled yet.'
626 'Max_used_connections' => __(
627 'The maximum number of connections that have been in use'
628 . ' simultaneously since the server started.'
630 'Not_flushed_delayed_rows' => __(
631 'The number of rows waiting to be written in INSERT DELAYED queues.'
633 'Opened_tables' => __(
634 'The number of tables that have been opened. If opened tables is'
635 . ' big, your table cache value is probably too small.'
638 'The number of files that are open.'
640 'Open_streams' => __(
641 'The number of streams that are open (used mainly for logging).'
644 'The number of tables that are open.'
646 'Qcache_free_blocks' => __(
647 'The number of free memory blocks in query cache. High numbers can'
648 . ' indicate fragmentation issues, which may be solved by issuing'
649 . ' a FLUSH QUERY CACHE statement.'
651 'Qcache_free_memory' => __(
652 'The amount of free memory for query cache.'
655 'The number of cache hits.'
657 'Qcache_inserts' => __(
658 'The number of queries added to the cache.'
660 'Qcache_lowmem_prunes' => __(
661 'The number of queries that have been removed from the cache to'
662 . ' free up memory for caching new queries. This information can'
663 . ' help you tune the query cache size. The query cache uses a'
664 . ' least recently used (LRU) strategy to decide which queries'
665 . ' to remove from the cache.'
667 'Qcache_not_cached' => __(
668 'The number of non-cached queries (not cachable, or not cached'
669 . ' due to the query_cache_type setting).'
671 'Qcache_queries_in_cache' => __(
672 'The number of queries registered in the cache.'
674 'Qcache_total_blocks' => __(
675 'The total number of blocks in the query cache.'
678 'The status of failsafe replication (not yet implemented).'
680 'Select_full_join' => __(
681 'The number of joins that do not use indexes. If this value is'
682 . ' not 0, you should carefully check the indexes of your tables.'
684 'Select_full_range_join' => __(
685 'The number of joins that used a range search on a reference table.'
687 'Select_range_check' => __(
688 'The number of joins without keys that check for key usage after'
689 . ' each row. (If this is not 0, you should carefully check the'
690 . ' indexes of your tables.)'
692 'Select_range' => __(
693 'The number of joins that used ranges on the first table. (It\'s'
694 . ' normally not critical even if this is big.)'
697 'The number of joins that did a full scan of the first table.'
699 'Slave_open_temp_tables' => __(
700 'The number of temporary tables currently'
701 . ' open by the slave SQL thread.'
703 'Slave_retried_transactions' => __(
704 'Total (since startup) number of times the replication slave SQL'
705 . ' thread has retried transactions.'
707 'Slave_running' => __(
708 'This is ON if this server is a slave that is connected to a master.'
710 'Slow_launch_threads' => __(
711 'The number of threads that have taken more than slow_launch_time'
712 . ' seconds to create.'
714 'Slow_queries' => __(
715 'The number of queries that have taken more than long_query_time'
718 'Sort_merge_passes' => __(
719 'The number of merge passes the sort algorithm has had to do.'
720 . ' If this value is large, you should consider increasing the'
721 . ' value of the sort_buffer_size system variable.'
724 'The number of sorts that were done with ranges.'
727 'The number of sorted rows.'
730 'The number of sorts that were done by scanning the table.'
732 'Table_locks_immediate' => __(
733 'The number of times that a table lock was acquired immediately.'
735 'Table_locks_waited' => __(
736 'The number of times that a table lock could not be acquired'
737 . ' immediately and a wait was needed. If this is high, and you have'
738 . ' performance problems, you should first optimize your queries,'
739 . ' and then either split your table or tables or use replication.'
741 'Threads_cached' => __(
742 'The number of threads in the thread cache. The cache hit rate can'
743 . ' be calculated as Threads_created/Connections. If this value is'
744 . ' red you should raise your thread_cache_size.'
746 'Threads_connected' => __(
747 'The number of currently open connections.'
749 'Threads_created' => __(
750 'The number of threads created to handle connections. If'
751 . ' Threads_created is big, you may want to increase the'
752 . ' thread_cache_size value. (Normally this doesn\'t give a notable'
753 . ' performance improvement if you have a good thread'
754 . ' implementation.)'
756 'Threads_cache_hitrate_%' => __(
757 'Thread cache hit rate (calculated value)'
759 'Threads_running' => __(
760 'The number of threads that are not sleeping.'