2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * displays status variables with descriptions and some hints an optmizing
5 * + reset status variables
10 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
11 $GLOBALS['is_header_sent'] = true;
14 require_once 'libraries/common.inc.php';
20 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
21 // Send with correct charset
22 header('Content-Type: text/html; charset=UTF-8');
24 // real-time charting data
25 if (isset($_REQUEST['chart_data'])) {
26 switch($_REQUEST['type']) {
27 // Process and Connections realtime chart
29 $c = PMA_DBI_fetch_result(
30 "SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1
32 $result = PMA_DBI_query('SHOW PROCESSLIST');
33 $num_procs = PMA_DBI_num_rows($result);
36 'x' => microtime(true) * 1000,
37 'y_proc' => $num_procs,
38 'y_conn' => $c['Connections']
41 exit(json_encode($ret));
43 case 'queries': // Query realtime chart
45 $sql = "SELECT concat('Com_', variable_name), variable_value
46 FROM data_dictionary.GLOBAL_STATEMENTS
47 WHERE variable_value > 0
49 SELECT variable_name, variable_value
50 FROM data_dictionary.GLOBAL_STATUS
51 WHERE variable_name = 'Questions'";
52 $queries = PMA_DBI_fetch_result($sql, 0, 1);
54 $queries = PMA_DBI_fetch_result(
56 WHERE (Variable_name LIKE 'Com_%' OR Variable_name = 'Questions')
60 cleanDeprecated($queries);
61 // admin commands are not queries
62 unset($queries['Com_admin_commands']);
63 $questions = $queries['Questions'];
64 unset($queries['Questions']);
66 //$sum=array_sum($queries);
68 'x' => microtime(true) * 1000,
70 'pointInfo' => $queries
73 exit(json_encode($ret));
75 case 'traffic': // Traffic realtime chart
76 $traffic = PMA_DBI_fetch_result(
78 WHERE Variable_name = 'Bytes_received'
79 OR Variable_name = 'Bytes_sent'", 0, 1
83 'x' => microtime(true) * 1000,
84 'y_sent' => $traffic['Bytes_sent'],
85 'y_received' => $traffic['Bytes_received']
88 exit(json_encode($ret));
90 case 'chartgrid': // Data for the monitor
91 $ret = json_decode($_REQUEST['requiredData'], true);
92 $statusVars = array();
93 $serverVars = array();
94 $sysinfo = $cpuload = $memory = 0;
97 /* Accumulate all required variables and data */
99 foreach ($ret as $chart_id => $chartNodes) {
100 // For each data series
101 foreach ($chartNodes as $node_id => $nodeDataPoints) {
102 // For each data point in the series (usually just 1)
103 foreach ($nodeDataPoints as $point_id => $dataPoint) {
104 $pName = $dataPoint['name'];
106 switch ($dataPoint['type']) {
107 /* We only collect the status and server variables here to
108 * read them all in one query,
109 * and only afterwards assign them.
110 * Also do some white list filtering on the names
113 if (! preg_match('/[^a-zA-Z_]+/', $pName)) {
114 $serverVars[] = $pName;
119 if (! preg_match('/[^a-zA-Z_]+/', $pName)) {
120 $statusVars[] = $pName;
125 $result = PMA_DBI_query('SHOW PROCESSLIST');
126 $ret[$chart_id][$node_id][$point_id]['value']
127 = PMA_DBI_num_rows($result);
132 include_once 'libraries/sysinfo.lib.php';
133 $sysinfo = getSysInfo();
136 $cpuload = $sysinfo->loadavg();
139 if (PHP_OS
== 'Linux') {
140 $ret[$chart_id][$node_id][$point_id]['idle']
142 $ret[$chart_id][$node_id][$point_id]['busy']
145 $ret[$chart_id][$node_id][$point_id]['value']
146 = $cpuload['loadavg'];
153 include_once 'libraries/sysinfo.lib.php';
154 $sysinfo = getSysInfo();
157 $memory = $sysinfo->memory();
160 $ret[$chart_id][$node_id][$point_id]['value']
168 // Retrieve all required status variables
169 if (count($statusVars)) {
170 $statusVarValues = PMA_DBI_fetch_result(
172 WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1
175 $statusVarValues = array();
178 // Retrieve all required server variables
179 if (count($serverVars)) {
180 $serverVarValues = PMA_DBI_fetch_result(
181 "SHOW GLOBAL VARIABLES
182 WHERE Variable_name='" . implode("' OR Variable_name='", $serverVars) . "'", 0, 1
185 $serverVarValues = array();
188 // ...and now assign them
189 foreach ($ret as $chart_id => $chartNodes) {
190 foreach ($chartNodes as $node_id => $nodeDataPoints) {
191 foreach ($nodeDataPoints as $point_id => $dataPoint) {
192 switch($dataPoint['type']) {
194 $ret[$chart_id][$node_id][$point_id]['value']
195 = $statusVarValues[$dataPoint['name']];
198 $ret[$chart_id][$node_id][$point_id]['value']
199 = $serverVarValues[$dataPoint['name']];
206 $ret['x'] = microtime(true) * 1000;
208 exit(json_encode($ret));
212 if (isset($_REQUEST['log_data'])) {
213 if (PMA_MYSQL_INT_VERSION
< 50106) {
214 /* FIXME: why this? */
218 $start = intval($_REQUEST['time_start']);
219 $end = intval($_REQUEST['time_end']);
221 if ($_REQUEST['type'] == 'slow') {
222 $q = 'SELECT start_time, user_host, ';
223 $q .= 'Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, ';
224 $q .= 'Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, ';
225 $q .= 'SUM(rows_sent) AS rows_sent, ';
226 $q .= 'SUM(rows_examined) AS rows_examined, db, sql_text, ';
227 $q .= 'COUNT(sql_text) AS \'#\' ';
228 $q .= 'FROM `mysql`.`slow_log` ';
229 $q .= 'WHERE start_time > FROM_UNIXTIME(' . $start . ') ';
230 $q .= 'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
232 $result = PMA_DBI_try_query($q);
234 $return = array('rows' => array(), 'sum' => array());
237 while ($row = PMA_DBI_fetch_assoc($result)) {
239 substr($row['sql_text'], 0, strpos($row['sql_text'], ' '))
245 //Cut off big inserts and updates, but append byte count instead
246 if (strlen($row['sql_text']) > 220) {
247 $implode_sql_text = implode(
248 ' ', PMA_formatByteDown(strlen($row['sql_text']), 2, 2)
250 $row['sql_text'] = substr($row['sql_text'], 0, 200)
251 . '... [' . $implode_sql_text . ']';
258 if (! isset($return['sum'][$type])) {
259 $return['sum'][$type] = 0;
261 $return['sum'][$type] +
= $row['#'];
262 $return['rows'][] = $row;
265 $return['sum']['TOTAL'] = array_sum($return['sum']);
266 $return['numRows'] = count($return['rows']);
268 PMA_DBI_free_result($result);
270 exit(json_encode($return));
273 if ($_REQUEST['type'] == 'general') {
274 $limitTypes = (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes'])
275 ?
'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
277 $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, ';
278 $q .= 'server_id, argument, count(argument) as \'#\' ';
279 $q .= 'FROM `mysql`.`general_log` ';
280 $q .= 'WHERE command_type=\'Query\' ';
281 $q .= 'AND event_time > FROM_UNIXTIME(' . $start . ') ';
282 $q .= 'AND event_time < FROM_UNIXTIME(' . $end . ') ';
283 $q .= $limitTypes . 'GROUP by argument'; // HAVING count > 1';
285 $result = PMA_DBI_try_query($q);
287 $return = array('rows' => array(), 'sum' => array());
289 $insertTables = array();
290 $insertTablesFirst = -1;
292 $removeVars = isset($_REQUEST['removeVariables'])
293 && $_REQUEST['removeVariables'];
295 while ($row = PMA_DBI_fetch_assoc($result)) {
296 preg_match('/^(\w+)\s/', $row['argument'], $match);
297 $type = strtolower($match[1]);
299 if (! isset($return['sum'][$type])) {
300 $return['sum'][$type] = 0;
302 $return['sum'][$type] +
= $row['#'];
306 // Group inserts if selected
307 if ($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i', $row['argument'], $matches)) {
308 $insertTables[$matches[2]]++
;
309 if ($insertTables[$matches[2]] > 1) {
310 $return['rows'][$insertTablesFirst]['#']
311 = $insertTables[$matches[2]];
313 // Add a ... to the end of this query to indicate that there's been other queries
314 if ($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.') {
315 $return['rows'][$insertTablesFirst]['argument'] .= '<br/>...';
318 // Group this value, thus do not add to the result list
321 $insertTablesFirst = $i;
322 $insertTables[$matches[2]] +
= $row['#'] - 1;
328 // Cut off big inserts and updates, but append byte count therefor
329 if (strlen($row['argument']) > 220) {
330 $row['argument'] = substr($row['argument'], 0, 200)
332 . implode(' ', PMA_formatByteDown(strlen($row['argument'])), 2, 2)
341 $return['rows'][] = $row;
345 $return['sum']['TOTAL'] = array_sum($return['sum']);
346 $return['numRows'] = count($return['rows']);
348 PMA_DBI_free_result($result);
350 exit(json_encode($return));
354 if (isset($_REQUEST['logging_vars'])) {
355 if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
356 $value = PMA_sqlAddslashes($_REQUEST['varValue']);
357 if (! is_numeric($value)) {
358 $value="'" . $value . "'";
361 if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])) {
362 PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value);
367 $loggingVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES WHERE Variable_name IN ("general_log","slow_query_log","long_query_time","log_output")', 0, 1);
368 exit(json_encode($loggingVars));
371 if (isset($_REQUEST['query_analyzer'])) {
374 if (strlen($_REQUEST['database'])) {
375 PMA_DBI_select_db($_REQUEST['database']);
378 if ($profiling = PMA_profilingSupported()) {
379 PMA_DBI_query('SET PROFILING=1;');
382 // Do not cache query
383 $query = preg_replace('/^(\s*SELECT)/i', '\\1 SQL_NO_CACHE', $_REQUEST['query']);
385 $result = PMA_DBI_try_query($query);
386 $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
388 $result = PMA_DBI_try_query('EXPLAIN ' . $query);
389 while ($row = PMA_DBI_fetch_assoc($result)) {
390 $return['explain'][] = $row;
393 // In case an error happened
394 $return['error'] = PMA_DBI_getError();
396 PMA_DBI_free_result($result);
399 $return['profiling'] = array();
400 $result = PMA_DBI_try_query('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=1 ORDER BY seq');
401 while ($row = PMA_DBI_fetch_assoc($result)) {
402 $return['profiling'][]= $row;
404 PMA_DBI_free_result($result);
407 exit(json_encode($return));
410 if (isset($_REQUEST['advisor'])) {
411 include 'libraries/Advisor.class.php';
412 $advisor = new Advisor();
413 exit(json_encode($advisor->run()));
419 * Replication library
422 $server_master_status = false;
423 $server_slave_status = false;
425 include_once 'libraries/replication.inc.php';
426 include_once 'libraries/replication_gui.lib.php';
433 // needed to decide whether to load codemirror.js in server_status.js
434 PMA_AddJSVar('cfg_CodemirrorEnable', $GLOBALS['cfg']['CodemirrorEnable'] ?
1 : 0);
435 $GLOBALS['js_include'][] = 'server_status.js';
437 $GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
438 $GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
440 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
441 /* Files required for chart exporting */
442 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
443 /* < IE 9 doesn't support canvas natively */
444 if (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
< 9) {
445 $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
447 $GLOBALS['js_include'][] = 'canvg/canvg.js';
450 * flush status variables if requested
452 if (isset($_REQUEST['flush'])) {
453 $_flush_commands = array(
459 if (in_array($_REQUEST['flush'], $_flush_commands)) {
460 PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
462 unset($_flush_commands);
466 * Kills a selected process
468 if (! empty($_REQUEST['kill'])) {
469 if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
470 $message = PMA_Message
::success(__('Thread %s was successfully killed.'));
472 $message = PMA_Message
::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
474 $message->addParam($_REQUEST['kill']);
475 //$message->display();
481 * get status from server
483 $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
485 // Drizzle doesn't put query statistics into variables, add it
486 $sql = "SELECT concat('Com_', variable_name), variable_value
487 FROM data_dictionary.GLOBAL_STATEMENTS";
488 $statements = PMA_DBI_fetch_result($sql, 0, 1);
489 $server_status = array_merge($server_status, $statements);
493 * for some calculations we require also some server settings
495 $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
498 * cleanup of some deprecated values
500 cleanDeprecated($server_status);
503 * calculate some values
505 // Key_buffer_fraction
506 if (isset($server_status['Key_blocks_unused'])
507 && isset($server_variables['key_cache_block_size'])
508 && isset($server_variables['key_buffer_size'])
510 $server_status['Key_buffer_fraction_%']
512 - $server_status['Key_blocks_unused']
513 * $server_variables['key_cache_block_size']
514 / $server_variables['key_buffer_size']
516 } elseif (isset($server_status['Key_blocks_used'])
517 && isset($server_variables['key_buffer_size'])) {
518 $server_status['Key_buffer_fraction_%']
519 = $server_status['Key_blocks_used']
521 / $server_variables['key_buffer_size'];
524 // Ratio for key read/write
525 if (isset($server_status['Key_writes'])
526 && isset($server_status['Key_write_requests'])
527 && $server_status['Key_write_requests'] > 0
529 $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
532 if (isset($server_status['Key_reads'])
533 && isset($server_status['Key_read_requests'])
534 && $server_status['Key_read_requests'] > 0
536 $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
539 // Threads_cache_hitrate
540 if (isset($server_status['Threads_created'])
541 && isset($server_status['Connections'])
542 && $server_status['Connections'] > 0
545 $server_status['Threads_cache_hitrate_%']
546 = 100 - $server_status['Threads_created'] / $server_status['Connections'] * 100;
550 * split variables in sections
552 $allocations = array(
553 // variable name => section
554 // variable names match when they begin with the given string
557 'Innodb_' => 'innodb',
559 'Handler_' => 'handler',
560 'Qcache_' => 'qcache',
561 'Threads_' => 'threads',
562 'Slow_launch_threads' => 'threads',
564 'Binlog_cache_' => 'binlog_cache',
565 'Created_tmp_' => 'created_tmp',
568 'Delayed_' => 'delayed',
569 'Not_flushed_delayed_rows' => 'delayed',
571 'Flush_commands' => 'query',
572 'Last_query_cost' => 'query',
573 'Slow_queries' => 'query',
574 'Queries' => 'query',
575 'Prepared_stmt_count' => 'query',
577 'Select_' => 'select',
580 'Open_tables' => 'table',
581 'Opened_tables' => 'table',
582 'Open_table_definitions' => 'table',
583 'Opened_table_definitions' => 'table',
584 'Table_locks_' => 'table',
586 'Rpl_status' => 'repl',
593 'Open_files' => 'files',
594 'Open_streams' => 'files',
595 'Opened_files' => 'files',
599 // section => section name (description)
601 'query' => __('SQL query'),
602 'innodb' => 'InnoDB',
604 'handler' => __('Handler'),
605 'qcache' => __('Query cache'),
606 'threads' => __('Threads'),
607 'binlog_cache' => __('Binary log'),
608 'created_tmp' => __('Temporary data'),
609 'delayed' => __('Delayed inserts'),
610 'key' => __('Key cache'),
611 'select' => __('Joins'),
612 'repl' => __('Replication'),
613 'sort' => __('Sorting'),
614 'table' => __('Tables'),
615 'tc' => __('Transaction coordinator'),
616 'files' => __('Files'),
618 'other' => __('Other')
622 * define some needfull links/commands
624 // variable or section name => (name => url)
627 $links['table'][__('Flush (close) all tables')]
628 = $PMA_PHP_SELF . '?flush=TABLES&' . PMA_generate_common_url();
629 $links['table'][__('Show open tables')]
630 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
631 '&goto=server_status.php&' . PMA_generate_common_url();
633 if ($server_master_status) {
634 $links['repl'][__('Show slave hosts')]
635 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
636 '&goto=server_status.php&' . PMA_generate_common_url();
637 $links['repl'][__('Show master status')] = '#replication_master';
639 if ($server_slave_status) {
640 $links['repl'][__('Show slave status')] = '#replication_slave';
643 $links['repl']['doc'] = 'replication';
645 $links['qcache'][__('Flush query cache')]
646 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&' .
647 PMA_generate_common_url();
648 $links['qcache']['doc'] = 'query_cache';
650 //$links['threads'][__('Show processes')]
651 // = 'server_processlist.php?' . PMA_generate_common_url();
652 $links['threads']['doc'] = 'mysql_threads';
654 $links['key']['doc'] = 'myisam_key_cache';
656 $links['binlog_cache']['doc'] = 'binary_log';
658 $links['Slow_queries']['doc'] = 'slow_query_log';
660 $links['innodb'][__('Variables')]
661 = 'server_engines.php?engine=InnoDB&' . PMA_generate_common_url();
662 $links['innodb'][__('InnoDB Status')]
663 = 'server_engines.php?engine=InnoDB&page=Status&' .
664 PMA_generate_common_url();
665 $links['innodb']['doc'] = 'innodb';
668 // Variable to contain all com_ variables (query statistics)
669 $used_queries = array();
671 // Variable to map variable names to their respective section name
672 // (used for js category filtering)
673 $allocationMap = array();
675 // Variable to mark used sections
676 $categoryUsed = array();
678 // sort vars into arrays
679 foreach ($server_status as $name => $value) {
680 $section_found = false;
681 foreach ($allocations as $filter => $section) {
682 if (strpos($name, $filter) !== false) {
683 $allocationMap[$name] = $section;
684 $categoryUsed[$section] = true;
685 $section_found = true;
686 if ($section == 'com' && $value > 0) {
687 $used_queries[$name] = $value;
689 break; // Only exits inner loop
692 if (!$section_found) {
693 $allocationMap[$name] = 'other';
694 $categoryUsed['other'] = true;
699 $used_queries = PMA_DBI_fetch_result(
700 'SELECT * FROM data_dictionary.global_statements',
704 unset($used_queries['admin_commands']);
706 // admin commands are not queries (e.g. they include COM_PING,
707 // which is excluded from $server_status['Questions'])
708 unset($used_queries['Com_admin_commands']);
711 /* Ajax request refresh */
712 if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
713 switch($_REQUEST['show']) {
714 case 'query_statistics':
715 printQueryStatistics();
717 case 'server_traffic':
718 printServerTraffic();
720 case 'variables_table':
721 // Prints the variables table
722 printVariablesTable();
730 $server_db_isLocal = strtolower($cfg['Server']['host']) == 'localhost'
731 ||
$cfg['Server']['host'] == '127.0.0.1'
732 ||
$cfg['Server']['host'] == '::1';
736 $_SESSION[' PMA_token ']
740 str_replace('&', '&', PMA_generate_common_url($db))
744 'new Date().getTime() - ' . (microtime(true) * 1000),
761 PMA_showMySQLDocu('general-thread-states', 'general-thread-states')
765 PMA_showMySQLDocu('explain-output', 'explain-output')
773 * Does the common work
775 require 'libraries/server_common.inc.php';
782 require 'libraries/server_links.inc.php';
785 <div id
="serverstatus">
788 * Displays the sub-page heading
790 echo PMA_getImage('s_status.png');
792 echo __('Runtime Information');
795 <div id
="serverStatusTabs">
797 <li
><a href
="#statustabs_traffic"><?php
echo __('Server'); ?
></a
></li
>
798 <li
><a href
="#statustabs_queries"><?php
echo __('Query statistics'); ?
></a
></li
>
799 <li
><a href
="#statustabs_allvars"><?php
echo __('All status variables'); ?
></a
></li
>
800 <li
class="jsfeature"><a href
="#statustabs_charting"><?php
echo __('Monitor'); ?
></a
></li
>
801 <li
class="jsfeature"><a href
="#statustabs_advisor"><?php
echo __('Advisor'); ?
></a
></li
>
804 <div id
="statustabs_traffic" class="clearfloat">
805 <div
class="buttonlinks jsfeature">
806 <a
class="tabRefresh" href
="<?php echo $PMA_PHP_SELF . '?show=server_traffic&' . PMA_generate_common_url(); ?>" >
807 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" width
="16" height
="16" alt
="ajax clock" style
="display: none;" />
808 <?php
echo __('Refresh'); ?
>
810 <span
class="refreshList" style
="display:none;">
811 <label
for="id_trafficChartRefresh"><?php
echo __('Refresh rate: '); ?
></label
>
812 <?php
refreshList('trafficChartRefresh'); ?
>
815 <a
class="tabChart livetrafficLink" href
="#">
816 <?php
echo __('Live traffic chart'); ?
>
818 <a
class="tabChart liveconnectionsLink" href
="#">
819 <?php
echo __('Live conn./process chart'); ?
>
822 <div
class="tabInnerContent">
823 <?php
printServerTraffic(); ?
>
826 <div id
="statustabs_queries" class="clearfloat">
827 <div
class="buttonlinks jsfeature">
828 <a
class="tabRefresh" href
="<?php echo $PMA_PHP_SELF . '?show=query_statistics&' . PMA_generate_common_url(); ?>" >
829 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" width
="16" height
="16" alt
="ajax clock" style
="display: none;" />
830 <?php
echo __('Refresh'); ?
>
832 <span
class="refreshList" style
="display:none;">
833 <label
for="id_queryChartRefresh"><?php
echo __('Refresh rate: '); ?
></label
>
834 <?php
refreshList('queryChartRefresh'); ?
>
836 <a
class="tabChart livequeriesLink" href
="#">
837 <?php
echo __('Live query chart'); ?
>
840 <div
class="tabInnerContent">
841 <?php
printQueryStatistics(); ?
>
844 <div id
="statustabs_allvars" class="clearfloat">
845 <fieldset id
="tableFilter" class="jsfeature">
846 <legend
><?php
echo __('Filters'); ?
></legend
>
847 <div
class="buttonlinks">
848 <a
class="tabRefresh" href
="<?php echo $PMA_PHP_SELF . '?show=variables_table&' . PMA_generate_common_url(); ?>" >
849 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" width
="16" height
="16" alt
="ajax clock" style
="display: none;" />
850 <?php
echo __('Refresh'); ?
>
853 <div
class="formelement">
854 <label
for="filterText"><?php
echo __('Containing the word:'); ?
></label
>
855 <input name
="filterText" type
="text" id
="filterText" style
="vertical-align: baseline;" />
857 <div
class="formelement">
858 <input type
="checkbox" name
="filterAlert" id
="filterAlert" />
859 <label
for="filterAlert"><?php
echo __('Show only alert values'); ?
></label
>
861 <div
class="formelement">
862 <select id
="filterCategory" name
="filterCategory">
863 <option value
=''><?php
echo __('Filter by category...'); ?
></option
>
865 foreach ($sections as $section_id => $section_name) {
866 if (isset($categoryUsed[$section_id])) {
868 <option value
='<?php echo $section_id; ?>'><?php
echo $section_name; ?
></option
>
875 <div
class="formelement">
876 <input type
="checkbox" name
="dontFormat" id
="dontFormat" />
877 <label
for="dontFormat"><?php
echo __('Show unformatted values'); ?
></label
>
880 <div id
="linkSuggestions" class="defaultLinks" style
="display:none">
881 <p
class="notice"><?php
echo __('Related links:'); ?
>
883 foreach ($links as $section_name => $section_links) {
884 echo '<span class="status_' . $section_name . '"> ';
886 foreach ($section_links as $link_name => $link_url) {
890 if ('doc' == $link_name) {
891 echo PMA_showMySQLDocu($link_url, $link_url);
893 echo '<a href="' . $link_url . '">' . $link_name . '</a>';
899 unset($link_url, $link_name, $i);
903 <div
class="tabInnerContent">
904 <?php
printVariablesTable(); ?
>
908 <div id
="statustabs_charting" class="jsfeature">
909 <?php
printMonitor(); ?
>
912 <div id
="statustabs_advisor" class="jsfeature">
913 <div
class="tabLinks">
914 <?php
echo PMA_getImage('play.png'); ?
> <a href
="#startAnalyzer"><?php
echo __('Run analyzer'); ?
></a
>
915 <?php
echo PMA_getImage('b_help.png'); ?
> <a href
="#openAdvisorInstructions"><?php
echo __('Instructions'); ?
></a
>
917 <div
class="tabInnerContent clearfloat">
919 <div id
="advisorInstructionsDialog" style
="display:none;">
922 echo __('The Advisor system can provide recommendations on server variables by analyzing the server status variables.');
924 echo __('Do note however that this system provides recommendations based on simple calculations and by rule of thumb which may not necessarily apply to your system.');
926 echo __('Prior to changing any of the configuration, be sure to know what you are changing (by reading the documentation) and how to undo the change. Wrong tuning can have a very negative effect on performance.');
928 echo __('The best way to tune your system would be to change only one setting at a time, observe or benchmark your database, and undo the change if there was no clearly measurable improvement.');
938 function printQueryStatistics()
940 global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
942 $hour_factor = 3600 / $server_status['Uptime'];
944 $total_queries = array_sum($used_queries);
947 <h3 id
="serverstatusqueries">
949 /* l10n: Questions is the name of a MySQL Status variable */
950 echo sprintf(__('Questions since startup: %s'), PMA_formatNumber($total_queries, 0)) . ' ';
951 echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
956 echo 'ø ' . __('per hour') . ': ';
957 echo PMA_formatNumber($total_queries * $hour_factor, 0);
960 echo 'ø ' . __('per minute') . ': ';
961 echo PMA_formatNumber($total_queries * 60 / $server_status['Uptime'], 0);
964 if ($total_queries / $server_status['Uptime'] >= 1) {
965 echo 'ø ' . __('per second') . ': ';
966 echo PMA_formatNumber($total_queries / $server_status['Uptime'], 0);
973 // reverse sort by value to show most used statements first
974 arsort($used_queries);
977 $count_displayed_rows = 0;
978 $perc_factor = 100 / $total_queries; //(- $server_status['Connections']);
982 <table id
="serverstatusqueriesdetails" class="data sortable noclick">
983 <col
class="namecol" />
984 <col
class="valuecol" span
="3" />
986 <tr
><th
><?php
echo __('Statements'); ?
></th
>
988 /* l10n: # = Amount of queries */
992 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
999 $chart_json = array();
1000 $query_sum = array_sum($used_queries);
1002 foreach ($used_queries as $name => $value) {
1003 $odd_row = !$odd_row;
1005 // For the percentage column, use Questions - Connections, because
1006 // the number of connections is not an item of the Query types
1007 // but is included in Questions. Then the total of the percentages is 100.
1008 $name = str_replace(array('Com_', '_'), array('', ' '), $name);
1010 // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
1011 if ($value < $query_sum * 0.02 && count($chart_json)>6) {
1012 $other_sum +
= $value;
1014 $chart_json[$name] = $value;
1017 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
1018 <th
class="name"><?php
echo htmlspecialchars($name); ?
></th
>
1019 <td
class="value"><?php
echo htmlspecialchars(PMA_formatNumber($value, 5, 0, true)); ?
></td
>
1020 <td
class="value"><?php
echo
1021 htmlspecialchars(PMA_formatNumber($value * $hour_factor, 4, 1, true)); ?
></td
>
1022 <td
class="value"><?php
echo
1023 htmlspecialchars(PMA_formatNumber($value * $perc_factor, 0, 2)); ?
>%
</td
>
1031 <div id
="serverstatusquerieschart">
1032 <span style
="display:none;">
1034 if ($other_sum > 0) {
1035 $chart_json[__('Other')] = $other_sum;
1038 echo json_encode($chart_json);
1045 function printServerTraffic()
1047 global $server_status, $PMA_PHP_SELF;
1048 global $server_master_status, $server_slave_status, $replication_types;
1050 $hour_factor = 3600 / $server_status['Uptime'];
1053 * starttime calculation
1055 $start_time = PMA_DBI_fetch_value(
1056 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']
1062 __('Network traffic since startup: %s'),
1063 implode(' ', PMA_formatByteDown($server_status['Bytes_received'] +
$server_status['Bytes_sent'], 3, 1))
1071 __('This MySQL server has been running for %1$s. It started up on %2$s.'),
1072 PMA_timespanFormat($server_status['Uptime']),
1073 PMA_localisedDate($start_time)
1079 if ($server_master_status ||
$server_slave_status) {
1080 echo '<p class="notice">';
1081 if ($server_master_status && $server_slave_status) {
1082 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
1083 } elseif ($server_master_status) {
1084 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
1085 } elseif ($server_slave_status) {
1086 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
1089 echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
1093 /* if the server works as master or slave in replication process, display useful information */
1094 if ($server_master_status ||
$server_slave_status) {
1096 <hr
class="clearfloat" />
1098 <h3
><a name
="replication"></a
><?php
echo __('Replication status'); ?
></h3
>
1101 foreach ($replication_types as $type) {
1102 if ($
{"server_{$type}_status"}) {
1103 PMA_replication_print_status_table($type);
1110 <table id
="serverstatustraffic" class="data noclick">
1113 <th colspan
="2"><?php
echo __('Traffic') . ' ' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?
></th
>
1114 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
1119 <th
class="name"><?php
echo __('Received'); ?
></th
>
1120 <td
class="value"><?php
echo
1122 ' ', PMA_formatByteDown($server_status['Bytes_received'], 3, 1)
1124 <td
class="value"><?php
echo
1126 ' ', PMA_formatByteDown($server_status['Bytes_received'] * $hour_factor, 3, 1)
1130 <th
class="name"><?php
echo __('Sent'); ?
></th
>
1131 <td
class="value"><?php
echo
1133 ' ', PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)
1135 <td
class="value"><?php
echo
1137 ' ', PMA_formatByteDown($server_status['Bytes_sent'] * $hour_factor, 3, 1)
1141 <th
class="name"><?php
echo __('Total'); ?
></th
>
1142 <td
class="value"><?php
echo
1146 $server_status['Bytes_received'] +
$server_status['Bytes_sent'], 3, 1
1149 <td
class="value"><?php
echo
1153 ($server_status['Bytes_received'] +
$server_status['Bytes_sent'])
1154 * $hour_factor, 3, 1
1161 <table id
="serverstatusconnections" class="data noclick">
1164 <th colspan
="2"><?php
echo __('Connections'); ?
></th
>
1165 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
1171 <th
class="name"><?php
echo __('max. concurrent connections'); ?
></th
>
1172 <td
class="value"><?php
echo
1173 PMA_formatNumber($server_status['Max_used_connections'], 0); ?
> </td
>
1174 <td
class="value">--- </td
>
1175 <td
class="value">--- </td
>
1178 <th
class="name"><?php
echo __('Failed attempts'); ?
></th
>
1179 <td
class="value"><?php
echo
1180 PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?
></td
>
1181 <td
class="value"><?php
echo
1183 $server_status['Aborted_connects'] * $hour_factor, 4, 2, true
1185 <td
class="value"><?php
echo
1186 $server_status['Connections'] > 0
1188 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
1194 <th
class="name"><?php
echo __('Aborted'); ?
></th
>
1195 <td
class="value"><?php
echo
1196 PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?
></td
>
1197 <td
class="value"><?php
echo
1199 $server_status['Aborted_clients'] * $hour_factor, 4, 2, true
1201 <td
class="value"><?php
echo
1202 $server_status['Connections'] > 0
1204 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
1210 <th
class="name"><?php
echo __('Total'); ?
></th
>
1211 <td
class="value"><?php
echo
1212 PMA_formatNumber($server_status['Connections'], 4, 0); ?
></td
>
1213 <td
class="value"><?php
echo
1215 $server_status['Connections'] * $hour_factor, 4, 2
1217 <td
class="value"><?php
echo
1218 PMA_formatNumber(100, 0, 2); ?
>%
</td
>
1224 $url_params = array();
1226 $show_full_sql = ! empty($_REQUEST['full']);
1227 if ($show_full_sql) {
1228 $url_params['full'] = 1;
1229 $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
1231 $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
1234 $sql_query = "SELECT
1239 p.command AS Command,
1242 " . ($show_full_sql ?
's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info
1243 FROM data_dictionary.PROCESSLIST p
1244 " . ($show_full_sql ?
'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
1246 $sql_query = $show_full_sql
1247 ?
'SHOW FULL PROCESSLIST'
1248 : 'SHOW PROCESSLIST';
1250 $result = PMA_DBI_query($sql_query);
1256 <table id
="tableprocesslist" class="data clearfloat noclick">
1259 <th
><?php
echo __('Processes'); ?
></th
>
1260 <th
><?php
echo __('ID'); ?
></th
>
1261 <th
><?php
echo __('User'); ?
></th
>
1262 <th
><?php
echo __('Host'); ?
></th
>
1263 <th
><?php
echo __('Database'); ?
></th
>
1264 <th
><?php
echo __('Command'); ?
></th
>
1265 <th
><?php
echo __('Time'); ?
></th
>
1266 <th
><?php
echo __('Status'); ?
></th
>
1268 echo __('SQL query');
1269 if (! PMA_DRIZZLE
) {
1271 <a href
="<?php echo $full_text_link; ?>"
1272 title
="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>">
1273 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?>text.png"
1274 alt
="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>" />
1283 while ($process = PMA_DBI_fetch_assoc($result)) {
1284 $url_params['kill'] = $process['Id'];
1285 $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
1287 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
1288 <td
><a href
="<?php echo $kill_process ; ?>"><?php
echo __('Kill'); ?
></a
></td
>
1289 <td
class="value"><?php
echo $process['Id']; ?
></td
>
1290 <td
><?php
echo $process['User']; ?
></td
>
1291 <td
><?php
echo $process['Host']; ?
></td
>
1292 <td
><?php
echo ((! isset($process['db']) ||
! strlen($process['db'])) ?
'<i>' . __('None') . '</i>' : $process['db']); ?
></td
>
1293 <td
><?php
echo $process['Command']; ?
></td
>
1294 <td
class="value"><?php
echo $process['Time']; ?
></td
>
1295 <td
><?php
echo (empty($process['State']) ?
'---' : $process['State']); ?
></td
>
1298 if (empty($process['Info'])) {
1301 if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
1302 echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
1304 echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
1311 $odd_row = ! $odd_row;
1319 function printVariablesTable()
1321 global $server_status, $server_variables, $allocationMap, $links;
1323 * Messages are built using the message name
1325 $strShowStatus = array(
1326 'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
1327 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
1328 'Binlog_cache_disk_use' => __('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.'),
1329 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
1330 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
1331 'Created_tmp_disk_tables' => __('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.'),
1332 'Created_tmp_files' => __('How many temporary files mysqld has created.'),
1333 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
1334 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
1335 'Delayed_insert_threads' => __('The number of INSERT DELAYED handler threads in use. Every different table on which one uses INSERT DELAYED gets its own thread.'),
1336 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
1337 'Flush_commands' => __('The number of executed FLUSH statements.'),
1338 'Handler_commit' => __('The number of internal COMMIT statements.'),
1339 'Handler_delete' => __('The number of times a row was deleted from a table.'),
1340 'Handler_discover' => __('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.'),
1341 'Handler_read_first' => __('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.'),
1342 'Handler_read_key' => __('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.'),
1343 'Handler_read_next' => __('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.'),
1344 'Handler_read_prev' => __('The number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.'),
1345 'Handler_read_rnd' => __('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.'),
1346 'Handler_read_rnd_next' => __('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.'),
1347 'Handler_rollback' => __('The number of internal ROLLBACK statements.'),
1348 'Handler_update' => __('The number of requests to update a row in a table.'),
1349 'Handler_write' => __('The number of requests to insert a row in a table.'),
1350 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'),
1351 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'),
1352 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'),
1353 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'),
1354 'Innodb_buffer_pool_pages_latched' => __('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.'),
1355 'Innodb_buffer_pool_pages_misc' => __('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.'),
1356 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'),
1357 'Innodb_buffer_pool_read_ahead_rnd' => __('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.'),
1358 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'),
1359 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'),
1360 'Innodb_buffer_pool_reads' => __('The number of logical reads that InnoDB could not satisfy from buffer pool and had to do a single-page read.'),
1361 'Innodb_buffer_pool_wait_free' => __('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.'),
1362 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'),
1363 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'),
1364 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'),
1365 'Innodb_data_pending_reads' => __('The current number of pending reads.'),
1366 'Innodb_data_pending_writes' => __('The current number of pending writes.'),
1367 'Innodb_data_read' => __('The amount of data read so far, in bytes.'),
1368 'Innodb_data_reads' => __('The total number of data reads.'),
1369 'Innodb_data_writes' => __('The total number of data writes.'),
1370 'Innodb_data_written' => __('The amount of data written so far, in bytes.'),
1371 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'),
1372 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'),
1373 'Innodb_log_waits' => __('The number of waits we had because log buffer was too small and we had to wait for it to be flushed before continuing.'),
1374 'Innodb_log_write_requests' => __('The number of log write requests.'),
1375 'Innodb_log_writes' => __('The number of physical writes to the log file.'),
1376 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'),
1377 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'),
1378 'Innodb_os_log_pending_writes' => __('Pending log file writes.'),
1379 'Innodb_os_log_written' => __('The number of bytes written to the log file.'),
1380 'Innodb_pages_created' => __('The number of pages created.'),
1381 'Innodb_page_size' => __('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.'),
1382 'Innodb_pages_read' => __('The number of pages read.'),
1383 'Innodb_pages_written' => __('The number of pages written.'),
1384 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'),
1385 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'),
1386 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'),
1387 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'),
1388 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'),
1389 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'),
1390 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'),
1391 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'),
1392 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'),
1393 'Key_blocks_not_flushed' => __('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.'),
1394 'Key_blocks_unused' => __('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.'),
1395 'Key_blocks_used' => __('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.'),
1396 'Key_buffer_fraction_%' => __('Percentage of used key cache (calculated value)'),
1397 'Key_read_requests' => __('The number of requests to read a key block from the cache.'),
1398 'Key_reads' => __('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.'),
1399 'Key_read_ratio_%' => __('Key cache miss calculated as rate of physical reads compared to read requests (calculated value)'),
1400 'Key_write_requests' => __('The number of requests to write a key block to the cache.'),
1401 'Key_writes' => __('The number of physical writes of a key block to disk.'),
1402 'Key_write_ratio_%' => __('Percentage of physical writes compared to write requests (calculated value)'),
1403 'Last_query_cost' => __('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.'),
1404 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'),
1405 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'),
1406 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'),
1407 'Open_files' => __('The number of files that are open.'),
1408 'Open_streams' => __('The number of streams that are open (used mainly for logging).'),
1409 'Open_tables' => __('The number of tables that are open.'),
1410 'Qcache_free_blocks' => __('The number of free memory blocks in query cache. High numbers can indicate fragmentation issues, which may be solved by issuing a FLUSH QUERY CACHE statement.'),
1411 'Qcache_free_memory' => __('The amount of free memory for query cache.'),
1412 'Qcache_hits' => __('The number of cache hits.'),
1413 'Qcache_inserts' => __('The number of queries added to the cache.'),
1414 'Qcache_lowmem_prunes' => __('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.'),
1415 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'),
1416 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'),
1417 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'),
1418 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'),
1419 'Select_full_join' => __('The number of joins that do not use indexes. If this value is not 0, you should carefully check the indexes of your tables.'),
1420 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'),
1421 'Select_range_check' => __('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.)'),
1422 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'),
1423 'Select_scan' => __('The number of joins that did a full scan of the first table.'),
1424 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'),
1425 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'),
1426 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'),
1427 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'),
1428 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'),
1429 'Sort_merge_passes' => __('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.'),
1430 'Sort_range' => __('The number of sorts that were done with ranges.'),
1431 'Sort_rows' => __('The number of sorted rows.'),
1432 'Sort_scan' => __('The number of sorts that were done by scanning the table.'),
1433 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'),
1434 'Table_locks_waited' => __('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.'),
1435 'Threads_cached' => __('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.'),
1436 'Threads_connected' => __('The number of currently open connections.'),
1437 'Threads_created' => __('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.)'),
1438 'Threads_cache_hitrate_%' => __('Thread cache hit rate (calculated value)'),
1439 'Threads_running' => __('The number of threads that are not sleeping.')
1443 * define some alerts
1445 // name => max value before alert
1448 // variable => max value
1449 'Aborted_clients' => 0,
1450 'Aborted_connects' => 0,
1452 'Binlog_cache_disk_use' => 0,
1454 'Created_tmp_disk_tables' => 0,
1456 'Handler_read_rnd' => 0,
1457 'Handler_read_rnd_next' => 0,
1459 'Innodb_buffer_pool_pages_dirty' => 0,
1460 'Innodb_buffer_pool_reads' => 0,
1461 'Innodb_buffer_pool_wait_free' => 0,
1462 'Innodb_log_waits' => 0,
1463 'Innodb_row_lock_time_avg' => 10, // ms
1464 'Innodb_row_lock_time_max' => 50, // ms
1465 'Innodb_row_lock_waits' => 0,
1467 'Slow_queries' => 0,
1468 'Delayed_errors' => 0,
1469 'Select_full_join' => 0,
1470 'Select_range_check' => 0,
1471 'Sort_merge_passes' => 0,
1472 'Opened_tables' => 0,
1473 'Table_locks_waited' => 0,
1474 'Qcache_lowmem_prunes' => 0,
1476 'Qcache_free_blocks' => isset($server_status['Qcache_total_blocks']) ?
$server_status['Qcache_total_blocks'] / 5 : 0,
1477 'Slow_launch_threads' => 0,
1479 // depends on Key_read_requests
1480 // normaly lower then 1:0.01
1481 'Key_reads' => isset($server_status['Key_read_requests']) ?
(0.01 * $server_status['Key_read_requests']) : 0,
1482 // depends on Key_write_requests
1483 // normaly nearly 1:1
1484 'Key_writes' => isset($server_status['Key_write_requests']) ?
(0.9 * $server_status['Key_write_requests']) : 0,
1486 'Key_buffer_fraction' => 0.5,
1488 // alert if more than 95% of thread cache is in use
1489 'Threads_cached' => isset($server_variables['thread_cache_size']) ?
0.95 * $server_variables['thread_cache_size'] : 0
1492 // variable => min value
1493 //'Handler read key' => '> ',
1497 <table
class="data sortable noclick" id
="serverstatusvariables">
1498 <col
class="namecol" />
1499 <col
class="valuecol" />
1500 <col
class="descrcol" />
1503 <th
><?php
echo __('Variable'); ?
></th
>
1504 <th
><?php
echo __('Value'); ?
></th
>
1505 <th
><?php
echo __('Description'); ?
></th
>
1512 foreach ($server_status as $name => $value) {
1513 $odd_row = !$odd_row;
1515 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; echo isset($allocationMap[$name])?' s_' . $allocationMap[$name]:''; ?>">
1516 <th
class="name"><?php
1517 echo htmlspecialchars(str_replace('_', ' ', $name));
1518 /* Fields containing % are calculated, they can not be described in MySQL documentation */
1519 if (strpos($name, '%') === false) {
1520 echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name);
1524 <td
class="value"><span
class="formatted"><?php
1525 if (isset($alerts[$name])) {
1526 if ($value > $alerts[$name]) {
1527 echo '<span class="attention">';
1529 echo '<span class="allfine">';
1532 if ('%' === substr($name, -1, 1)) {
1533 echo htmlspecialchars(PMA_formatNumber($value, 0, 2)) . ' %';
1534 } elseif (strpos($name, 'Uptime') !== false) {
1535 echo htmlspecialchars(PMA_timespanFormat($value));
1536 } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
1537 echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
1538 } elseif (is_numeric($value) && $value == (int) $value) {
1539 echo htmlspecialchars(PMA_formatNumber($value, 3, 0));
1540 } elseif (is_numeric($value)) {
1541 echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
1543 echo htmlspecialchars($value);
1545 if (isset($alerts[$name])) {
1548 ?
></span
><span style
="display:none;" class="original"><?php
echo $value; ?
></span
>
1552 if (isset($strShowStatus[$name ])) {
1553 echo $strShowStatus[$name];
1556 if (isset($links[$name])) {
1557 foreach ($links[$name] as $link_name => $link_url) {
1558 if ('doc' == $link_name) {
1559 echo PMA_showMySQLDocu($link_url, $link_url);
1561 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
1565 unset($link_url, $link_name);
1578 function printMonitor()
1580 global $server_status, $server_db_isLocal;
1582 <div
class="tabLinks" style
="display:none;">
1583 <a href
="#pauseCharts">
1584 <?php
echo PMA_getImage('play.png'); ?
>
1585 <?php
echo __('Start Monitor'); ?
>
1587 <a href
="#settingsPopup" class="popupLink" style
="display:none;">
1588 <?php
echo PMA_getImage('s_cog.png'); ?
>
1589 <?php
echo __('Settings'); ?
>
1591 <?php
if (! PMA_DRIZZLE
) { ?
>
1592 <a href
="#monitorInstructionsDialog">
1593 <?php
echo PMA_getImage('b_help.png'); ?
>
1594 <?php
echo __('Instructions/Setup'); ?
>
1597 <a href
="#endChartEditMode" style
="display:none;">
1598 <?php
echo PMA_getImage('s_okay.png'); ?
>
1599 <?php
echo __('Done rearranging/editing charts'); ?
>
1603 <div
class="popupContent settingsPopup">
1604 <a href
="#addNewChart">
1605 <?php
echo PMA_getImage('b_chart.png'); ?
>
1606 <?php
echo __('Add chart'); ?
>
1608 <a href
="#rearrangeCharts"><?php
echo PMA_getImage('b_tblops.png'); ?
><?php
echo __('Rearrange/edit charts'); ?
></a
>
1609 <div
class="clearfloat paddingtop"></div
>
1610 <div
class="floatleft">
1612 echo __('Refresh rate') . '<br />';
1613 refreshList('gridChartRefresh', 5, Array(2, 3, 4, 5, 10, 20, 40, 60, 120, 300, 600, 1200));
1616 <div
class="floatleft">
1617 <?php
echo __('Chart columns'); ?
> <br
/>
1618 <select name
="chartColumns">
1632 <div
class="clearfloat paddingtop">
1633 <b
><?php
echo __('Chart arrangement'); ?
></b
> <?php
echo PMA_showHint(__('The arrangement of the charts is stored to the browsers local storage. You may want to export it if you have a complicated set up.')); ?
><br
/>
1634 <a href
="#importMonitorConfig"><?php
echo __('Import'); ?
></a
> 
; 
;<a href
="#exportMonitorConfig"><?php
echo __('Export'); ?
></a
> 
; 
;<a href
="#clearMonitorConfig"><?php
echo __('Reset to default'); ?
></a
>
1638 <div id
="monitorInstructionsDialog" title
="<?php echo __('Monitor Instructions'); ?>" style
="display:none;">
1639 <?php
echo __('The phpMyAdmin Monitor can assist you in optimizing the server configuration and track down time intensive queries. For the latter you will need to set log_output to \'TABLE\' and have either the slow_query_log or general_log enabled. Note however, that the general_log produces a lot of data and increases server load by up to 15%'); ?
>
1640 <?php
if (PMA_MYSQL_INT_VERSION
< 50106) { ?
>
1642 <?php
echo PMA_getImage('s_attention.png'); ?
>
1644 echo __('Unfortunately your Database server does not support logging to table, which is a requirement for analyzing the database logs with phpMyAdmin. Logging to table is supported by MySQL 5.1.6 and onwards. You may still use the server charting features however.');
1651 <img
class="ajaxIcon" src
="<?php echo $GLOBALS['pmaThemeImage']; ?>ajax_clock_small.gif" alt
="Loading" />
1652 <div
class="ajaxContent"></div
>
1653 <div
class="monitorUse" style
="display:none;">
1657 echo __('Using the monitor:');
1658 echo '</strong><p>';
1659 echo __('Your browser will refresh all displayed charts in a regular interval. You may add charts and change the refresh rate under \'Settings\', or remove any chart using the cog icon on each respective chart.');
1661 echo __('To display queries from the logs, select the relevant time span on any chart by holding down the left mouse button and panning over the chart. Once confirmed, this will load a table of grouped queries, there you may click on any occuring SELECT statements to further analyze them.');
1665 <?php
echo PMA_getImage('s_attention.png'); ?
>
1668 echo __('Please note:');
1669 echo '</strong><br />';
1670 echo __('Enabling the general_log may increase the server load by 5-15%. Also be aware that generating statistics from the logs is a load intensive task, so it is advisable to select only a small time span and to disable the general_log and empty its table once monitoring is not required any more.');
1677 <div id
="addChartDialog" title
="<?php echo __('Add chart'); ?>" style
="display:none;">
1678 <div id
="tabGridVariables">
1679 <p
><input type
="text" name
="chartTitle" value
="<?php echo __('Chart Title'); ?>" /></p
>
1681 <input type
="radio" name
="chartType" value
="preset" id
="chartPreset" />
1682 <label
for="chartPreset"><?php
echo __('Preset chart'); ?
></label
>
1683 <select name
="presetCharts"></select
><br
/>
1685 <input type
="radio" name
="chartType" value
="variable" id
="chartStatusVar" checked
="checked" />
1686 <label
for="chartStatusVar"><?php
echo __('Status variable(s)'); ?
></label
><br
/>
1687 <div id
="chartVariableSettings">
1688 <label
for="chartSeries"><?php
echo __('Select series:'); ?
></label
><br
/>
1689 <select id
="chartSeries" name
="varChartList" size
="1">
1690 <option
><?php
echo __('Commonly monitored'); ?
></option
>
1691 <option
>Processes
</option
>
1692 <option
>Questions
</option
>
1693 <option
>Connections
</option
>
1694 <option
>Bytes_sent
</option
>
1695 <option
>Bytes_received
</option
>
1696 <option
>Threads_connected
</option
>
1697 <option
>Created_tmp_disk_tables
</option
>
1698 <option
>Handler_read_first
</option
>
1699 <option
>Innodb_buffer_pool_wait_free
</option
>
1700 <option
>Key_reads
</option
>
1701 <option
>Open_tables
</option
>
1702 <option
>Select_full_join
</option
>
1703 <option
>Slow_queries
</option
>
1705 <label
for="variableInput"><?php
echo __('or type variable name:'); ?
> </label
>
1706 <input type
="text" name
="variableInput" id
="variableInput" />
1708 <input type
="checkbox" name
="differentialValue" id
="differentialValue" value
="differential" checked
="checked" />
1709 <label
for="differentialValue"><?php
echo __('Display as differential value'); ?
></label
><br
/>
1710 <input type
="checkbox" id
="useDivisor" name
="useDivisor" value
="1" />
1711 <label
for="useDivisor"><?php
echo __('Apply a divisor'); ?
></label
>
1712 <span
class="divisorInput" style
="display:none;">
1713 <input type
="text" name
="valueDivisor" size
="4" value
="1" />
1714 (<a href
="#kibDivisor"><?php
echo __('KiB'); ?
></a
>, <a href
="#mibDivisor"><?php
echo __('MiB'); ?
></a
>)
1717 <input type
="checkbox" id
="useUnit" name
="useUnit" value
="1" />
1718 <label
for="useUnit"><?php
echo __('Append unit to data values'); ?
></label
>
1720 <span
class="unitInput" style
="display:none;">
1721 <input type
="text" name
="valueUnit" size
="4" value
="" />
1724 <a href
="#submitAddSeries"><b
><?php
echo __('Add this series'); ?
></b
></a
>
1725 <span id
="clearSeriesLink" style
="display:none;">
1726 |
<a href
="#submitClearSeries"><?php
echo __('Clear series'); ?
></a
>
1729 <?php
echo __('Series in Chart:'); ?
><br
/>
1730 <span id
="seriesPreview">
1731 <i
><?php
echo __('None'); ?
></i
>
1737 <!-- For generic
use -->
1738 <div id
="emptyDialog" title
="Dialog" style
="display:none;">
1741 <?php
if (! PMA_DRIZZLE
) { ?
>
1742 <div id
="logAnalyseDialog" title
="<?php echo __('Log statistics'); ?>" style
="display:none;">
1743 <p
> <?php
echo __('Selected time range:'); ?
>
1744 <input type
="text" name
="dateStart" class="datetimefield" value
="" /> -
1745 <input type
="text" name
="dateEnd" class="datetimefield" value
="" /></p
>
1746 <input type
="checkbox" id
="limitTypes" value
="1" checked
="checked" />
1747 <label
for="limitTypes">
1748 <?php
echo __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements'); ?
>
1751 <input type
="checkbox" id
="removeVariables" value
="1" checked
="checked" />
1752 <label
for="removeVariables">
1753 <?php
echo __('Remove variable data in INSERT statements for better grouping'); ?
>
1758 echo __('Choose from which log you want the statistics to be generated from.');
1760 echo __('Results are grouped by query text.');
1765 <div id
="queryAnalyzerDialog" title
="<?php echo __('Query analyzer'); ?>" style
="display:none;">
1766 <textarea id
="sqlquery"> </textarea
>
1768 <div
class="placeHolder"></div
>
1772 <table
class="clearfloat" id
="chartGrid">
1779 <script type
="text/javascript">
1780 variableNames
= [ <?php
1782 foreach ($server_status as $name=>$value) {
1783 if (is_numeric($value)) {
1787 echo "'" . $name . "'";
1795 /* Builds a <select> list for refresh rates */
1796 function refreshList($name, $defaultRate=5, $refreshRates=Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600))
1799 <select name
="<?php echo $name; ?>" id
="id_<?php echo $name; ?>">
1801 foreach ($refreshRates as $rate) {
1802 $selected = ($rate == $defaultRate)?
' selected="selected"':'';
1805 echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d second', '%d seconds', $rate), $rate) . '</option>';
1807 echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d minute', '%d minutes', $rate/60), $rate/60) . '</option>';
1816 * cleanup of some deprecated values
1818 * @param array &$server_status
1820 function cleanDeprecated(&$server_status)
1822 $deprecated = array(
1823 'Com_prepare_sql' => 'Com_stmt_prepare',
1824 'Com_execute_sql' => 'Com_stmt_execute',
1825 'Com_dealloc_sql' => 'Com_stmt_close',
1828 foreach ($deprecated as $old => $new) {
1829 if (isset($server_status[$old]) && isset($server_status[$new])) {
1830 unset($server_status[$old]);
1838 require 'libraries/footer.inc.php';