Translation update done using Pootle.
[phpmyadmin.git] / server_status.php
blob1dd4852369491e065c0abad9201197c61613b8ac
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);
18 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
19 $GLOBALS['is_header_sent'] = true;
22 require_once './libraries/common.inc.php';
24 /**
25 * Ajax request
28 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
29 // Send with correct charset
30 header('Content-Type: text/html; charset=UTF-8');
32 // real-time charting data
33 if (isset($_REQUEST['chart_data'])) {
34 switch($_REQUEST['type']) {
35 // Process and Connections realtime chart
36 case 'proc':
37 $c = PMA_DBI_fetch_result("SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1);
38 $result = PMA_DBI_query('SHOW PROCESSLIST');
39 $num_procs = PMA_DBI_num_rows($result);
41 $ret = array(
42 'x' => microtime(true) * 1000,
43 'y_proc' => $num_procs,
44 'y_conn' => $c['Connections']
47 exit(json_encode($ret));
49 // Query realtime chart
50 case 'queries':
51 $queries = PMA_DBI_fetch_result(
52 "SHOW GLOBAL STATUS
53 WHERE (Variable_name LIKE 'Com_%' OR Variable_name = 'Questions')
54 AND Value > 0'", 0, 1);
55 cleanDeprecated($queries);
56 // admin commands are not queries
57 unset($queries['Com_admin_commands']);
58 $questions = $queries['Questions'];
59 unset($queries['Questions']);
61 //$sum=array_sum($queries);
62 $ret = array(
63 'x' => microtime(true) * 1000,
64 'y' => $questions,
65 'pointInfo' => $queries
68 exit(json_encode($ret));
70 // Traffic realtime chart
71 case 'traffic':
72 $traffic = PMA_DBI_fetch_result(
73 "SHOW GLOBAL STATUS
74 WHERE Variable_name = 'Bytes_received'
75 OR Variable_name = 'Bytes_sent'", 0, 1);
77 $ret = array(
78 'x' => microtime(true) * 1000,
79 'y_sent' => $traffic['Bytes_sent'],
80 'y_received' => $traffic['Bytes_received']
83 exit(json_encode($ret));
85 // Data for the monitor
86 case 'chartgrid':
87 $ret = json_decode($_REQUEST['requiredData'], true);
88 $statusVars = array();
89 $serverVars = array();
90 $sysinfo = $cpuload = $memory = 0;
91 $pName = '';
93 /* Accumulate all required variables and data */
94 // For each chart
95 foreach ($ret as $chart_id => $chartNodes) {
96 // For each data series
97 foreach ($chartNodes as $node_id => $nodeDataPoints) {
98 // For each data point in the series (usually just 1)
99 foreach ($nodeDataPoints as $point_id => $dataPoint) {
100 $pName = $dataPoint['name'];
102 switch ($dataPoint['type']) {
103 /* We only collect the status and server variables here to
104 * read them all in one query, and only afterwards assign them.
105 * Also do some white list filtering on the names
107 case 'servervar':
108 if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
109 $serverVars[] = $pName;
111 break;
113 case 'statusvar':
114 if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
115 $statusVars[] = $pName;
117 break;
119 case 'proc':
120 $result = PMA_DBI_query('SHOW PROCESSLIST');
121 $ret[$chart_id][$node_id][$point_id]['value'] = PMA_DBI_num_rows($result);
122 break;
124 case 'cpu':
125 if (!$sysinfo) {
126 require_once('libraries/sysinfo.lib.php');
127 $sysinfo = getSysInfo();
129 if (!$cpuload) {
130 $cpuload = $sysinfo->loadavg();
133 if (PHP_OS == 'Linux') {
134 $ret[$chart_id][$node_id][$point_id]['idle'] = $cpuload['idle'];
135 $ret[$chart_id][$node_id][$point_id]['busy'] = $cpuload['busy'];
136 } else
137 $ret[$chart_id][$node_id][$point_id]['value'] = $cpuload['loadavg'];
139 break;
141 case 'memory':
142 if (!$sysinfo) {
143 require_once('libraries/sysinfo.lib.php');
144 $sysinfo = getSysInfo();
146 if (!$memory) {
147 $memory = $sysinfo->memory();
150 $ret[$chart_id][$node_id][$point_id]['value'] = $memory[$pName];
151 break;
152 } /* switch */
153 } /* foreach */
154 } /* foreach */
155 } /* foreach */
157 // Retrieve all required status variables
158 if (count($statusVars)) {
159 $statusVarValues = PMA_DBI_fetch_result(
160 "SHOW GLOBAL STATUS
161 WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1);
162 } else {
163 $statusVarValues = array();
166 // Retrieve all required server variables
167 if (count($serverVars)) {
168 $serverVarValues = PMA_DBI_fetch_result(
169 "SHOW GLOBAL VARIABLES
170 WHERE Variable_name='" . implode("' OR Variable_name='", $serverVars) . "'", 0, 1);
171 } else {
172 $serverVarValues = array();
175 // ...and now assign them
176 foreach ($ret as $chart_id => $chartNodes) {
177 foreach ($chartNodes as $node_id => $nodeDataPoints) {
178 foreach ($nodeDataPoints as $point_id => $dataPoint) {
179 switch($dataPoint['type']) {
180 case 'statusvar':
181 $ret[$chart_id][$node_id][$point_id]['value'] = $statusVarValues[$dataPoint['name']];
182 break;
183 case 'servervar':
184 $ret[$chart_id][$node_id][$point_id]['value'] = $serverVarValues[$dataPoint['name']];
185 break;
191 $ret['x'] = microtime(true) * 1000;
193 exit(json_encode($ret));
197 if (isset($_REQUEST['log_data'])) {
198 if (PMA_MYSQL_INT_VERSION < 50106) {
199 /* FIXME: why this? */
200 exit('""');
203 $start = intval($_REQUEST['time_start']);
204 $end = intval($_REQUEST['time_end']);
206 if ($_REQUEST['type'] == 'slow') {
207 $q = 'SELECT start_time, user_host, Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, '.
208 'SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined, db, sql_text, COUNT(sql_text) AS \'#\' '.
209 'FROM `mysql`.`slow_log` WHERE start_time > FROM_UNIXTIME(' . $start . ') '.
210 'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
212 $result = PMA_DBI_try_query($q);
214 $return = array('rows' => array(), 'sum' => array());
215 $type = '';
217 while ($row = PMA_DBI_fetch_assoc($result)) {
218 $type = strtolower(substr($row['sql_text'], 0, strpos($row['sql_text'], ' ')));
220 switch($type) {
221 case 'insert':
222 case 'update':
223 // Cut off big inserts and updates, but append byte count therefor
224 if (strlen($row['sql_text']) > 220) {
225 $row['sql_text'] = substr($row['sql_text'], 0, 200)
226 . '... ['
227 . implode(' ', PMA_formatByteDown(strlen($row['sql_text']), 2, 2))
228 . ']';
230 break;
231 default:
232 break;
235 if (!isset($return['sum'][$type])) {
236 $return['sum'][$type] = 0;
238 $return['sum'][$type] += $row['#'];
239 $return['rows'][] = $row;
242 $return['sum']['TOTAL'] = array_sum($return['sum']);
243 $return['numRows'] = count($return['rows']);
245 PMA_DBI_free_result($result);
247 exit(json_encode($return));
250 if ($_REQUEST['type'] == 'general') {
251 $limitTypes = (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes'])
252 ? 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
254 $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, server_id, argument, count(argument) as \'#\' '.
255 'FROM `mysql`.`general_log` WHERE command_type=\'Query\' '.
256 'AND event_time > FROM_UNIXTIME(' . $start . ') AND event_time < FROM_UNIXTIME(' . $end . ') '.
257 $limitTypes . 'GROUP by argument'; // HAVING count > 1';
259 $result = PMA_DBI_try_query($q);
261 $return = array('rows' => array(), 'sum' => array());
262 $type = '';
263 $insertTables = array();
264 $insertTablesFirst = -1;
265 $i = 0;
266 $removeVars = isset($_REQUEST['removeVariables']) && $_REQUEST['removeVariables'];
268 while ($row = PMA_DBI_fetch_assoc($result)) {
269 preg_match('/^(\w+)\s/', $row['argument'], $match);
270 $type = strtolower($match[1]);
272 if (!isset($return['sum'][$type])) {
273 $return['sum'][$type] = 0;
275 $return['sum'][$type] += $row['#'];
277 switch($type) {
278 case 'insert':
279 // Group inserts if selected
280 if ($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i', $row['argument'], $matches)) {
281 $insertTables[$matches[2]]++;
282 if ($insertTables[$matches[2]] > 1) {
283 $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
285 // Add a ... to the end of this query to indicate that there's been other queries
286 if ($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.') {
287 $return['rows'][$insertTablesFirst]['argument'] .= '<br/>...';
290 // Group this value, thus do not add to the result list
291 continue 2;
292 } else {
293 $insertTablesFirst = $i;
294 $insertTables[$matches[2]] += $row['#'] - 1;
297 // No break here
299 case 'update':
300 // Cut off big inserts and updates, but append byte count therefor
301 if (strlen($row['argument']) > 220) {
302 $row['argument'] = substr($row['argument'], 0, 200)
303 . '... ['
304 . implode(' ', PMA_formatByteDown(strlen($row['argument'])), 2, 2)
305 . ']';
307 break;
309 default: break;
312 $return['rows'][] = $row;
313 $i++;
316 $return['sum']['TOTAL'] = array_sum($return['sum']);
317 $return['numRows'] = count($return['rows']);
319 PMA_DBI_free_result($result);
321 exit(json_encode($return));
325 if (isset($_REQUEST['logging_vars'])) {
326 if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
327 $value = PMA_sqlAddslashes($_REQUEST['varValue']);
328 if (!is_numeric($value)) {
329 $value="'" . $value . "'";
332 if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])) {
333 PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value);
338 $loggingVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES WHERE Variable_name IN ("general_log","slow_query_log","long_query_time","log_output")', 0, 1);
339 exit(json_encode($loggingVars));
342 if (isset($_REQUEST['query_analyzer'])) {
343 $return = array();
345 if (strlen($_REQUEST['database'])) {
346 PMA_DBI_select_db($_REQUEST['database']);
349 if ($profiling = PMA_profilingSupported()) {
350 PMA_DBI_query('SET PROFILING=1;');
353 // Do not cache query
354 $query = preg_replace('/^(\s*SELECT)/i', '\\1 SQL_NO_CACHE', $_REQUEST['query']);
356 $result = PMA_DBI_try_query($query);
357 $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
359 $result = PMA_DBI_try_query('EXPLAIN ' . $query);
360 while ($row = PMA_DBI_fetch_assoc($result)) {
361 $return['explain'][] = $row;
364 // In case an error happened
365 $return['error'] = PMA_DBI_getError();
367 PMA_DBI_free_result($result);
369 if ($profiling) {
370 $return['profiling'] = array();
371 $result = PMA_DBI_try_query('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=1 ORDER BY seq');
372 while ($row = PMA_DBI_fetch_assoc($result)) {
373 $return['profiling'][]= $row;
375 PMA_DBI_free_result($result);
378 exit(json_encode($return));
381 if (isset($_REQUEST['advisor'])) {
382 include('libraries/Advisor.class.php');
383 $advisor = new Advisor();
384 exit(json_encode($advisor->run()));
390 * Replication library
392 require './libraries/replication.inc.php';
393 require_once './libraries/replication_gui.lib.php';
396 * JS Includes
399 $GLOBALS['js_include'][] = 'server_status.js';
400 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
401 $GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
402 $GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
403 // Charting
404 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
405 /* Files required for chart exporting */
406 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
407 /* < IE 9 doesn't support canvas natively */
408 if(PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
409 $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
411 $GLOBALS['js_include'][] = 'canvg/canvg.js';
414 * flush status variables if requested
416 if (isset($_REQUEST['flush'])) {
417 $_flush_commands = array(
418 'STATUS',
419 'TABLES',
420 'QUERY CACHE',
423 if (in_array($_REQUEST['flush'], $_flush_commands)) {
424 PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
426 unset($_flush_commands);
430 * Kills a selected process
432 if (!empty($_REQUEST['kill'])) {
433 if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
434 $message = PMA_Message::success(__('Thread %s was successfully killed.'));
435 } else {
436 $message = PMA_Message::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
438 $message->addParam($_REQUEST['kill']);
439 //$message->display();
445 * get status from server
447 $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
450 * for some calculations we require also some server settings
452 $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
455 * cleanup of some deprecated values
457 cleanDeprecated($server_status);
460 * calculate some values
462 // Key_buffer_fraction
463 if (isset($server_status['Key_blocks_unused'])
464 && isset($server_variables['key_cache_block_size'])
465 && isset($server_variables['key_buffer_size'])) {
466 $server_status['Key_buffer_fraction_%'] =
468 - $server_status['Key_blocks_unused']
469 * $server_variables['key_cache_block_size']
470 / $server_variables['key_buffer_size']
471 * 100;
472 } elseif (isset($server_status['Key_blocks_used'])
473 && isset($server_variables['key_buffer_size'])) {
474 $server_status['Key_buffer_fraction_%'] =
475 $server_status['Key_blocks_used']
476 * 1024
477 / $server_variables['key_buffer_size'];
480 // Ratio for key read/write
481 if (isset($server_status['Key_writes'])
482 && isset($server_status['Key_write_requests'])
483 && $server_status['Key_write_requests'] > 0) {
484 $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
487 if (isset($server_status['Key_reads'])
488 && isset($server_status['Key_read_requests'])
489 && $server_status['Key_read_requests'] > 0) {
490 $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
493 // Threads_cache_hitrate
494 if (isset($server_status['Threads_created'])
495 && isset($server_status['Connections'])
496 && $server_status['Connections'] > 0) {
498 $server_status['Threads_cache_hitrate_%'] =
499 100 - $server_status['Threads_created'] / $server_status['Connections'] * 100;
503 * split variables in sections
505 $allocations = array(
506 // variable name => section
507 // variable names match when they begin with the given string
509 'Com_' => 'com',
510 'Innodb_' => 'innodb',
511 'Ndb_' => 'ndb',
512 'Handler_' => 'handler',
513 'Qcache_' => 'qcache',
514 'Threads_' => 'threads',
515 'Slow_launch_threads' => 'threads',
517 'Binlog_cache_' => 'binlog_cache',
518 'Created_tmp_' => 'created_tmp',
519 'Key_' => 'key',
521 'Delayed_' => 'delayed',
522 'Not_flushed_delayed_rows' => 'delayed',
524 'Flush_commands' => 'query',
525 'Last_query_cost' => 'query',
526 'Slow_queries' => 'query',
527 'Queries' => 'query',
528 'Prepared_stmt_count' => 'query',
530 'Select_' => 'select',
531 'Sort_' => 'sort',
533 'Open_tables' => 'table',
534 'Opened_tables' => 'table',
535 'Open_table_definitions' => 'table',
536 'Opened_table_definitions' => 'table',
537 'Table_locks_' => 'table',
539 'Rpl_status' => 'repl',
540 'Slave_' => 'repl',
542 'Tc_' => 'tc',
544 'Ssl_' => 'ssl',
546 'Open_files' => 'files',
547 'Open_streams' => 'files',
548 'Opened_files' => 'files',
551 $sections = array(
552 // section => section name (description)
553 'com' => 'Com',
554 'query' => __('SQL query'),
555 'innodb' => 'InnoDB',
556 'ndb' => 'NDB',
557 'handler' => __('Handler'),
558 'qcache' => __('Query cache'),
559 'threads' => __('Threads'),
560 'binlog_cache' => __('Binary log'),
561 'created_tmp' => __('Temporary data'),
562 'delayed' => __('Delayed inserts'),
563 'key' => __('Key cache'),
564 'select' => __('Joins'),
565 'repl' => __('Replication'),
566 'sort' => __('Sorting'),
567 'table' => __('Tables'),
568 'tc' => __('Transaction coordinator'),
569 'files' => __('Files'),
570 'ssl' => 'SSL',
574 * define some needfull links/commands
576 // variable or section name => (name => url)
577 $links = array();
579 $links['table'][__('Flush (close) all tables')]
580 = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
581 $links['table'][__('Show open tables')]
582 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
583 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
585 if ($server_master_status) {
586 $links['repl'][__('Show slave hosts')]
587 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
588 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
589 $links['repl'][__('Show master status')] = '#replication_master';
591 if ($server_slave_status) {
592 $links['repl'][__('Show slave status')] = '#replication_slave';
595 $links['repl']['doc'] = 'replication';
597 $links['qcache'][__('Flush query cache')]
598 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
599 PMA_generate_common_url();
600 $links['qcache']['doc'] = 'query_cache';
602 //$links['threads'][__('Show processes')]
603 // = 'server_processlist.php?' . PMA_generate_common_url();
604 $links['threads']['doc'] = 'mysql_threads';
606 $links['key']['doc'] = 'myisam_key_cache';
608 $links['binlog_cache']['doc'] = 'binary_log';
610 $links['Slow_queries']['doc'] = 'slow_query_log';
612 $links['innodb'][__('Variables')]
613 = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
614 $links['innodb'][__('InnoDB Status')]
615 = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
616 PMA_generate_common_url();
617 $links['innodb']['doc'] = 'innodb';
620 // Variable to contain all com_ variables
621 $used_queries = array();
623 // Variable to map variable names to their respective section name
624 // (used for js category filtering)
625 $allocationMap = array();
627 // sort vars into arrays
628 foreach ($server_status as $name => $value) {
629 foreach ($allocations as $filter => $section) {
630 if (strpos($name, $filter) !== false) {
631 $allocationMap[$name] = $section;
632 if ($section == 'com' && $value > 0) {
633 $used_queries[$name] = $value;
635 break; // Only exits inner loop
640 if(PMA_DRIZZLE) {
641 $used_queries = PMA_DBI_fetch_result(
642 'SELECT * FROM data_dictionary.global_statements',
646 unset($used_queries['admin_commands']);
647 } else {
648 // admin commands are not queries (e.g. they include COM_PING,
649 // which is excluded from $server_status['Questions'])
650 unset($used_queries['Com_admin_commands']);
653 /* Ajax request refresh */
654 if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
655 switch($_REQUEST['show']) {
656 case 'query_statistics':
657 printQueryStatistics();
658 exit();
659 case 'server_traffic':
660 printServerTraffic();
661 exit();
662 case 'variables_table':
663 // Prints the variables table
664 printVariablesTable();
665 exit();
667 default:
668 break;
672 $server_db_isLocal = strtolower($cfg['Server']['host']) == 'localhost'
673 || $cfg['Server']['host'] == '127.0.0.1'
674 || $cfg['Server']['host'] == '::1';
676 PMA_AddJSVar(
677 'pma_token',
678 $_SESSION[' PMA_token ']
680 PMA_AddJSVar(
681 'url_query',
682 str_replace('&amp;', '&', PMA_generate_common_url($db))
684 PMA_AddJSVar(
685 'server_time_diff',
686 'new Date().getTime() - ' . (microtime(true) * 1000)
688 PMA_AddJSVar(
689 'server_os',
690 PHP_OS
692 PMA_AddJSVar(
693 'is_superuser',
694 PMA_isSuperuser()
696 PMA_AddJSVar(
697 'server_db_isLocal',
698 $server_db_isLocal
700 PMA_AddJSVar(
701 'profiling_docu',
702 PMA_showMySQLDocu('general-thread-states', 'general-thread-states')
704 PMA_AddJSVar(
705 'explain_docu',
706 PMA_showMySQLDocu('explain-output', 'explain-output')
710 * start output
714 * Does the common work
716 require './libraries/server_common.inc.php';
721 * Displays the links
723 require './libraries/server_links.inc.php';
726 <div id="serverstatus">
727 <h2><?php
729 * Displays the sub-page heading
731 if ($GLOBALS['cfg']['MainPageIconic']) {
732 echo '<img class="icon ic_s_status" src="themes/dot.gif" width="16" height="16" alt="" />';
735 echo __('Runtime Information');
737 ?></h2>
738 <div id="serverStatusTabs">
739 <ul>
740 <li><a href="#statustabs_traffic"><?php echo __('Server'); ?></a></li>
741 <li><a href="#statustabs_queries"><?php echo __('Query statistics'); ?></a></li>
742 <li><a href="#statustabs_allvars"><?php echo __('All status variables'); ?></a></li>
743 <li class="jsfeature"><a href="#statustabs_charting"><?php echo __('Monitor'); ?></a></li>
744 <li class="jsfeature"><a href="#statustabs_advisor"><?php echo __('Advisor'); ?></a></li>
745 </ul>
747 <div id="statustabs_traffic" class="clearfloat">
748 <div class="buttonlinks jsfeature">
749 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=server_traffic&amp;' . PMA_generate_common_url(); ?>" >
750 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
751 <?php echo __('Refresh'); ?>
752 </a>
753 <span class="refreshList" style="display:none;">
754 <label for="id_trafficChartRefresh"><?php echo __('Refresh rate: '); ?></label>
755 <?php refreshList('trafficChartRefresh'); ?>
756 </span>
758 <a class="tabChart livetrafficLink" href="#">
759 <?php echo __('Live traffic chart'); ?>
760 </a>
761 <a class="tabChart liveconnectionsLink" href="#">
762 <?php echo __('Live conn./process chart'); ?>
763 </a>
764 </div>
765 <div class="tabInnerContent">
766 <?php printServerTraffic(); ?>
767 </div>
768 </div>
769 <div id="statustabs_queries" class="clearfloat">
770 <div class="buttonlinks jsfeature">
771 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=query_statistics&amp;' . PMA_generate_common_url(); ?>" >
772 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
773 <?php echo __('Refresh'); ?>
774 </a>
775 <span class="refreshList" style="display:none;">
776 <label for="id_queryChartRefresh"><?php echo __('Refresh rate: '); ?></label>
777 <?php refreshList('queryChartRefresh'); ?>
778 </span>
779 <a class="tabChart livequeriesLink" href="#">
780 <?php echo __('Live query chart'); ?>
781 </a>
782 </div>
783 <div class="tabInnerContent">
784 <?php printQueryStatistics(); ?>
785 </div>
786 </div>
787 <div id="statustabs_allvars" class="clearfloat">
788 <fieldset id="tableFilter" class="jsfeature">
789 <div class="buttonlinks">
790 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=variables_table&amp;' . PMA_generate_common_url(); ?>" >
791 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
792 <?php echo __('Refresh'); ?>
793 </a>
794 </div>
795 <legend>Filters</legend>
796 <div class="formelement">
797 <label for="filterText"><?php echo __('Containing the word:'); ?></label>
798 <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
799 </div>
800 <div class="formelement">
801 <input type="checkbox" name="filterAlert" id="filterAlert" />
802 <label for="filterAlert"><?php echo __('Show only alert values'); ?></label>
803 </div>
804 <div class="formelement">
805 <select id="filterCategory" name="filterCategory">
806 <option value=''><?php echo __('Filter by category...'); ?></option>
807 <?php
808 foreach ($sections as $section_id => $section_name) {
810 <option value='<?php echo $section_id; ?>'><?php echo $section_name; ?></option>
811 <?php
815 </select>
816 </div>
817 <div class="formelement">
818 <input type="checkbox" name="dontFormat" id="dontFormat" />
819 <label for="dontFormat"><?php echo __('Show unformatted values'); ?></label>
820 </div>
821 </fieldset>
822 <div id="linkSuggestions" class="defaultLinks" style="display:none">
823 <p class="notice"><?php echo __('Related links:'); ?>
824 <?php
825 foreach ($links as $section_name => $section_links) {
826 echo '<span class="status_' . $section_name . '"> ';
827 $i=0;
828 foreach ($section_links as $link_name => $link_url) {
829 if ($i > 0) {
830 echo ', ';
832 if ('doc' == $link_name) {
833 echo PMA_showMySQLDocu($link_url, $link_url);
834 } else {
835 echo '<a href="' . $link_url . '">' . $link_name . '</a>';
837 $i++;
839 echo '</span>';
841 unset($link_url, $link_name, $i);
843 </p>
844 </div>
845 <div class="tabInnerContent">
846 <?php printVariablesTable(); ?>
847 </div>
848 </div>
850 <div id="statustabs_charting" class="jsfeature">
851 <?php printMonitor(); ?>
852 </div>
854 <div id="statustabs_advisor" class="jsfeature">
855 <div class="tabLinks">
856 <img src="themes/dot.gif" class="icon ic_play" alt="" /> <a href="#startAnalyzer"><?php echo __('Run analyzer'); ?></a>
857 <img src="themes/dot.gif" class="icon ic_b_help" alt="" /> <a href="#openAdvisorInstructions"><?php echo __('Instructions'); ?></a>
858 </div>
859 <div class="tabInnerContent clearfloat">
860 </div>
861 <div id="advisorInstructionsDialog" style="display:none;">
862 <?php
863 echo '<p>';
864 echo __('The Advisor system can provide recommendations on server variables by analyzing the server status variables.');
865 echo '</p> <p>';
866 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.');
867 echo '</p> <p>';
868 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.');
869 echo '</p> <p>';
870 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.');
871 echo '</p>';
873 </div>
874 </div>
875 </div>
876 </div>
878 <?php
880 function printQueryStatistics()
882 global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
884 $hour_factor = 3600 / $server_status['Uptime'];
886 $total_queries = array_sum($used_queries);
889 <h3 id="serverstatusqueries">
890 <?php
891 /* l10n: Questions is the name of a MySQL Status variable */
892 echo sprintf(__('Questions since startup: %s'), PMA_formatNumber($total_queries, 0)) . ' ';
893 echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
895 <br />
896 <span>
897 <?php
898 echo '&oslash; ' . __('per hour') . ': ';
899 echo PMA_formatNumber($total_queries * $hour_factor, 0);
900 echo '<br />';
902 echo '&oslash; ' . __('per minute') . ': ';
903 echo PMA_formatNumber( $total_queries * 60 / $server_status['Uptime'], 0);
904 echo '<br />';
906 if ($total_queries / $server_status['Uptime'] >= 1) {
907 echo '&oslash; ' . __('per second') . ': ';
908 echo PMA_formatNumber( $total_queries / $server_status['Uptime'], 0);
911 </span>
912 </h3>
913 <?php
915 // reverse sort by value to show most used statements first
916 arsort($used_queries);
918 $odd_row = true;
919 $count_displayed_rows = 0;
920 $perc_factor = 100 / $total_queries; //(- $server_status['Connections']);
924 <table id="serverstatusqueriesdetails" class="data sortable noclick">
925 <col class="namecol" />
926 <col class="valuecol" span="3" />
927 <thead>
928 <tr><th><?php echo __('Statements'); ?></th>
929 <th><?php
930 /* l10n: # = Amount of queries */
931 echo __('#');
933 </th>
934 <th>&oslash; <?php echo __('per hour'); ?></th>
935 <th>%</th>
936 </tr>
937 </thead>
938 <tbody>
940 <?php
941 $chart_json = array();
942 $query_sum = array_sum($used_queries);
943 $other_sum = 0;
944 foreach ($used_queries as $name => $value) {
945 $odd_row = !$odd_row;
947 // For the percentage column, use Questions - Connections, because
948 // the number of connections is not an item of the Query types
949 // but is included in Questions. Then the total of the percentages is 100.
950 $name = str_replace(array('Com_', '_'), array('', ' '), $name);
952 // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
953 if ($value < $query_sum * 0.02 && count($chart_json)>6) {
954 $other_sum += $value;
955 } else {
956 $chart_json[$name] = $value;
959 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
960 <th class="name"><?php echo htmlspecialchars($name); ?></th>
961 <td class="value"><?php echo htmlspecialchars(PMA_formatNumber($value, 5, 0, true)); ?></td>
962 <td class="value"><?php echo
963 htmlspecialchars(PMA_formatNumber($value * $hour_factor, 4, 1, true)); ?></td>
964 <td class="value"><?php echo
965 htmlspecialchars(PMA_formatNumber($value * $perc_factor, 0, 2)); ?>%</td>
966 </tr>
967 <?php
970 </tbody>
971 </table>
973 <div id="serverstatusquerieschart">
974 <span style="display:none;">
975 <?php
976 if ($other_sum > 0) {
977 $chart_json[__('Other')] = $other_sum;
980 echo json_encode($chart_json);
982 </span>
983 </div>
984 <?php
987 function printServerTraffic()
989 global $server_status, $PMA_PHP_SELF;
990 global $server_master_status, $server_slave_status, $replication_types;
992 $hour_factor = 3600 / $server_status['Uptime'];
995 * starttime calculation
997 $start_time = PMA_DBI_fetch_value(
998 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
1001 <h3><?php
1002 echo sprintf(
1003 __('Network traffic since startup: %s'),
1004 implode(' ', PMA_formatByteDown( $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))
1007 </h3>
1010 <?php
1011 echo sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'),
1012 PMA_timespanFormat($server_status['Uptime']),
1013 PMA_localisedDate($start_time)) . "\n";
1015 </p>
1017 <?php
1018 if ($server_master_status || $server_slave_status) {
1019 echo '<p class="notice">';
1020 if ($server_master_status && $server_slave_status) {
1021 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
1022 } elseif ($server_master_status) {
1023 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
1024 } elseif ($server_slave_status) {
1025 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
1027 echo ' ';
1028 echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
1029 echo '</p>';
1032 /* if the server works as master or slave in replication process, display useful information */
1033 if ($server_master_status || $server_slave_status) {
1035 <hr class="clearfloat" />
1037 <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
1038 <?php
1040 foreach ($replication_types as $type)
1042 if (${"server_{$type}_status"}) {
1043 PMA_replication_print_status_table($type);
1046 unset($types);
1050 <table id="serverstatustraffic" class="data noclick">
1051 <thead>
1052 <tr>
1053 <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>
1054 <th>&oslash; <?php echo __('per hour'); ?></th>
1055 </tr>
1056 </thead>
1057 <tbody>
1058 <tr class="odd">
1059 <th class="name"><?php echo __('Received'); ?></th>
1060 <td class="value"><?php echo
1061 implode(' ',
1062 PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?></td>
1063 <td class="value"><?php echo
1064 implode(' ',
1065 PMA_formatByteDown(
1066 $server_status['Bytes_received'] * $hour_factor, 3, 1)); ?></td>
1067 </tr>
1068 <tr class="even">
1069 <th class="name"><?php echo __('Sent'); ?></th>
1070 <td class="value"><?php echo
1071 implode(' ',
1072 PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?></td>
1073 <td class="value"><?php echo
1074 implode(' ',
1075 PMA_formatByteDown(
1076 $server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?></td>
1077 </tr>
1078 <tr class="odd">
1079 <th class="name"><?php echo __('Total'); ?></th>
1080 <td class="value"><?php echo
1081 implode(' ',
1082 PMA_formatByteDown(
1083 $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)
1084 ); ?></td>
1085 <td class="value"><?php echo
1086 implode(' ',
1087 PMA_formatByteDown(
1088 ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
1089 * $hour_factor, 3, 1)
1090 ); ?></td>
1091 </tr>
1092 </tbody>
1093 </table>
1095 <table id="serverstatusconnections" class="data noclick">
1096 <thead>
1097 <tr>
1098 <th colspan="2"><?php echo __('Connections'); ?></th>
1099 <th>&oslash; <?php echo __('per hour'); ?></th>
1100 <th>%</th>
1101 </tr>
1102 </thead>
1103 <tbody>
1104 <tr class="odd">
1105 <th class="name"><?php echo __('max. concurrent connections'); ?></th>
1106 <td class="value"><?php echo
1107 PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
1108 <td class="value">--- </td>
1109 <td class="value">--- </td>
1110 </tr>
1111 <tr class="even">
1112 <th class="name"><?php echo __('Failed attempts'); ?></th>
1113 <td class="value"><?php echo
1114 PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
1115 <td class="value"><?php echo
1116 PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
1117 4, 2, true); ?></td>
1118 <td class="value"><?php echo
1119 $server_status['Connections'] > 0
1120 ? PMA_formatNumber(
1121 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
1122 0, 2, true) . '%'
1123 : '--- '; ?></td>
1124 </tr>
1125 <tr class="odd">
1126 <th class="name"><?php echo __('Aborted'); ?></th>
1127 <td class="value"><?php echo
1128 PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
1129 <td class="value"><?php echo
1130 PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
1131 4, 2, true); ?></td>
1132 <td class="value"><?php echo
1133 $server_status['Connections'] > 0
1134 ? PMA_formatNumber(
1135 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
1136 0, 2, true) . '%'
1137 : '--- '; ?></td>
1138 </tr>
1139 <tr class="even">
1140 <th class="name"><?php echo __('Total'); ?></th>
1141 <td class="value"><?php echo
1142 PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
1143 <td class="value"><?php echo
1144 PMA_formatNumber($server_status['Connections'] * $hour_factor,
1145 4, 2); ?></td>
1146 <td class="value"><?php echo
1147 PMA_formatNumber(100, 0, 2); ?>%</td>
1148 </tr>
1149 </tbody>
1150 </table>
1151 <?php
1153 $url_params = array();
1155 if (! empty($_REQUEST['full'])) {
1156 $sql_query = 'SHOW FULL PROCESSLIST';
1157 $url_params['full'] = 1;
1158 $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
1159 } else {
1160 $sql_query = 'SHOW PROCESSLIST';
1161 $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
1163 $result = PMA_DBI_query($sql_query);
1166 * Displays the page
1169 <table id="tableprocesslist" class="data clearfloat noclick">
1170 <thead>
1171 <tr>
1172 <th><?php echo __('Processes'); ?></th>
1173 <th><?php echo __('ID'); ?></th>
1174 <th><?php echo __('User'); ?></th>
1175 <th><?php echo __('Host'); ?></th>
1176 <th><?php echo __('Database'); ?></th>
1177 <th><?php echo __('Command'); ?></th>
1178 <th><?php echo __('Time'); ?></th>
1179 <th><?php echo __('Status'); ?></th>
1180 <th><?php
1181 echo __('SQL query');
1182 if (! PMA_DRIZZLE) {
1184 <a href="<?php echo $full_text_link; ?>"
1185 title="<?php echo empty($full) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>">
1186 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . (empty($_REQUEST['full']) ? 'full' : 'partial'); ?>text.png"
1187 alt="<?php echo empty($_REQUEST['full']) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>" />
1188 </a>
1189 <?php } ?>
1190 </th>
1191 </tr>
1192 </thead>
1193 <tbody>
1194 <?php
1195 $odd_row = true;
1196 while ($process = PMA_DBI_fetch_assoc($result)) {
1197 if (PMA_DRIZZLE) {
1198 // Drizzle uses uppercase keys
1199 foreach ($process as $k => $v) {
1200 $k = $k !== 'DB'
1201 ? ucfirst(strtolower($k))
1202 : 'db';
1203 $process[$k] = $v;
1206 $url_params['kill'] = $process['Id'];
1207 $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
1209 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
1210 <td><a href="<?php echo $kill_process ; ?>"><?php echo __('Kill'); ?></a></td>
1211 <td class="value"><?php echo $process['Id']; ?></td>
1212 <td><?php echo $process['User']; ?></td>
1213 <td><?php echo $process['Host']; ?></td>
1214 <td><?php echo ((! isset($process['db']) || ! strlen($process['db'])) ? '<i>' . __('None') . '</i>' : $process['db']); ?></td>
1215 <td><?php echo $process['Command']; ?></td>
1216 <td class="value"><?php echo $process['Time']; ?></td>
1217 <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
1218 <td>
1219 <?php
1220 if (empty($process['Info'])) {
1221 echo '---';
1222 } else {
1223 if (empty($_REQUEST['full']) && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
1224 echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
1225 } else {
1226 echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
1230 </td>
1231 </tr>
1232 <?php
1233 $odd_row = ! $odd_row;
1236 </tbody>
1237 </table>
1238 <?php
1241 function printVariablesTable()
1243 global $server_status, $server_variables, $allocationMap, $links;
1245 * Messages are built using the message name
1247 $strShowStatus = array(
1248 'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
1249 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
1250 '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.'),
1251 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
1252 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
1253 '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.'),
1254 'Created_tmp_files' => __('How many temporary files mysqld has created.'),
1255 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
1256 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
1257 '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.'),
1258 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
1259 'Flush_commands' => __('The number of executed FLUSH statements.'),
1260 'Handler_commit' => __('The number of internal COMMIT statements.'),
1261 'Handler_delete' => __('The number of times a row was deleted from a table.'),
1262 '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.'),
1263 '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.'),
1264 '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.'),
1265 '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.'),
1266 '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.'),
1267 '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.'),
1268 '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.'),
1269 'Handler_rollback' => __('The number of internal ROLLBACK statements.'),
1270 'Handler_update' => __('The number of requests to update a row in a table.'),
1271 'Handler_write' => __('The number of requests to insert a row in a table.'),
1272 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'),
1273 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'),
1274 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'),
1275 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'),
1276 '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.'),
1277 '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.'),
1278 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'),
1279 '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.'),
1280 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'),
1281 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'),
1282 '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.'),
1283 '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.'),
1284 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'),
1285 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'),
1286 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'),
1287 'Innodb_data_pending_reads' => __('The current number of pending reads.'),
1288 'Innodb_data_pending_writes' => __('The current number of pending writes.'),
1289 'Innodb_data_read' => __('The amount of data read so far, in bytes.'),
1290 'Innodb_data_reads' => __('The total number of data reads.'),
1291 'Innodb_data_writes' => __('The total number of data writes.'),
1292 'Innodb_data_written' => __('The amount of data written so far, in bytes.'),
1293 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'),
1294 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'),
1295 '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.'),
1296 'Innodb_log_write_requests' => __('The number of log write requests.'),
1297 'Innodb_log_writes' => __('The number of physical writes to the log file.'),
1298 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'),
1299 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'),
1300 'Innodb_os_log_pending_writes' => __('Pending log file writes.'),
1301 'Innodb_os_log_written' => __('The number of bytes written to the log file.'),
1302 'Innodb_pages_created' => __('The number of pages created.'),
1303 '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.'),
1304 'Innodb_pages_read' => __('The number of pages read.'),
1305 'Innodb_pages_written' => __('The number of pages written.'),
1306 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'),
1307 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'),
1308 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'),
1309 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'),
1310 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'),
1311 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'),
1312 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'),
1313 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'),
1314 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'),
1315 '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.'),
1316 '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.'),
1317 '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.'),
1318 'Key_read_requests' => __('The number of requests to read a key block from the cache.'),
1319 '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.'),
1320 'Key_write_requests' => __('The number of requests to write a key block to the cache.'),
1321 'Key_writes' => __('The number of physical writes of a key block to disk.'),
1322 '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.'),
1323 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'),
1324 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'),
1325 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'),
1326 'Open_files' => __('The number of files that are open.'),
1327 'Open_streams' => __('The number of streams that are open (used mainly for logging).'),
1328 'Open_tables' => __('The number of tables that are open.'),
1329 '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.'),
1330 'Qcache_free_memory' => __('The amount of free memory for query cache.'),
1331 'Qcache_hits' => __('The number of cache hits.'),
1332 'Qcache_inserts' => __('The number of queries added to the cache.'),
1333 '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.'),
1334 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'),
1335 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'),
1336 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'),
1337 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'),
1338 '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.'),
1339 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'),
1340 '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.)'),
1341 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'),
1342 'Select_scan' => __('The number of joins that did a full scan of the first table.'),
1343 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'),
1344 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'),
1345 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'),
1346 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'),
1347 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'),
1348 '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.'),
1349 'Sort_range' => __('The number of sorts that were done with ranges.'),
1350 'Sort_rows' => __('The number of sorted rows.'),
1351 'Sort_scan' => __('The number of sorts that were done by scanning the table.'),
1352 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'),
1353 '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.'),
1354 '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.'),
1355 'Threads_connected' => __('The number of currently open connections.'),
1356 '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.)'),
1357 'Threads_running' => __('The number of threads that are not sleeping.')
1361 * define some alerts
1363 // name => max value before alert
1364 $alerts = array(
1365 // lower is better
1366 // variable => max value
1367 'Aborted_clients' => 0,
1368 'Aborted_connects' => 0,
1370 'Binlog_cache_disk_use' => 0,
1372 'Created_tmp_disk_tables' => 0,
1374 'Handler_read_rnd' => 0,
1375 'Handler_read_rnd_next' => 0,
1377 'Innodb_buffer_pool_pages_dirty' => 0,
1378 'Innodb_buffer_pool_reads' => 0,
1379 'Innodb_buffer_pool_wait_free' => 0,
1380 'Innodb_log_waits' => 0,
1381 'Innodb_row_lock_time_avg' => 10, // ms
1382 'Innodb_row_lock_time_max' => 50, // ms
1383 'Innodb_row_lock_waits' => 0,
1385 'Slow_queries' => 0,
1386 'Delayed_errors' => 0,
1387 'Select_full_join' => 0,
1388 'Select_range_check' => 0,
1389 'Sort_merge_passes' => 0,
1390 'Opened_tables' => 0,
1391 'Table_locks_waited' => 0,
1392 'Qcache_lowmem_prunes' => 0,
1394 'Qcache_free_blocks' => $server_status['Qcache_total_blocks'] / 5,
1395 'Slow_launch_threads' => 0,
1397 // depends on Key_read_requests
1398 // normaly lower then 1:0.01
1399 'Key_reads' => (0.01 * $server_status['Key_read_requests']),
1400 // depends on Key_write_requests
1401 // normaly nearly 1:1
1402 'Key_writes' => (0.9 * $server_status['Key_write_requests']),
1404 'Key_buffer_fraction' => 0.5,
1406 // alert if more than 95% of thread cache is in use
1407 'Threads_cached' => 0.95 * $server_variables['thread_cache_size']
1409 // higher is better
1410 // variable => min value
1411 //'Handler read key' => '> ',
1415 <table class="data sortable noclick" id="serverstatusvariables">
1416 <col class="namecol" />
1417 <col class="valuecol" />
1418 <col class="descrcol" />
1419 <thead>
1420 <tr>
1421 <th><?php echo __('Variable'); ?></th>
1422 <th><?php echo __('Value'); ?></th>
1423 <th><?php echo __('Description'); ?></th>
1424 </tr>
1425 </thead>
1426 <tbody>
1427 <?php
1429 $odd_row = false;
1430 foreach ($server_status as $name => $value) {
1431 $odd_row = !$odd_row;
1433 <tr class="<?php echo $odd_row ? 'odd' : 'even'; echo isset($allocationMap[$name])?' s_' . $allocationMap[$name]:''; ?>">
1434 <th class="name"><?php echo htmlspecialchars(str_replace('_', ' ', $name)) . PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); ?>
1435 </th>
1436 <td class="value"><span class="formatted"><?php
1437 if (isset($alerts[$name])) {
1438 if ($value > $alerts[$name]) {
1439 echo '<span class="attention">';
1440 } else {
1441 echo '<span class="allfine">';
1444 if ('%' === substr($name, -1, 1)) {
1445 echo htmlspecialchars(PMA_formatNumber($value, 0, 2)) . ' %';
1446 } elseif (strpos($name, 'Uptime')!==FALSE) {
1447 echo htmlspecialchars(PMA_timespanFormat($value));
1448 } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
1449 echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
1450 } elseif (is_numeric($value) && $value == (int) $value) {
1451 echo htmlspecialchars(PMA_formatNumber($value, 3, 0));
1452 } elseif (is_numeric($value)) {
1453 echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
1454 } else {
1455 echo htmlspecialchars($value);
1457 if (isset($alerts[$name])) {
1458 echo '</span>';
1460 ?></span><span style="display:none;" class="original"><?php echo $value; ?></span>
1461 </td>
1462 <td class="descr">
1463 <?php
1464 if (isset($strShowStatus[$name ])) {
1465 echo $strShowStatus[$name];
1468 if (isset($links[$name])) {
1469 foreach ($links[$name] as $link_name => $link_url) {
1470 if ('doc' == $link_name) {
1471 echo PMA_showMySQLDocu($link_url, $link_url);
1472 } else {
1473 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
1474 "\n";
1477 unset($link_url, $link_name);
1480 </td>
1481 </tr>
1482 <?php
1485 </tbody>
1486 </table>
1487 <?php
1490 function printMonitor()
1492 global $server_status, $server_db_isLocal;
1494 <div class="tabLinks" style="display:none;">
1495 <a href="#pauseCharts">
1496 <img src="themes/dot.gif" class="icon ic_play" alt="" />
1497 <?php echo __('Start Monitor'); ?>
1498 </a>
1499 <a href="#settingsPopup" rel="popupLink" style="display:none;">
1500 <img src="themes/dot.gif" class="icon ic_s_cog" alt="" />
1501 <?php echo __('Settings'); ?>
1502 </a>
1503 <a href="#monitorInstructionsDialog">
1504 <img src="themes/dot.gif" class="icon ic_b_help" alt="" />
1505 <?php echo __('Instructions/Setup'); ?>
1506 </a>
1507 <a href="#endChartEditMode" style="display:none;">
1508 <img src="themes/dot.gif" class="icon ic_s_okay" alt="" />
1509 <?php echo __('Done rearranging/editing charts'); ?>
1510 </a>
1511 </div>
1513 <div class="popupContent settingsPopup">
1514 <a href="#addNewChart">
1515 <img src="themes/dot.gif" class="icon ic_b_chart" alt="" />
1516 <?php echo __('Add chart'); ?>
1517 </a>
1518 <a href="#rearrangeCharts"><img class="icon ic_b_tblops" src="themes/dot.gif" width="16" height="16" alt="" /><?php echo __('Rearrange/edit charts'); ?></a>
1519 <div class="clearfloat paddingtop"></div>
1520 <div class="floatleft">
1521 <?php
1522 echo __('Refresh rate') . '<br />';
1523 refreshList('gridChartRefresh', 5, Array(2, 3, 4, 5, 10, 20, 40, 60, 120, 300, 600, 1200));
1524 ?><br />
1525 </div>
1526 <div class="floatleft">
1527 <?php echo __('Chart columns'); ?> <br />
1528 <select name="chartColumns">
1529 <option>1</option>
1530 <option>2</option>
1531 <option>3</option>
1532 <option>4</option>
1533 <option>5</option>
1534 <option>6</option>
1535 <option>7</option>
1536 <option>8</option>
1537 <option>9</option>
1538 <option>10</option>
1539 </select>
1540 </div>
1542 <div class="clearfloat paddingtop">
1543 <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/>
1544 <a href="#importMonitorConfig"><?php echo __('Import'); ?></a>&nbsp;&nbsp;<a href="#exportMonitorConfig"><?php echo __('Export'); ?></a>&nbsp;&nbsp;<a href="#clearMonitorConfig"><?php echo __('Reset to default'); ?></a>
1545 </div>
1546 </div>
1548 <div id="monitorInstructionsDialog" title="<?php echo __('Monitor Instructions'); ?>" style="display:none;">
1549 <?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%'); ?>
1550 <?php if (PMA_MYSQL_INT_VERSION < 50106) { ?>
1552 <img class="icon ic_s_attention" src="themes/dot.gif" alt="" />
1553 <?php
1554 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.');
1556 </p>
1557 <?php
1558 } else {
1560 <p></p>
1561 <img class="ajaxIcon" src="<?php echo $GLOBALS['pmaThemeImage']; ?>ajax_clock_small.gif" alt="Loading" />
1562 <div class="ajaxContent"></div>
1563 <div class="monitorUse" style="display:none;">
1564 <p></p>
1565 <?php
1566 echo '<strong>';
1567 echo __('Using the monitor:');
1568 echo '</strong><p>';
1569 echo __('Ok, you are good to go! Once you click \'Start monitor\' 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.');
1570 echo '</p><p>';
1571 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.');
1572 echo '</p>';
1575 <img class="icon ic_s_attention" src="themes/dot.gif" alt="" />
1576 <?php
1577 echo '<strong>';
1578 echo __('Please note:');
1579 echo '</strong><br />';
1580 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.');
1582 </p>
1583 </div>
1584 <?php } ?>
1585 </div>
1587 <div id="addChartDialog" title="Add chart" style="display:none;">
1588 <div id="tabGridVariables">
1589 <p><input type="text" name="chartTitle" value="<?php echo __('Chart Title'); ?>" /></p>
1591 <input type="radio" name="chartType" value="preset" id="chartPreset" />
1592 <label for="chartPreset"><?php echo __('Preset chart'); ?></label>
1593 <select name="presetCharts"></select><br/>
1595 <input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked" />
1596 <label for="chartStatusVar"><?php echo __('Status variable(s)'); ?></label><br/>
1597 <div id="chartVariableSettings">
1598 <label for="chartSeries"><?php echo __('Select series:'); ?></label><br />
1599 <select id="chartSeries" name="varChartList" size="1">
1600 <option><?php echo __('Commonly monitored'); ?></option>
1601 <option>Processes</option>
1602 <option>Questions</option>
1603 <option>Connections</option>
1604 <option>Bytes_sent</option>
1605 <option>Bytes_received</option>
1606 <option>Threads_connected</option>
1607 <option>Created_tmp_disk_tables</option>
1608 <option>Handler_read_first</option>
1609 <option>Innodb_buffer_pool_wait_free</option>
1610 <option>Key_reads</option>
1611 <option>Open_tables</option>
1612 <option>Select_full_join</option>
1613 <option>Slow_queries</option>
1614 </select><br />
1615 <label for="variableInput"><?php echo __('or type variable name:'); ?> </label>
1616 <input type="text" name="variableInput" id="variableInput" />
1617 <p></p>
1618 <input type="checkbox" name="differentialValue" id="differentialValue" value="differential" checked="checked" />
1619 <label for="differentialValue"><?php echo __('Display as differential value'); ?></label><br />
1620 <input type="checkbox" id="useDivisor" name="useDivisor" value="1" />
1621 <label for="useDivisor"><?php echo __('Apply a divisor'); ?></label>
1622 <span class="divisorInput" style="display:none;">
1623 <input type="text" name="valueDivisor" size="4" value="1" />
1624 (<a href="#kibDivisor"><?php echo __('KiB'); ?></a>, <a href="#mibDivisor"><?php echo __('MiB'); ?></a>)
1625 </span><br />
1627 <input type="checkbox" id="useUnit" name="useUnit" value="1" />
1628 <label for="useUnit"><?php echo __('Append unit to data values'); ?></label>
1630 <span class="unitInput" style="display:none;">
1631 <input type="text" name="valueUnit" size="4" value="" />
1632 </span>
1634 <a href="#submitAddSeries"><b><?php echo __('Add this series'); ?></b></a>
1635 <span id="clearSeriesLink" style="display:none;">
1636 | <a href="#submitClearSeries"><?php echo __('Clear series'); ?></a>
1637 </span>
1638 </p>
1639 <?php echo __('Series in Chart:'); ?><br/>
1640 <span id="seriesPreview">
1641 <i><?php echo __('None'); ?></i>
1642 </span>
1643 </div>
1644 </div>
1645 </div>
1647 <!-- For generic use -->
1648 <div id="emptyDialog" title="Dialog" style="display:none;">
1649 </div>
1651 <div id="logAnalyseDialog" title="<?php echo __('Log statistics'); ?>" style="display:none;">
1652 <p> <?php echo __('Selected time range:'); ?>
1653 <input type="text" name="dateStart" class="datetimefield" value="" /> -
1654 <input type="text" name="dateEnd" class="datetimefield" value="" /></p>
1655 <input type="checkbox" id="limitTypes" value="1" checked="checked" />
1656 <label for="limitTypes">
1657 <?php echo __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements'); ?>
1658 </label>
1659 <br/>
1660 <input type="checkbox" id="removeVariables" value="1" checked="checked" />
1661 <label for="removeVariables">
1662 <?php echo __('Remove variable data in INSERT statements for better grouping'); ?>
1663 </label>
1665 <?php
1666 echo '<p>';
1667 echo __('Choose from which log you want the statistics to be generated from.');
1668 echo '</p><p>';
1669 echo __('Results are grouped by query text.');
1670 echo '</p>';
1672 </div>
1674 <div id="queryAnalyzerDialog" title="<?php echo __('Query analyzer'); ?>" style="display:none;">
1675 <textarea id="sqlquery"> </textarea>
1676 <p></p>
1677 <div class="placeHolder"></div>
1678 </div>
1680 <table border="0" class="clearfloat" id="chartGrid">
1682 </table>
1683 <div id="logTable">
1684 <br/>
1685 </div>
1687 <script type="text/javascript">
1688 variableNames = [ <?php
1689 $i=0;
1690 foreach ($server_status as $name=>$value) {
1691 if (is_numeric($value)) {
1692 if ($i++ > 0) {
1693 echo ", ";
1695 echo "'" . $name . "'";
1698 ?> ];
1699 </script>
1700 <?php
1703 /* Builds a <select> list for refresh rates */
1704 function refreshList($name, $defaultRate=5, $refreshRates=Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600))
1707 <select name="<?php echo $name; ?>" id="id_<?php echo $name; ?>">
1708 <?php
1709 foreach ($refreshRates as $rate) {
1710 $selected = ($rate == $defaultRate)?' selected="selected"':'';
1712 if ($rate<60) {
1713 echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d second', '%d seconds', $rate), $rate) . '</option>';
1714 } else {
1715 echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d minute', '%d minutes', $rate/60), $rate/60) . '</option>';
1719 </select>
1720 <?php
1724 * cleanup of some deprecated values
1726 * @param array &$server_status
1728 function cleanDeprecated(&$server_status)
1730 $deprecated = array(
1731 'Com_prepare_sql' => 'Com_stmt_prepare',
1732 'Com_execute_sql' => 'Com_stmt_execute',
1733 'Com_dealloc_sql' => 'Com_stmt_close',
1736 foreach ($deprecated as $old => $new) {
1737 if (isset($server_status[$old]) && isset($server_status[$new])) {
1738 unset($server_status[$old]);
1744 * Sends the footer
1746 require './libraries/footer.inc.php';