Merge remote-tracking branch 'origin/master' into drizzle
[phpmyadmin.git] / server_status.php
blob21d26d638bf3562a4504f11eef03e3795d94489c
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;
21 require_once './libraries/common.inc.php';
23 /**
24 * Ajax request
27 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
28 // Send with correct charset
29 header('Content-Type: text/html; charset=UTF-8');
31 // real-time charting data
32 if (isset($_REQUEST['chart_data'])) {
33 switch($_REQUEST['type']) {
34 case 'proc':
35 $c = PMA_DBI_fetch_result("SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1);
36 $result = PMA_DBI_query('SHOW PROCESSLIST');
37 $num_procs = PMA_DBI_num_rows($result);
39 $ret = array(
40 'x' => microtime(true)*1000,
41 'y_proc' => $num_procs,
42 'y_conn' => $c['Connections']
45 exit(json_encode($ret));
47 case 'queries':
48 if (PMA_DRIZZLE) {
49 $sql = "SELECT concat('Com_', variable_name), variable_value
50 FROM data_dictionary.GLOBAL_STATEMENTS
51 WHERE variable_value > 0
52 UNION
53 SELECT variable_name, variable_value
54 FROM data_dictionary.GLOBAL_STATUS
55 WHERE variable_name = 'Questions'";
56 $queries = PMA_DBI_fetch_result($sql, 0, 1);
57 } else {
58 $queries = PMA_DBI_fetch_result(
59 "SHOW GLOBAL STATUS
60 WHERE (Variable_name LIKE 'Com_%' OR Variable_name = 'Questions')
61 AND Value > 0'", 0, 1);
63 cleanDeprecated($queries);
64 // admin commands are not queries
65 unset($queries['Com_admin_commands']);
66 $questions = $queries['Questions'];
67 unset($queries['Questions']);
69 //$sum=array_sum($queries);
70 $ret = array(
71 'x' => microtime(true)*1000,
72 'y' => $questions,
73 'pointInfo' => $queries
76 exit(json_encode($ret));
78 case 'traffic':
79 $traffic = PMA_DBI_fetch_result(
80 "SHOW GLOBAL STATUS
81 WHERE Variable_name = 'Bytes_received'
82 OR Variable_name = 'Bytes_sent'", 0, 1);
84 $ret = array(
85 'x' => microtime(true)*1000,
86 'y_sent' => $traffic['Bytes_sent'],
87 'y_received' => $traffic['Bytes_received']
90 exit(json_encode($ret));
92 case 'chartgrid':
93 $ret = json_decode($_REQUEST['requiredData'], true);
94 $statusVars = array();
95 $sysinfo = $cpuload = $memory = 0;
97 foreach ($ret as $chart_id => $chartNodes) {
98 foreach ($chartNodes as $node_id => $node) {
99 switch ($node['dataType']) {
100 case 'statusvar':
101 // Some white list filtering
102 if (!preg_match('/[^a-zA-Z_]+/',$node['name']))
103 $statusVars[] = $node['name'];
104 break;
106 case 'proc':
107 $result = PMA_DBI_query('SHOW PROCESSLIST');
108 $ret[$chart_id][$node_id]['y'] = PMA_DBI_num_rows($result);
109 break;
111 case 'cpu':
112 if (!$sysinfo) {
113 require_once('libraries/sysinfo.lib.php');
114 $sysinfo = getSysInfo();
116 if (!$cpuload)
117 $cpuload = $sysinfo->loadavg();
119 if (PHP_OS == 'Linux') {
120 $ret[$chart_id][$node_id]['idle'] = $cpuload['idle'];
121 $ret[$chart_id][$node_id]['busy'] = $cpuload['busy'];
122 } else
123 $ret[$chart_id][$node_id]['y'] = $cpuload['loadavg'];
125 break;
127 case 'memory':
128 if (!$sysinfo) {
129 require_once('libraries/sysinfo.lib.php');
130 $sysinfo = getSysInfo();
132 if (!$memory)
133 $memory = $sysinfo->memory();
135 $ret[$chart_id][$node_id]['y'] = $memory[$node['name']];
136 break;
141 $vars = PMA_DBI_fetch_result(
142 "SHOW GLOBAL STATUS
143 WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1);
145 foreach ($ret as $chart_id => $chartNodes) {
146 foreach ($chartNodes as $node_id => $node) {
147 if ($node['dataType'] == 'statusvar')
148 $ret[$chart_id][$node_id]['y'] = $vars[$node['name']];
152 $ret['x'] = microtime(true)*1000;
154 exit(json_encode($ret));
158 if (isset($_REQUEST['log_data'])) {
159 $start = intval($_REQUEST['time_start']);
160 $end = intval($_REQUEST['time_end']);
162 if ($_REQUEST['type'] == 'slow') {
163 $q = 'SELECT SUM(query_time) AS TIME(query_time), SUM(lock_time) as lock_time, '.
164 'SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined, sql_text, COUNT(sql_text) AS \'#\' '.
165 'FROM `mysql`.`slow_log` WHERE event_time > FROM_UNIXTIME('.$start.') '.
166 'AND event_time < FROM_UNIXTIME('.$end.') GROUP BY sql_text';
168 $result = PMA_DBI_try_query($q);
170 $return = array('rows' => array(), 'sum' => array());
171 $type = '';
173 while ($row = PMA_DBI_fetch_assoc($result)) {
174 $type = substr($row['sql_text'],0,strpos($row['sql_text'],' '));
175 $return['sum'][$type]++;
176 $return['rows'][] = $row;
179 $return['sum']['TOTAL'] = array_sum($return['sum']);
181 PMA_DBI_free_result($result);
183 exit(json_encode($return));
186 if($_REQUEST['type'] == 'general') {
187 $limitTypes = (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes'])
188 ? 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
190 $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, server_id, argument, count(argument) as \'#\' '.
191 'FROM `mysql`.`general_log` WHERE command_type=\'Query\' '.
192 'AND event_time > FROM_UNIXTIME('.$start.') AND event_time < FROM_UNIXTIME('.$end.') '.
193 $limitTypes . 'GROUP by argument'; // HAVING count > 1';
195 $result = PMA_DBI_try_query($q);
197 $return = array('rows' => array(), 'sum' => array());
198 $type = '';
199 $insertTables = array();
200 $insertTablesFirst = -1;
201 $i = 0;
202 $removeVars = isset($_REQUEST['removeVariables']) && $_REQUEST['removeVariables'];
204 while ($row = PMA_DBI_fetch_assoc($result)) {
205 preg_match('/^(\w+)\s/',$row['argument'],$match);
206 $type = strtolower($match[1]);
208 if(!isset($return['sum'][$type])) $return['sum'][$type] = 0;
209 $return['sum'][$type] += $row['#'];
211 switch($type) {
212 case 'insert':
213 // Group inserts if selected
214 if($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i',$row['argument'],$matches)) {
215 $insertTables[$matches[2]]++;
216 if ($insertTables[$matches[2]] > 1) {
217 $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
219 // Add a ... to the end of this query to indicate that there's been other queries
220 if($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.')
221 $return['rows'][$insertTablesFirst]['argument'] .= '<br/>...';
223 // Group this value, thus do not add to the result list
224 continue 2;
225 } else {
226 $insertTablesFirst = $i;
227 $insertTables[$matches[2]] += $row['#'] - 1;
230 // No break here
232 case 'update':
233 // Cut off big inserts and updates, but append byte count therefor
234 if(strlen($row['argument']) > 180)
235 $row['argument'] = substr($row['argument'],0,160) . '... [' .
236 PMA_formatByteDown(strlen($row['argument']), 2).']';
238 break;
240 default: break;
243 $return['rows'][] = $row;
244 $i++;
247 $return['sum']['TOTAL'] = array_sum($return['sum']);
248 $return['numRows'] = count($return['rows']);
250 PMA_DBI_free_result($result);
252 exit(json_encode($return));
256 if (isset($_REQUEST['logging_vars'])) {
257 if(isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
258 $value = PMA_sqlAddslashes($_REQUEST['varValue']);
259 if(!is_numeric($value)) $value="'".$value."'";
261 if(! preg_match("/[^a-zA-Z0-9_]+/",$_REQUEST['varName']))
262 PMA_DBI_query('SET GLOBAL '.$_REQUEST['varName'].' = '.$value);
266 $loggingVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES WHERE Variable_name IN ("general_log","slow_query_log","long_query_time","log_output")', 0, 1);
267 exit(json_encode($loggingVars));
270 if(isset($_REQUEST['query_analyzer'])) {
271 $return = array();
273 if ($profiling = PMA_profilingSupported())
274 PMA_DBI_query('SET PROFILING=1;');
276 // Do not cache query
277 $query = preg_replace('/^(\s*SELECT)/i','\\1 SQL_NO_CACHE',$_REQUEST['query']);
279 $result = PMA_DBI_try_query('EXPLAIN ' . $query);
280 $return['explain'] = PMA_DBI_fetch_assoc($result);
282 // In case an error happened
283 $return['error'] = PMA_DBI_getError();
285 PMA_DBI_free_result($result);
287 if($profiling) {
288 $return['profiling'] = array();
289 $result = PMA_DBI_try_query('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=1 ORDER BY seq');
290 while ($row = PMA_DBI_fetch_assoc($result)) {
291 $return['profiling'][]= $row;
293 PMA_DBI_free_result($result);
296 exit(json_encode($return));
302 * Replication library
304 if (PMA_DRIZZLE) {
305 $server_master_status = false;
306 $server_slave_status = false;
307 } else {
308 require './libraries/replication.inc.php';
309 require_once './libraries/replication_gui.lib.php';
313 * JS Includes
316 $GLOBALS['js_include'][] = 'server_status.js';
317 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
318 $GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
319 $GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
320 $GLOBALS['js_include'][] = 'jquery/jquery.json-2.2.js';
321 $GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
322 $GLOBALS['js_include'][] = 'jquery/jquery.sortableTable.js';
323 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
324 // Charting
325 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
326 /* Files required for chart exporting */
327 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
328 $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
329 $GLOBALS['js_include'][] = 'canvg/canvg.js';
330 $GLOBALS['js_include'][] = 'canvg/rgbcolor.js';
331 $GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
332 $GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
335 * flush status variables if requested
337 if (isset($_REQUEST['flush'])) {
338 $_flush_commands = array(
339 'STATUS',
340 'TABLES',
341 'QUERY CACHE',
344 if (in_array($_REQUEST['flush'], $_flush_commands)) {
345 PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
347 unset($_flush_commands);
351 * Kills a selected process
353 if (!empty($_REQUEST['kill'])) {
354 if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
355 $message = PMA_Message::success(__('Thread %s was successfully killed.'));
356 } else {
357 $message = PMA_Message::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
359 $message->addParam($_REQUEST['kill']);
360 //$message->display();
366 * get status from server
368 $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
369 if (PMA_DRIZZLE) {
370 // Drizzle doesn't put query statistics into variables, add it
371 $sql = "SELECT concat('Com_', variable_name), variable_value
372 FROM data_dictionary.GLOBAL_STATEMENTS";
373 $statements = PMA_DBI_fetch_result($sql, 0, 1);
374 $server_status = array_merge($server_status, $statements);
378 * for some calculations we require also some server settings
380 $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
383 * cleanup of some deprecated values
385 cleanDeprecated($server_status);
388 * calculate some values
390 // Key_buffer_fraction
391 if (isset($server_status['Key_blocks_unused'])
392 && isset($server_variables['key_cache_block_size'])
393 && isset($server_variables['key_buffer_size'])) {
394 $server_status['Key_buffer_fraction_%'] =
396 - $server_status['Key_blocks_unused']
397 * $server_variables['key_cache_block_size']
398 / $server_variables['key_buffer_size']
399 * 100;
400 } elseif (isset($server_status['Key_blocks_used'])
401 && isset($server_variables['key_buffer_size'])) {
402 $server_status['Key_buffer_fraction_%'] =
403 $server_status['Key_blocks_used']
404 * 1024
405 / $server_variables['key_buffer_size'];
408 // Ratio for key read/write
409 if (isset($server_status['Key_writes'])
410 && isset($server_status['Key_write_requests'])
411 && $server_status['Key_write_requests'] > 0) {
412 $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
415 if (isset($server_status['Key_reads'])
416 && isset($server_status['Key_read_requests'])
417 && $server_status['Key_read_requests'] > 0) {
418 $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
421 // Threads_cache_hitrate
422 if (isset($server_status['Threads_created'])
423 && isset($server_status['Connections'])
424 && $server_status['Connections'] > 0) {
425 $server_status['Threads_cache_hitrate_%'] =
427 - $server_status['Threads_created']
428 / $server_status['Connections']
429 * 100;
432 // Format Uptime_since_flush_status : show as days, hours, minutes, seconds
433 if (isset($server_status['Uptime_since_flush_status'])) {
434 $server_status['Uptime_since_flush_status'] = PMA_timespanFormat($server_status['Uptime_since_flush_status']);
438 * split variables in sections
440 $allocations = array(
441 // variable name => section
442 // variable names match when they begin with the given string
444 'Com_' => 'com',
445 'Innodb_' => 'innodb',
446 'Ndb_' => 'ndb',
447 'Handler_' => 'handler',
448 'Qcache_' => 'qcache',
449 'Threads_' => 'threads',
450 'Slow_launch_threads' => 'threads',
452 'Binlog_cache_' => 'binlog_cache',
453 'Created_tmp_' => 'created_tmp',
454 'Key_' => 'key',
456 'Delayed_' => 'delayed',
457 'Not_flushed_delayed_rows' => 'delayed',
459 'Flush_commands' => 'query',
460 'Last_query_cost' => 'query',
461 'Slow_queries' => 'query',
462 'Queries' => 'query',
463 'Prepared_stmt_count' => 'query',
465 'Select_' => 'select',
466 'Sort_' => 'sort',
468 'Open_tables' => 'table',
469 'Opened_tables' => 'table',
470 'Open_table_definitions' => 'table',
471 'Opened_table_definitions' => 'table',
472 'Table_locks_' => 'table',
474 'Rpl_status' => 'repl',
475 'Slave_' => 'repl',
477 'Tc_' => 'tc',
479 'Ssl_' => 'ssl',
481 'Open_files' => 'files',
482 'Open_streams' => 'files',
483 'Opened_files' => 'files',
486 $sections = array(
487 // section => section name (description)
488 'com' => 'Com',
489 'query' => __('SQL query'),
490 'innodb' => 'InnoDB',
491 'ndb' => 'NDB',
492 'handler' => __('Handler'),
493 'qcache' => __('Query cache'),
494 'threads' => __('Threads'),
495 'binlog_cache' => __('Binary log'),
496 'created_tmp' => __('Temporary data'),
497 'delayed' => __('Delayed inserts'),
498 'key' => __('Key cache'),
499 'select' => __('Joins'),
500 'repl' => __('Replication'),
501 'sort' => __('Sorting'),
502 'table' => __('Tables'),
503 'tc' => __('Transaction coordinator'),
504 'files' => __('Files'),
505 'ssl' => 'SSL',
506 'other' => __('Other')
510 * define some needfull links/commands
512 // variable or section name => (name => url)
513 $links = array();
515 $links['table'][__('Flush (close) all tables')]
516 = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
517 $links['table'][__('Show open tables')]
518 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
519 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
521 if ($server_master_status) {
522 $links['repl'][__('Show slave hosts')]
523 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
524 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
525 $links['repl'][__('Show master status')] = '#replication_master';
527 if ($server_slave_status) {
528 $links['repl'][__('Show slave status')] = '#replication_slave';
531 $links['repl']['doc'] = 'replication';
533 $links['qcache'][__('Flush query cache')]
534 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
535 PMA_generate_common_url();
536 $links['qcache']['doc'] = 'query_cache';
538 //$links['threads'][__('Show processes')]
539 // = 'server_processlist.php?' . PMA_generate_common_url();
540 $links['threads']['doc'] = 'mysql_threads';
542 $links['key']['doc'] = 'myisam_key_cache';
544 $links['binlog_cache']['doc'] = 'binary_log';
546 $links['Slow_queries']['doc'] = 'slow_query_log';
548 $links['innodb'][__('Variables')]
549 = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
550 $links['innodb'][__('InnoDB Status')]
551 = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
552 PMA_generate_common_url();
553 $links['innodb']['doc'] = 'innodb';
556 // Variable to contain all com_ variables (query statistics)
557 $used_queries = array();
559 // Variable to map variable names to their respective section name (used for js category filtering)
560 $allocationMap = array();
562 // Variable to mark used sections
563 $categoryUsed = array();
565 // sort vars into arrays
566 foreach ($server_status as $name => $value) {
567 $section_found = false;
568 foreach ($allocations as $filter => $section) {
569 if (strpos($name, $filter) !== false) {
570 $allocationMap[$name] = $section;
571 $categoryUsed[$section] = true;
572 $section_found = true;
573 if ($section == 'com' && $value > 0) $used_queries[$name] = $value;
574 break; // Only exits inner loop
577 if (!$section_found) {
578 $allocationMap[$name] = 'other';
579 $categoryUsed['other'] = true;
583 // admin commands are not queries (e.g. they include COM_PING, which is excluded from $server_status['Questions'])
584 unset($used_queries['Com_admin_commands']);
586 /* Ajax request refresh */
587 if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
588 switch($_REQUEST['show']) {
589 case 'query_statistics':
590 printQueryStatistics();
591 exit();
592 case 'server_traffic':
593 printServerTraffic();
594 exit();
595 case 'variables_table':
596 // Prints the variables table
597 printVariablesTable();
598 exit();
600 default:
601 break;
606 * start output
610 * Does the common work
612 require './libraries/server_common.inc.php';
616 * Displays the links
618 require './libraries/server_links.inc.php';
620 $server = 1;
621 if (isset($_REQUEST['server']) && intval($_REQUEST['server'])) $server = intval($_REQUEST['server']);
623 $server_db_isLocal = strtolower($cfg['Servers'][$server]['host']) == 'localhost'
624 || $cfg['Servers'][$server]['host'] == '127.0.0.1'
625 || $cfg['Servers'][$server]['host'] == '::1';
628 <script type="text/javascript">
629 pma_token = '<?php echo $_SESSION[' PMA_token ']; ?>';
630 url_query = '<?php echo str_replace('&amp;','&',$url_query);?>';
631 server_time_diff = new Date().getTime() - <?php echo microtime(true)*1000; ?>;
632 server_os = '<?php echo PHP_OS; ?>';
633 is_superuser = <?php echo PMA_isSuperuser()?'true':'false'; ?>;
634 server_db_isLocal = <?php echo ($server_db_isLocal)?'true':'false'; ?>;
635 </script>
636 <div id="serverstatus">
637 <h2><?php
639 * Displays the sub-page heading
641 if ($GLOBALS['cfg']['MainPageIconic']) {
642 echo '<img class="icon ic_s_status" src="themes/dot.gif" width="16" height="16" alt="" />';
645 echo __('Runtime Information');
647 ?></h2>
648 <div id="serverStatusTabs">
649 <ul>
650 <li><a href="#statustabs_traffic"><?php echo __('Server'); ?></a></li>
651 <li><a href="#statustabs_queries"><?php echo __('Query statistics'); ?></a></li>
652 <li><a href="#statustabs_allvars"><?php echo __('All status variables'); ?></a></li>
653 <li><a href="#statustabs_charting"><?php echo __('Monitor'); ?></a></li>
654 </ul>
656 <div id="statustabs_traffic">
657 <div class="buttonlinks">
658 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=server_traffic&amp;' . PMA_generate_common_url(); ?>" >
659 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
660 <?php echo __('Refresh'); ?>
661 </a>
662 <span class="refreshList" style="display:none;">
663 <label for="trafficChartRefresh"><?php echo __('Refresh rate: '); ?></label>
664 <?php refreshList('trafficChartRefresh'); ?>
665 </span>
667 <a class="tabChart livetrafficLink" href="#">
668 <?php echo __('Live traffic chart'); ?>
669 </a>
670 <a class="tabChart liveconnectionsLink" href="#">
671 <?php echo __('Live conn./process chart'); ?>
672 </a>
673 </div>
674 <div class="tabInnerContent">
675 <?php printServerTraffic(); ?>
676 </div>
677 </div>
678 <div id="statustabs_queries">
679 <div class="buttonlinks">
680 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=query_statistics&amp;' . PMA_generate_common_url(); ?>" >
681 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
682 <?php echo __('Refresh'); ?>
683 </a>
684 <span class="refreshList" style="display:none;">
685 <label for="queryChartRefresh"><?php echo __('Refresh rate: '); ?></label>
686 <?php refreshList('queryChartRefresh'); ?>
687 </span>
688 <a class="tabChart livequeriesLink" href="#">
689 <?php echo __('Live query chart'); ?>
690 </a>
691 </div>
692 <div class="tabInnerContent">
693 <?php printQueryStatistics(); ?>
694 </div>
695 </div>
696 <div id="statustabs_allvars">
697 <fieldset id="tableFilter">
698 <div class="buttonlinks">
699 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=variables_table&amp;' . PMA_generate_common_url(); ?>" >
700 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
701 <?php echo __('Refresh'); ?>
702 </a>
703 </div>
704 <legend>Filters</legend>
705 <div class="formelement">
706 <label for="filterText"><?php echo __('Containing the word:'); ?></label>
707 <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
708 </div>
709 <div class="formelement">
710 <input type="checkbox" name="filterAlert" id="filterAlert">
711 <label for="filterAlert"><?php echo __('Show only alert values'); ?></label>
712 </div>
713 <div class="formelement">
714 <select id="filterCategory" name="filterCategory">
715 <option value=''><?php echo __('Filter by category...'); ?></option>
716 <?php
717 foreach ($sections as $section_id => $section_name) {
718 if (isset($categoryUsed[$section_id])) {
720 <option value='<?php echo $section_id; ?>'><?php echo $section_name; ?></option>
721 <?php
725 </select>
726 </div>
727 </fieldset>
728 <div id="linkSuggestions" class="defaultLinks" style="display:none">
729 <p class="notice"><?php echo __('Related links:'); ?>
730 <?php
731 foreach ($links as $section_name => $section_links) {
732 echo '<span class="status_'.$section_name.'"> ';
733 $i=0;
734 foreach ($section_links as $link_name => $link_url) {
735 if ($i > 0) echo ', ';
736 if ('doc' == $link_name) {
737 echo PMA_showMySQLDocu($link_url, $link_url);
738 } else {
739 echo '<a href="' . $link_url . '">' . $link_name . '</a>';
741 $i++;
743 echo '</span>';
745 unset($link_url, $link_name, $i);
747 </p>
748 </div>
749 <div class="tabInnerContent">
750 <?php printVariablesTable(); ?>
751 </div>
752 </div>
754 <div id="statustabs_charting">
755 <?php printMonitor(); ?>
756 </div>
757 </div>
758 </div>
760 <?php
762 function printQueryStatistics() {
763 global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
765 $hour_factor = 3600 / $server_status['Uptime'];
767 $total_queries = array_sum($used_queries);
770 <h3 id="serverstatusqueries">
771 <?php
772 /* l10n: Questions is the name of a MySQL Status variable */
773 echo sprintf(__('Questions since startup: %s'),PMA_formatNumber($total_queries, 0)) . ' ';
774 echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
776 <br>
777 <span>
778 <?php
779 echo '&oslash; '.__('per hour').': ';
780 echo PMA_formatNumber($total_queries * $hour_factor, 0);
781 echo '<br>';
783 echo '&oslash; '.__('per minute').': ';
784 echo PMA_formatNumber( $total_queries * 60 / $server_status['Uptime'], 0);
785 echo '<br>';
787 if ($total_queries / $server_status['Uptime'] >= 1) {
788 echo '&oslash; '.__('per second').': ';
789 echo PMA_formatNumber( $total_queries / $server_status['Uptime'], 0);
792 </span>
793 </h3>
794 <?php
796 // reverse sort by value to show most used statements first
797 arsort($used_queries);
799 $odd_row = true;
800 $count_displayed_rows = 0;
801 $perc_factor = 100 / $total_queries; //(- $server_status['Connections']);
805 <table id="serverstatusqueriesdetails" class="data sortable noclick">
806 <col class="namecol" />
807 <col class="valuecol" span="3" />
808 <thead>
809 <tr><th><?php echo __('Statements'); ?></th>
810 <th><?php
811 /* l10n: # = Amount of queries */
812 echo __('#');
814 <th>&oslash; <?php echo __('per hour'); ?></th>
815 <th>%</th>
816 </tr>
817 </thead>
818 <tbody>
820 <?php
821 $chart_json = array();
822 $query_sum = array_sum($used_queries);
823 $other_sum = 0;
824 foreach ($used_queries as $name => $value) {
825 $odd_row = !$odd_row;
827 // For the percentage column, use Questions - Connections, because
828 // the number of connections is not an item of the Query types
829 // but is included in Questions. Then the total of the percentages is 100.
830 $name = str_replace(array('Com_', '_'), array('', ' '), $name);
832 // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
833 if ($value < $query_sum * 0.02 && count($chart_json)>6)
834 $other_sum += $value;
835 else $chart_json[$name] = $value;
837 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
838 <th class="name"><?php echo htmlspecialchars($name); ?></th>
839 <td class="value"><?php echo PMA_formatNumber($value, 5, 0, true); ?></td>
840 <td class="value"><?php echo
841 PMA_formatNumber($value * $hour_factor, 4, 1, true); ?></td>
842 <td class="value"><?php echo
843 PMA_formatNumber($value * $perc_factor, 0, 2); ?>%</td>
844 </tr>
845 <?php
848 </tbody>
849 </table>
851 <div id="serverstatusquerieschart">
852 <span style="display:none;">
853 <?php
854 if ($other_sum > 0)
855 $chart_json[__('Other')] = $other_sum;
857 echo json_encode($chart_json);
859 </span>
860 </div>
861 <?php
864 function printServerTraffic() {
865 global $server_status,$PMA_PHP_SELF;
866 global $server_master_status, $server_slave_status, $replication_types;
868 $hour_factor = 3600 / $server_status['Uptime'];
871 * starttime calculation
873 $start_time = PMA_DBI_fetch_value(
874 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
877 <h3><?php
878 echo sprintf(
879 __('Network traffic since startup: %s'),
880 implode(' ', PMA_formatByteDown( $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))
883 </h3>
886 <?php
887 echo sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'),
888 PMA_timespanFormat($server_status['Uptime']),
889 PMA_localisedDate($start_time)) . "\n";
891 </p>
893 <?php
894 if ($server_master_status || $server_slave_status) {
895 echo '<p class="notice">';
896 if ($server_master_status && $server_slave_status) {
897 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
898 } elseif ($server_master_status) {
899 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
900 } elseif ($server_slave_status) {
901 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
903 echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
904 echo '</p>';
907 /* if the server works as master or slave in replication process, display useful information */
908 if ($server_master_status || $server_slave_status)
911 <hr class="clearfloat" />
913 <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
914 <?php
916 foreach ($replication_types as $type)
918 if (${"server_{$type}_status"}) {
919 PMA_replication_print_status_table($type);
922 unset($types);
926 <table id="serverstatustraffic" class="data noclick">
927 <thead>
928 <tr>
929 <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>
930 <th>&oslash; <?php echo __('per hour'); ?></th>
931 </tr>
932 </thead>
933 <tbody>
934 <tr class="odd">
935 <th class="name"><?php echo __('Received'); ?></th>
936 <td class="value"><?php echo
937 implode(' ',
938 PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?></td>
939 <td class="value"><?php echo
940 implode(' ',
941 PMA_formatByteDown(
942 $server_status['Bytes_received'] * $hour_factor, 3, 1)); ?></td>
943 </tr>
944 <tr class="even">
945 <th class="name"><?php echo __('Sent'); ?></th>
946 <td class="value"><?php echo
947 implode(' ',
948 PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?></td>
949 <td class="value"><?php echo
950 implode(' ',
951 PMA_formatByteDown(
952 $server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?></td>
953 </tr>
954 <tr class="odd">
955 <th class="name"><?php echo __('Total'); ?></th>
956 <td class="value"><?php echo
957 implode(' ',
958 PMA_formatByteDown(
959 $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)
960 ); ?></td>
961 <td class="value"><?php echo
962 implode(' ',
963 PMA_formatByteDown(
964 ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
965 * $hour_factor, 3, 1)
966 ); ?></td>
967 </tr>
968 </tbody>
969 </table>
971 <table id="serverstatusconnections" class="data noclick">
972 <thead>
973 <tr>
974 <th colspan="2"><?php echo __('Connections'); ?></th>
975 <th>&oslash; <?php echo __('per hour'); ?></th>
976 <th>%</th>
977 </tr>
978 </thead>
979 <tbody>
980 <tr class="odd">
981 <th class="name"><?php echo __('max. concurrent connections'); ?></th>
982 <td class="value"><?php echo
983 PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
984 <td class="value">--- </td>
985 <td class="value">--- </td>
986 </tr>
987 <tr class="even">
988 <th class="name"><?php echo __('Failed attempts'); ?></th>
989 <td class="value"><?php echo
990 PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
991 <td class="value"><?php echo
992 PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
993 4, 2, true); ?></td>
994 <td class="value"><?php echo
995 $server_status['Connections'] > 0
996 ? PMA_formatNumber(
997 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
998 0, 2, true) . '%'
999 : '--- '; ?></td>
1000 </tr>
1001 <tr class="odd">
1002 <th class="name"><?php echo __('Aborted'); ?></th>
1003 <td class="value"><?php echo
1004 PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
1005 <td class="value"><?php echo
1006 PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
1007 4, 2, true); ?></td>
1008 <td class="value"><?php echo
1009 $server_status['Connections'] > 0
1010 ? PMA_formatNumber(
1011 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
1012 0, 2, true) . '%'
1013 : '--- '; ?></td>
1014 </tr>
1015 <tr class="even">
1016 <th class="name"><?php echo __('Total'); ?></th>
1017 <td class="value"><?php echo
1018 PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
1019 <td class="value"><?php echo
1020 PMA_formatNumber($server_status['Connections'] * $hour_factor,
1021 4, 2); ?></td>
1022 <td class="value"><?php echo
1023 PMA_formatNumber(100, 0, 2); ?>%</td>
1024 </tr>
1025 </tbody>
1026 </table>
1027 <?php
1029 $url_params = array();
1031 $show_full_sql = !empty($_REQUEST['full']);
1032 if ($show_full_sql) {
1033 $url_params['full'] = 1;
1034 $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
1035 } else {
1036 $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
1038 if (PMA_DRIZZLE) {
1039 $sql_query = "SELECT
1040 p.id AS Id,
1041 p.username AS User,
1042 p.host AS Host,
1043 p.db AS db,
1044 p.command AS Command,
1045 p.time AS Time,
1046 p.state AS State,
1047 " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info
1048 FROM data_dictionary.PROCESSLIST p
1049 " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
1050 } else {
1051 $sql_query = $show_full_sql
1052 ? 'SHOW FULL PROCESSLIST'
1053 : 'SHOW PROCESSLIST';
1055 $result = PMA_DBI_query($sql_query);
1058 * Displays the page
1061 <table id="tableprocesslist" class="data clearfloat noclick">
1062 <thead>
1063 <tr>
1064 <th><?php echo __('Processes'); ?></th>
1065 <th><?php echo __('ID'); ?></th>
1066 <th><?php echo __('User'); ?></th>
1067 <th><?php echo __('Host'); ?></th>
1068 <th><?php echo __('Database'); ?></th>
1069 <th><?php echo __('Command'); ?></th>
1070 <th><?php echo __('Time'); ?></th>
1071 <th><?php echo __('Status'); ?></th>
1072 <th><?php echo __('SQL query'); ?>
1073 <a href="<?php echo $full_text_link; ?>"
1074 title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>">
1075 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?>text.png"
1076 alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>" />
1077 </a>
1078 </th>
1079 </tr>
1080 </thead>
1081 <tbody>
1082 <?php
1083 $odd_row = true;
1084 while ($process = PMA_DBI_fetch_assoc($result)) {
1085 $url_params['kill'] = $process['Id'];
1086 $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
1088 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
1089 <td><a href="<?php echo $kill_process ; ?>"><?php echo __('Kill'); ?></a></td>
1090 <td class="value"><?php echo $process['Id']; ?></td>
1091 <td><?php echo $process['User']; ?></td>
1092 <td><?php echo $process['Host']; ?></td>
1093 <td><?php echo ((! isset($process['db']) || ! strlen($process['db'])) ? '<i>' . __('None') . '</i>' : $process['db']); ?></td>
1094 <td><?php echo $process['Command']; ?></td>
1095 <td class="value"><?php echo $process['Time']; ?></td>
1096 <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
1097 <td>
1098 <?php
1099 if (empty($process['Info'])) {
1100 echo '---';
1101 } else {
1102 if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
1103 echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
1104 } else {
1105 echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
1109 </td>
1110 </tr>
1111 <?php
1112 $odd_row = ! $odd_row;
1115 </tbody>
1116 </table>
1117 <?php
1120 function printVariablesTable() {
1121 global $server_status, $server_variables, $allocationMap, $links;
1123 * Messages are built using the message name
1125 $strShowStatus = array(
1126 'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
1127 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
1128 '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.'),
1129 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
1130 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
1131 '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.'),
1132 'Created_tmp_files' => __('How many temporary files mysqld has created.'),
1133 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
1134 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
1135 '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.'),
1136 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
1137 'Flush_commands' => __('The number of executed FLUSH statements.'),
1138 'Handler_commit' => __('The number of internal COMMIT statements.'),
1139 'Handler_delete' => __('The number of times a row was deleted from a table.'),
1140 '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.'),
1141 '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.'),
1142 '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.'),
1143 '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.'),
1144 '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.'),
1145 '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.'),
1146 '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.'),
1147 'Handler_rollback' => __('The number of internal ROLLBACK statements.'),
1148 'Handler_update' => __('The number of requests to update a row in a table.'),
1149 'Handler_write' => __('The number of requests to insert a row in a table.'),
1150 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'),
1151 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'),
1152 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'),
1153 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'),
1154 '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.'),
1155 '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.'),
1156 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'),
1157 '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.'),
1158 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'),
1159 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'),
1160 '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.'),
1161 '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.'),
1162 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'),
1163 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'),
1164 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'),
1165 'Innodb_data_pending_reads' => __('The current number of pending reads.'),
1166 'Innodb_data_pending_writes' => __('The current number of pending writes.'),
1167 'Innodb_data_read' => __('The amount of data read so far, in bytes.'),
1168 'Innodb_data_reads' => __('The total number of data reads.'),
1169 'Innodb_data_writes' => __('The total number of data writes.'),
1170 'Innodb_data_written' => __('The amount of data written so far, in bytes.'),
1171 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'),
1172 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'),
1173 '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.'),
1174 'Innodb_log_write_requests' => __('The number of log write requests.'),
1175 'Innodb_log_writes' => __('The number of physical writes to the log file.'),
1176 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'),
1177 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'),
1178 'Innodb_os_log_pending_writes' => __('Pending log file writes.'),
1179 'Innodb_os_log_written' => __('The number of bytes written to the log file.'),
1180 'Innodb_pages_created' => __('The number of pages created.'),
1181 '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.'),
1182 'Innodb_pages_read' => __('The number of pages read.'),
1183 'Innodb_pages_written' => __('The number of pages written.'),
1184 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'),
1185 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'),
1186 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'),
1187 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'),
1188 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'),
1189 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'),
1190 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'),
1191 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'),
1192 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'),
1193 '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.'),
1194 '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.'),
1195 '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.'),
1196 'Key_read_requests' => __('The number of requests to read a key block from the cache.'),
1197 '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.'),
1198 'Key_write_requests' => __('The number of requests to write a key block to the cache.'),
1199 'Key_writes' => __('The number of physical writes of a key block to disk.'),
1200 '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.'),
1201 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'),
1202 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'),
1203 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'),
1204 'Open_files' => __('The number of files that are open.'),
1205 'Open_streams' => __('The number of streams that are open (used mainly for logging).'),
1206 'Open_tables' => __('The number of tables that are open.'),
1207 '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.'),
1208 'Qcache_free_memory' => __('The amount of free memory for query cache.'),
1209 'Qcache_hits' => __('The number of cache hits.'),
1210 'Qcache_inserts' => __('The number of queries added to the cache.'),
1211 '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.'),
1212 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'),
1213 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'),
1214 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'),
1215 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'),
1216 '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.'),
1217 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'),
1218 '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.)'),
1219 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'),
1220 'Select_scan' => __('The number of joins that did a full scan of the first table.'),
1221 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'),
1222 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'),
1223 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'),
1224 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'),
1225 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'),
1226 '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.'),
1227 'Sort_range' => __('The number of sorts that were done with ranges.'),
1228 'Sort_rows' => __('The number of sorted rows.'),
1229 'Sort_scan' => __('The number of sorts that were done by scanning the table.'),
1230 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'),
1231 '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.'),
1232 '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.'),
1233 'Threads_connected' => __('The number of currently open connections.'),
1234 '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.)'),
1235 'Threads_running' => __('The number of threads that are not sleeping.')
1239 * define some alerts
1241 // name => max value before alert
1242 $alerts = array(
1243 // lower is better
1244 // variable => max value
1245 'Aborted_clients' => 0,
1246 'Aborted_connects' => 0,
1248 'Binlog_cache_disk_use' => 0,
1250 'Created_tmp_disk_tables' => 0,
1252 'Handler_read_rnd' => 0,
1253 'Handler_read_rnd_next' => 0,
1255 'Innodb_buffer_pool_pages_dirty' => 0,
1256 'Innodb_buffer_pool_reads' => 0,
1257 'Innodb_buffer_pool_wait_free' => 0,
1258 'Innodb_log_waits' => 0,
1259 'Innodb_row_lock_time_avg' => 10, // ms
1260 'Innodb_row_lock_time_max' => 50, // ms
1261 'Innodb_row_lock_waits' => 0,
1263 'Slow_queries' => 0,
1264 'Delayed_errors' => 0,
1265 'Select_full_join' => 0,
1266 'Select_range_check' => 0,
1267 'Sort_merge_passes' => 0,
1268 'Opened_tables' => 0,
1269 'Table_locks_waited' => 0,
1270 'Qcache_lowmem_prunes' => 0,
1272 'Qcache_free_blocks' => isset($server_status['Qcache_total_blocks']) ? $server_status['Qcache_total_blocks'] / 5 : 0,
1273 'Slow_launch_threads' => 0,
1275 // depends on Key_read_requests
1276 // normaly lower then 1:0.01
1277 'Key_reads' => isset($server_status['Key_read_requests']) ? (0.01 * $server_status['Key_read_requests']) : 0,
1278 // depends on Key_write_requests
1279 // normaly nearly 1:1
1280 'Key_writes' => isset($server_status['Key_write_requests']) ? (0.9 * $server_status['Key_write_requests']) : 0,
1282 'Key_buffer_fraction' => 0.5,
1284 // alert if more than 95% of thread cache is in use
1285 'Threads_cached' => isset($server_variables['thread_cache_size']) ? 0.95 * $server_variables['thread_cache_size'] : 0
1287 // higher is better
1288 // variable => min value
1289 //'Handler read key' => '> ',
1293 <table class="data sortable noclick" id="serverstatusvariables">
1294 <col class="namecol" />
1295 <col class="valuecol" />
1296 <col class="descrcol" />
1297 <thead>
1298 <tr>
1299 <th><?php echo __('Variable'); ?></th>
1300 <th><?php echo __('Value'); ?></th>
1301 <th><?php echo __('Description'); ?></th>
1302 </tr>
1303 </thead>
1304 <tbody>
1305 <?php
1307 $odd_row = false;
1308 foreach ($server_status as $name => $value) {
1309 $odd_row = !$odd_row;
1311 <tr class="<?php echo $odd_row ? 'odd' : 'even'; echo isset($allocationMap[$name])?' s_'.$allocationMap[$name]:''; ?>">
1312 <th class="name"><?php echo htmlspecialchars(str_replace('_',' ',$name)) . PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); ?>
1313 </th>
1314 <td class="value"><?php
1315 if (isset($alerts[$name])) {
1316 if ($value > $alerts[$name]) {
1317 echo '<span class="attention">';
1318 } else {
1319 echo '<span class="allfine">';
1322 if ('%' === substr($name, -1, 1)) {
1323 echo PMA_formatNumber($value, 0, 2) . ' %';
1324 } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
1325 echo PMA_formatNumber($value, 3, 1);
1326 } elseif (is_numeric($value) && $value == (int) $value) {
1327 echo PMA_formatNumber($value, 3, 0);
1328 } elseif (is_numeric($value)) {
1329 echo PMA_formatNumber($value, 3, 1);
1330 } else {
1331 echo htmlspecialchars($value);
1333 if (isset($alerts[$name])) {
1334 echo '</span>';
1336 ?></td>
1337 <td class="descr">
1338 <?php
1339 if (isset($strShowStatus[$name ])) {
1340 echo $strShowStatus[$name];
1343 if (isset($links[$name])) {
1344 foreach ($links[$name] as $link_name => $link_url) {
1345 if ('doc' == $link_name) {
1346 echo PMA_showMySQLDocu($link_url, $link_url);
1347 } else {
1348 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
1349 "\n";
1352 unset($link_url, $link_name);
1355 </td>
1356 </tr>
1357 <?php
1360 </tbody>
1361 </table>
1362 <?php
1365 function printMonitor() {
1366 global $server_status, $server_db_isLocal;
1368 <div class="monitorLinks">
1369 <a href="#pauseCharts">
1370 <img src="themes/dot.gif" class="icon ic_play" alt="" />
1371 <?php echo __('Start Monitor'); ?>
1372 </a>
1373 <a href="#settingsPopup" rel="popupLink" style="display:none;">
1374 <img src="themes/dot.gif" class="icon ic_s_cog" alt="" />
1375 <?php echo __('Settings'); ?>
1376 </a>
1377 <?php if (!PMA_DRIZZLE) { ?>
1378 <a href="#monitorInstructionsDialog">
1379 <img src="themes/dot.gif" class="icon ic_b_help" alt="" />
1380 <?php echo __('Instructions/Setup'); ?>
1381 </a>
1382 <?php } ?>
1383 <a href="#endChartEditMode" style="display:none;">
1384 <img src="themes/dot.gif" class="icon ic_s_okay" alt="" />
1385 <?php echo __('Done rearranging/editing charts'); ?>
1386 </a>
1387 </div>
1389 <div class="popupContent settingsPopup">
1390 <a href="#addNewChart">
1391 <img src="themes/dot.gif" class="icon ic_b_chart" alt="" />
1392 <?php echo __('Add chart'); ?>
1393 </a> |
1394 <a href="#rearrangeCharts"> <?php echo __('Rearrange/edit charts'); ?></a><br>
1396 <?php echo __('Refresh rate:'); refreshList('gridChartRefresh'); ?><br>
1397 </p>
1399 <?php echo __('Chart columns:'); ?>
1400 <select name="chartColumns">
1401 <option>1</option>
1402 <option>2</option>
1403 <option>3</option>
1404 <option>4</option>
1405 <option>5</option>
1406 <option>6</option>
1407 <option>7</option>
1408 <option>8</option>
1409 <option>9</option>
1410 <option>10</option>
1411 </select>
1412 </p>
1413 <a href="#clearMonitorConfig"><?php echo __('Clear monitor config'); ?></a>
1414 </div>
1416 <div id="monitorInstructionsDialog" title="<?php echo __('Monitor Instructions'); ?>" style="display:none;">
1417 <?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%'); ?>
1418 <p></p>
1419 <img class="ajaxIcon" src="<?php echo $GLOBALS['pmaThemeImage']; ?>ajax_clock_small.gif" alt="Loading">
1420 <div class="ajaxContent">
1421 </div>
1422 <div class="monitorUse" style="display:none;">
1423 <p></p>
1424 <?php echo __('<b>Using the monitor:</b><br/> 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.<p>When you get to see a sudden spike in activity, select the relevant time span on any chart by holding down the left mouse button and panning over the chart. This will load statistics from the logs helping you find what caused the activity spike.</p>');
1427 <img class="icon ic_s_attention" src="themes/dot.gif" alt="">
1428 <?php echo __('<b>Please note:</b> 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.'); ?>
1429 </p>
1430 </div>
1431 </div>
1433 <div id="addChartDialog" title="Add chart" style="display:none;">
1434 <div id="tabGridVariables">
1435 <p><input type="text" name="chartTitle" value="<?php echo __('Chart Title'); ?>" /></p>
1436 <?php if ($server_db_isLocal) { ?>
1437 <input type="radio" name="chartType" value="cpu" id="chartCPU">
1438 <label for="chartCPU"><?php echo __('CPU Usage'); ?></label><br/>
1440 <input type="radio" name="chartType" value="memory" id="chartMemory">
1441 <label for="chartMemory"><?php echo __('Memory Usage'); ?></label><br/>
1443 <input type="radio" name="chartType" value="swap" id="chartSwap">
1444 <label for="chartSwap"><?php echo __('Swap Usage'); ?></label><br/>
1445 <?php } ?>
1446 <input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked">
1447 <label for="chartStatusVar"><?php echo __('Status variable(s)'); ?></label><br/>
1448 <div id="chartVariableSettings">
1449 <label for="chartSeries"><?php echo __('Select series:'); ?></label><br>
1450 <select id="chartSeries" name="varChartList" size="1">
1451 <option><?php echo __('Commonly monitored'); ?></option>
1452 <option>Processes</option>
1453 <option>Questions</option>
1454 <option>Connections</option>
1455 <option>Bytes_sent</option>
1456 <option>Bytes_received</option>
1457 <option>Threads_connected</option>
1458 <option>Created_tmp_disk_tables</option>
1459 <option>Handler_read_first</option>
1460 <option>Innodb_buffer_pool_wait_free</option>
1461 <option>Key_reads</option>
1462 <option>Open_tables</option>
1463 <option>Select_full_join</option>
1464 <option>Slow_queries</option>
1465 </select><br>
1466 <label for="variableInput"><?php echo __('or type variable name:'); ?> </label>
1467 <input type="text" name="variableInput" id="variableInput" />
1468 <p></p>
1469 <input type="checkbox" name="differentialValue" id="differentialValue" value="differential" checked="checked" />
1470 <label for="differentialValue"><?php echo __('Display as differential value'); ?></label><br>
1471 <input type="checkbox" id="useDivisor" name="useDivisor" value="1" />
1472 <label for="useDivisor"><?php echo __('Apply a divisor'); ?></label>
1473 <span class="divisorInput" style="display:none;">
1474 <input type="text" name="valueDivisor" size="4" value="1">
1475 (<a href="#kibDivisor"><?php echo __('KiB'); ?></a>, <a href="#mibDivisor"><?php echo __('MiB'); ?></a>)
1476 </span><br>
1478 <input type="checkbox" id="useUnit" name="useUnit" value="1" />
1479 <label for="useUnit"><?php echo __('Append unit to data values'); ?></label>
1481 <span class="unitInput" style="display:none;">
1482 <input type="text" name="valueUnit" size="4" value="">
1483 </span>
1485 <a href="#submitAddSeries"><b><?php echo __('Add this series'); ?></b></a>
1486 <span id="clearSeriesLink" style="display:none;">
1487 | <a href="#submitClearSeries"><?php echo __('Clear series'); ?></a>
1488 </span>
1489 </p>
1490 <?php echo __('Series in Chart:'); ?><br/>
1491 <span id="seriesPreview">
1492 <i><?php echo __('None'); ?></i>
1493 </span>
1494 </div>
1495 </div>
1496 </div>
1498 <div id="loadingLogsDialog" title="<?php echo __('Loading logs'); ?>" style="display:none;">
1499 </div>
1501 <?php if (!PMA_DRIZZLE) { ?>
1502 <div id="logAnalyseDialog" title="<?php echo __('Log statistics'); ?>" style="display:none;">
1503 <p> <?php echo __('Selected time range:'); ?>
1504 <input type="text" name="dateStart" class="datetimefield" value="" /> -
1505 <input type="text" name="dateEnd" class="datetimefield" value="" /></p>
1506 <input type="checkbox" id="limitTypes" value="1" checked="checked" />
1507 <label for="limitTypes">
1508 <?php echo __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements'); ?>
1509 </label>
1510 <br/>
1511 <input type="checkbox" id="removeVariables" value="1" checked="checked" />
1512 <label for="removeVariables">
1513 <?php echo __('Remove variable data in INSERT statements for better grouping'); ?>
1514 </label>
1516 <?php echo __('<p>Choose from which log you want the statistics to be generated from.</p> Results are grouped by query text.'); ?>
1517 </div>
1519 <div id="queryAnalyzerDialog" title="<?php echo __('Query analyzer'); ?>" style="display:none;">
1520 <textarea id="sqlquery"> </textarea>
1521 <p></p>
1522 <div class="placeHolder"></div>
1523 </div>
1524 <?php } ?>
1526 <table border="0" class="clearfloat" id="chartGrid">
1528 </table>
1529 <div id="logTable">
1530 <br/>
1531 </div>
1533 <script type="text/javascript">
1534 variableNames = [ <?php
1535 $i=0;
1536 foreach ($server_status as $name=>$value) {
1537 if (is_numeric($value)) {
1538 if ($i++ > 0) echo ", ";
1539 echo "'".$name."'";
1542 ?> ];
1543 </script>
1544 <?php
1547 /* Builds a <select> list for refresh rates */
1548 function refreshList($name,$defaultRate=5, $refreshRates=Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600)) {
1550 <select name="<?php echo $name; ?>">
1551 <?php
1552 foreach ($refreshRates as $rate) {
1553 $selected = ($rate == $defaultRate)?' selected="selected"':'';
1555 if ($rate<60)
1556 echo '<option value="'.$rate.'"'.$selected.'>'.sprintf(_ngettext('%d second', '%d seconds', $rate), $rate).'</option>';
1557 else
1558 echo '<option value="'.$rate.'"'.$selected.'>'.sprintf(_ngettext('%d minute', '%d minutes', $rate/60), $rate/60).'</option>';
1561 </select>
1562 <?php
1566 * cleanup of some deprecated values
1568 * @param array &$server_status
1570 function cleanDeprecated(&$server_status) {
1571 $deprecated = array(
1572 'Com_prepare_sql' => 'Com_stmt_prepare',
1573 'Com_execute_sql' => 'Com_stmt_execute',
1574 'Com_dealloc_sql' => 'Com_stmt_close',
1577 foreach ($deprecated as $old => $new) {
1578 if (isset($server_status[$old]) && isset($server_status[$new])) {
1579 unset($server_status[$old]);
1585 * Sends the footer
1587 require './libraries/footer.inc.php';