Merge remote-tracking branch 'origin/master' into drizzle
[phpmyadmin.git] / server_status.php
blobcc60b0f4f9ac09c29cf868ea6283daade106e693
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 * Function to output refresh rate selection.
26 function PMA_choose_refresh_rate() {
27 echo '<option value="5">' . __('Refresh rate') . '</option>';
28 foreach (array(1, 2, 5, 20, 40, 60, 120, 300, 600) as $rate) {
29 if ($rate % 60 == 0) {
30 $minrate = $rate / 60;
31 echo '<option value="' . $rate . '">' . sprintf(_ngettext('%d minute', '%d minutes', $minrate), $minrate) . '</option>';
32 } else {
33 echo '<option value="' . $rate . '">' . sprintf(_ngettext('%d second', '%d seconds', $rate), $rate) . '</option>';
38 /**
39 * Ajax request
42 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
43 // Send with correct charset
44 header('Content-Type: text/html; charset=UTF-8');
46 if (isset($_REQUEST['logging_vars'])) {
47 if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
48 $value = PMA_sqlAddslashes($_REQUEST['varValue']);
49 if (!is_numeric($value)) $value="'".$value."'";
51 if (!preg_match("/[^a-zA-Z0-9_]+/",$_REQUEST['varName']))
52 PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = '.$value);
56 $loggingVars = PMA_DBI_fetch_result(
57 "SHOW GLOBAL VARIABLES WHERE Variable_name IN (
58 'general_log', 'slow_query_log', 'long_query_time', 'log_output')", 0, 1);
59 exit(json_encode($loggingVars));
62 // real-time charting data
63 if (isset($_REQUEST['chart_data'])) {
64 switch($_REQUEST['type']) {
65 case 'proc':
66 $c = PMA_DBI_fetch_result("SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1);
67 $result = PMA_DBI_query('SHOW PROCESSLIST');
68 $num_procs = PMA_DBI_num_rows($result);
70 $ret = array(
71 'x' => microtime(true)*1000,
72 'y_proc' => $num_procs,
73 'y_conn' => $c['Connections']
76 exit(json_encode($ret));
78 case 'queries':
79 if (PMA_DRIZZLE) {
80 $sql = "SELECT concat('Com_', variable_name), variable_value
81 FROM data_dictionary.GLOBAL_STATEMENTS
82 WHERE variable_value > 0
83 UNION
84 SELECT variable_name, variable_value
85 FROM data_dictionary.GLOBAL_STATUS
86 WHERE variable_name = 'Questions'";
87 $queries = PMA_DBI_fetch_result($sql, 0, 1);
88 } else {
89 $queries = PMA_DBI_fetch_result(
90 "SHOW GLOBAL STATUS
91 WHERE (Variable_name LIKE 'Com_%' OR Variable_name = 'Questions')
92 AND Value > 0'", 0, 1);
94 cleanDeprecated($queries);
95 // admin commands are not queries
96 unset($queries['Com_admin_commands']);
97 $questions = $queries['Questions'];
98 unset($queries['Questions']);
100 //$sum=array_sum($queries);
101 $ret = array(
102 'x' => microtime(true)*1000,
103 'y' => $questions,
104 'pointInfo' => $queries
107 exit(json_encode($ret));
109 case 'traffic':
110 $traffic = PMA_DBI_fetch_result(
111 "SHOW GLOBAL STATUS
112 WHERE Variable_name = 'Bytes_received'
113 OR Variable_name = 'Bytes_sent'", 0, 1);
115 $ret = array(
116 'x' => microtime(true)*1000,
117 'y_sent' => $traffic['Bytes_sent'],
118 'y_received' => $traffic['Bytes_received']
121 exit(json_encode($ret));
123 case 'chartgrid':
124 $ret = json_decode($_REQUEST['requiredData'], true);
125 $statusVars = array();
126 $sysinfo = $cpuload = $memory = 0;
128 foreach ($ret as $chart_id => $chartNodes) {
129 foreach ($chartNodes as $node_id => $node) {
130 switch ($node['dataType']) {
131 case 'statusvar':
132 // Some white list filtering
133 if (!preg_match('/[^a-zA-Z_]+/',$node['name']))
134 $statusVars[] = $node['name'];
135 break;
137 case 'proc':
138 $result = PMA_DBI_query('SHOW PROCESSLIST');
139 $ret[$chart_id][$node_id]['y'] = PMA_DBI_num_rows($result);
140 break;
142 case 'cpu':
143 if (!$sysinfo) {
144 require_once('libraries/sysinfo.lib.php');
145 $sysinfo = getSysInfo();
147 if (!$cpuload)
148 $cpuload = $sysinfo->loadavg();
150 if (PHP_OS == 'Linux') {
151 $ret[$chart_id][$node_id]['idle'] = $cpuload['idle'];
152 $ret[$chart_id][$node_id]['busy'] = $cpuload['busy'];
153 } else
154 $ret[$chart_id][$node_id]['y'] = $cpuload['loadavg'];
156 break;
158 case 'memory':
159 if (!$sysinfo) {
160 require_once('libraries/sysinfo.lib.php');
161 $sysinfo = getSysInfo();
163 if (!$memory)
164 $memory = $sysinfo->memory();
166 $ret[$chart_id][$node_id]['y'] = $memory[$node['name']];
167 break;
172 $vars = PMA_DBI_fetch_result(
173 "SHOW GLOBAL STATUS
174 WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1);
176 foreach ($ret as $chart_id => $chartNodes) {
177 foreach ($chartNodes as $node_id => $node) {
178 if ($node['dataType'] == 'statusvar')
179 $ret[$chart_id][$node_id]['y'] = $vars[$node['name']];
183 $ret['x'] = microtime(true)*1000;
185 exit(json_encode($ret));
189 if (isset($_REQUEST['log_data'])) {
190 $start = intval($_REQUEST['time_start']);
191 $end = intval($_REQUEST['time_end']);
193 if ($_REQUEST['type'] == 'slow') {
194 $q = 'SELECT SUM(query_time) AS TIME(query_time), SUM(lock_time) as lock_time, '.
195 'SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined, sql_text, COUNT(sql_text) AS \'#\' '.
196 'FROM `mysql`.`slow_log` WHERE event_time > FROM_UNIXTIME('.$start.') '.
197 'AND event_time < FROM_UNIXTIME('.$end.') GROUP BY sql_text';
199 $result = PMA_DBI_try_query($q);
201 $return = array('rows' => array(), 'sum' => array());
202 $type = '';
204 while ($row = PMA_DBI_fetch_assoc($result)) {
205 $type = substr($row['sql_text'],0,strpos($row['sql_text'],' '));
206 $return['sum'][$type]++;
207 $return['rows'][] = $row;
210 $return['sum']['TOTAL'] = array_sum($return['sum']);
212 PMA_DBI_free_result($result);
214 exit(json_encode($return));
217 if ($_REQUEST['type'] == 'general') {
218 $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, server_id, argument, count(argument) as \'#\' FROM `mysql`.`general_log` WHERE command_type=\'Query\' '.
219 'AND event_time > FROM_UNIXTIME('.$start.') AND event_time < FROM_UNIXTIME('.$end.') '.
220 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' GROUP by argument'; // HAVING count > 1';
222 $result = PMA_DBI_try_query($q);
224 $return = array('rows' => array(), 'sum' => array());
225 $type = '';
226 $insertTables = array();
227 $insertTablesFirst = -1;
228 $i = 0;
230 while ($row = PMA_DBI_fetch_assoc($result)) {
231 preg_match('/^(\w+)\s/',$row['argument'],$match);
232 $type = strtolower($match[1]);
233 // Ignore undefined index warning, just increase counter by one
234 @$return['sum'][$type] += $row['#'];
236 if ($type=='insert' || $type=='update') {
237 // Group inserts if selected
238 if ($type=='insert' && isset($_REQUEST['groupInserts']) && $_REQUEST['groupInserts'] && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i',$row['argument'],$matches)) {
239 $insertTables[$matches[2]]++;
240 if ($insertTables[$matches[2]] > 1) {
241 $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
243 // Add a ... to the end of this query to indicate that there's been other queries
244 if ($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.')
245 $return['rows'][$insertTablesFirst]['argument'] .= '<br/>...';
247 // Group this value, thus do not add to the result list
248 continue;
249 } else {
250 $insertTablesFirst = $i;
251 $insertTables[$matches[2]] += $row['#'] - 1;
255 // Cut off big selects, but append byte count therefor
256 if (strlen($row['argument']) > 180) {
257 $row['argument'] = substr($row['argument'],0,160) . '... [' .
258 PMA_formatByteDown(strlen($row['argument']), 2).']';
261 $return['rows'][] = $row;
262 $i++;
265 $return['sum']['TOTAL'] = array_sum($return['sum']);
266 $return['numRows'] = count($return['rows']);
268 PMA_DBI_free_result($result);
270 exit(json_encode($return));
277 * Replication library
279 if (PMA_DRIZZLE) {
280 $server_master_status = false;
281 $server_slave_status = false;
282 } else {
283 require './libraries/replication.inc.php';
284 require_once './libraries/replication_gui.lib.php';
288 * JS Includes
291 $GLOBALS['js_include'][] = 'server_status.js';
292 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
293 $GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
294 $GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
295 $GLOBALS['js_include'][] = 'jquery/jquery.json-2.2.js';
296 $GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
297 $GLOBALS['js_include'][] = 'jquery/jquery.sortableTable.js';
298 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
299 // Charting
300 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
301 /* Files required for chart exporting */
302 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
303 $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
304 $GLOBALS['js_include'][] = 'canvg/canvg.js';
305 $GLOBALS['js_include'][] = 'canvg/rgbcolor.js';
308 * flush status variables if requested
310 if (isset($_REQUEST['flush'])) {
311 $_flush_commands = array(
312 'STATUS',
313 'TABLES',
314 'QUERY CACHE',
317 if (in_array($_REQUEST['flush'], $_flush_commands)) {
318 PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
320 unset($_flush_commands);
324 * Kills a selected process
326 if (!empty($_REQUEST['kill'])) {
327 if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
328 $message = PMA_Message::success(__('Thread %s was successfully killed.'));
329 } else {
330 $message = PMA_Message::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
332 $message->addParam($_REQUEST['kill']);
333 //$message->display();
339 * get status from server
341 $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
342 if (PMA_DRIZZLE) {
343 // Drizzle doesn't put query statistics into variables, add it
344 $sql = "SELECT concat('Com_', variable_name), variable_value
345 FROM data_dictionary.GLOBAL_STATEMENTS";
346 $statements = PMA_DBI_fetch_result($sql, 0, 1);
347 $server_status = array_merge($server_status, $statements);
351 * for some calculations we require also some server settings
353 $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
356 * cleanup of some deprecated values
358 cleanDeprecated($server_status);
361 * calculate some values
363 // Key_buffer_fraction
364 if (isset($server_status['Key_blocks_unused'])
365 && isset($server_variables['key_cache_block_size'])
366 && isset($server_variables['key_buffer_size'])) {
367 $server_status['Key_buffer_fraction_%'] =
369 - $server_status['Key_blocks_unused']
370 * $server_variables['key_cache_block_size']
371 / $server_variables['key_buffer_size']
372 * 100;
373 } elseif (isset($server_status['Key_blocks_used'])
374 && isset($server_variables['key_buffer_size'])) {
375 $server_status['Key_buffer_fraction_%'] =
376 $server_status['Key_blocks_used']
377 * 1024
378 / $server_variables['key_buffer_size'];
381 // Ratio for key read/write
382 if (isset($server_status['Key_writes'])
383 && isset($server_status['Key_write_requests'])
384 && $server_status['Key_write_requests'] > 0) {
385 $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
388 if (isset($server_status['Key_reads'])
389 && isset($server_status['Key_read_requests'])
390 && $server_status['Key_read_requests'] > 0) {
391 $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
394 // Threads_cache_hitrate
395 if (isset($server_status['Threads_created'])
396 && isset($server_status['Connections'])
397 && $server_status['Connections'] > 0) {
398 $server_status['Threads_cache_hitrate_%'] =
400 - $server_status['Threads_created']
401 / $server_status['Connections']
402 * 100;
405 // Format Uptime_since_flush_status : show as days, hours, minutes, seconds
406 if (isset($server_status['Uptime_since_flush_status'])) {
407 $server_status['Uptime_since_flush_status'] = PMA_timespanFormat($server_status['Uptime_since_flush_status']);
411 * split variables in sections
413 $allocations = array(
414 // variable name => section
415 // variable names match when they begin with the given string
417 'Com_' => 'com',
418 'Innodb_' => 'innodb',
419 'Ndb_' => 'ndb',
420 'Handler_' => 'handler',
421 'Qcache_' => 'qcache',
422 'Threads_' => 'threads',
423 'Slow_launch_threads' => 'threads',
425 'Binlog_cache_' => 'binlog_cache',
426 'Created_tmp_' => 'created_tmp',
427 'Key_' => 'key',
429 'Delayed_' => 'delayed',
430 'Not_flushed_delayed_rows' => 'delayed',
432 'Flush_commands' => 'query',
433 'Last_query_cost' => 'query',
434 'Slow_queries' => 'query',
435 'Queries' => 'query',
436 'Prepared_stmt_count' => 'query',
438 'Select_' => 'select',
439 'Sort_' => 'sort',
441 'Open_tables' => 'table',
442 'Opened_tables' => 'table',
443 'Open_table_definitions' => 'table',
444 'Opened_table_definitions' => 'table',
445 'Table_locks_' => 'table',
447 'Rpl_status' => 'repl',
448 'Slave_' => 'repl',
450 'Tc_' => 'tc',
452 'Ssl_' => 'ssl',
454 'Open_files' => 'files',
455 'Open_streams' => 'files',
456 'Opened_files' => 'files',
459 $sections = array(
460 // section => section name (description)
461 'com' => 'Com',
462 'query' => __('SQL query'),
463 'innodb' => 'InnoDB',
464 'ndb' => 'NDB',
465 'handler' => __('Handler'),
466 'qcache' => __('Query cache'),
467 'threads' => __('Threads'),
468 'binlog_cache' => __('Binary log'),
469 'created_tmp' => __('Temporary data'),
470 'delayed' => __('Delayed inserts'),
471 'key' => __('Key cache'),
472 'select' => __('Joins'),
473 'repl' => __('Replication'),
474 'sort' => __('Sorting'),
475 'table' => __('Tables'),
476 'tc' => __('Transaction coordinator'),
477 'files' => __('Files'),
478 'ssl' => 'SSL',
479 'other' => __('Other')
483 * define some needfull links/commands
485 // variable or section name => (name => url)
486 $links = array();
488 $links['table'][__('Flush (close) all tables')]
489 = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
490 $links['table'][__('Show open tables')]
491 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
492 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
494 if ($server_master_status) {
495 $links['repl'][__('Show slave hosts')]
496 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
497 '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
498 $links['repl'][__('Show master status')] = '#replication_master';
500 if ($server_slave_status) {
501 $links['repl'][__('Show slave status')] = '#replication_slave';
504 $links['repl']['doc'] = 'replication';
506 $links['qcache'][__('Flush query cache')]
507 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
508 PMA_generate_common_url();
509 $links['qcache']['doc'] = 'query_cache';
511 //$links['threads'][__('Show processes')]
512 // = 'server_processlist.php?' . PMA_generate_common_url();
513 $links['threads']['doc'] = 'mysql_threads';
515 $links['key']['doc'] = 'myisam_key_cache';
517 $links['binlog_cache']['doc'] = 'binary_log';
519 $links['Slow_queries']['doc'] = 'slow_query_log';
521 $links['innodb'][__('Variables')]
522 = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
523 $links['innodb'][__('InnoDB Status')]
524 = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
525 PMA_generate_common_url();
526 $links['innodb']['doc'] = 'innodb';
529 // Variable to contain all com_ variables (query statistics)
530 $used_queries = array();
532 // Variable to map variable names to their respective section name (used for js category filtering)
533 $allocationMap = array();
535 // Variable to mark used sections
536 $categoryUsed = array();
538 // sort vars into arrays
539 foreach ($server_status as $name => $value) {
540 $section_found = false;
541 foreach ($allocations as $filter => $section) {
542 if (strpos($name, $filter) !== false) {
543 $allocationMap[$name] = $section;
544 $categoryUsed[$section] = true;
545 $section_found = true;
546 if ($section == 'com' && $value > 0) $used_queries[$name] = $value;
547 break; // Only exits inner loop
550 if (!$section_found) {
551 $allocationMap[$name] = 'other';
552 $categoryUsed['other'] = true;
556 // admin commands are not queries (e.g. they include COM_PING, which is excluded from $server_status['Questions'])
557 unset($used_queries['Com_admin_commands']);
559 /* Ajax request refresh */
560 if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
561 switch($_REQUEST['show']) {
562 case 'query_statistics':
563 printQueryStatistics();
564 exit();
565 case 'server_traffic':
566 printServerTraffic();
567 exit();
568 case 'variables_table':
569 // Prints the variables table
570 printVariablesTable();
571 exit();
573 default:
574 break;
579 * start output
583 * Does the common work
585 require './libraries/server_common.inc.php';
589 * Displays the links
591 require './libraries/server_links.inc.php';
593 $server = 1;
594 if (isset($_REQUEST['server']) && intval($_REQUEST['server'])) $server = intval($_REQUEST['server']);
596 $server_db_isLocal = strtolower($cfg['Servers'][$server]['host']) == 'localhost'
597 || $cfg['Servers'][$server]['host'] == '127.0.0.1'
598 || $cfg['Servers'][$server]['host'] == '::1';
601 <script type="text/javascript">
602 pma_token = '<?php echo $_SESSION[' PMA_token ']; ?>';
603 url_query = '<?php echo str_replace('&amp;','&',$url_query);?>';
604 server_time_diff = new Date().getTime() - <?php echo microtime(true)*1000; ?>;
605 server_os = '<?php echo PHP_OS; ?>';
606 is_superuser = <?php echo PMA_isSuperuser()?'true':'false'; ?>;
607 server_db_isLocal = <?php echo ($server_db_isLocal)?'true':'false'; ?>;
608 </script>
609 <div id="serverstatus">
610 <h2><?php
612 * Displays the sub-page heading
614 if ($GLOBALS['cfg']['MainPageIconic']) {
615 echo '<img class="icon ic_s_status" src="themes/dot.gif" width="16" height="16" alt="" />';
618 echo __('Runtime Information');
620 ?></h2>
621 <div id="serverStatusTabs">
622 <ul>
623 <li><a href="#statustabs_traffic"><?php echo __('Server'); ?></a></li>
624 <li><a href="#statustabs_queries"><?php echo __('Query statistics'); ?></a></li>
625 <li><a href="#statustabs_allvars"><?php echo __('All status variables'); ?></a></li>
626 <li><a href="#statustabs_charting"><?php echo __('Monitor'); ?></a></li>
627 </ul>
629 <div id="statustabs_traffic">
630 <div class="buttonlinks">
631 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=server_traffic&amp;' . PMA_generate_common_url(); ?>" >
632 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
633 <?php echo __('Refresh'); ?>
634 </a>
635 <span class="refreshList" style="display:none;">
636 <label for="trafficChartRefresh"><?php echo __('Refresh rate: '); ?></label>
637 <?php refreshList('trafficChartRefresh'); ?>
638 </span>
640 <a class="tabChart livetrafficLink" href="#">
641 <?php echo __('Live traffic chart'); ?>
642 </a>
643 <a class="tabChart liveconnectionsLink" href="#">
644 <?php echo __('Live conn./process chart'); ?>
645 </a>
646 </div>
647 <div class="tabInnerContent">
648 <?php printServerTraffic(); ?>
649 </div>
650 </div>
651 <div id="statustabs_queries">
652 <div class="buttonlinks">
653 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=query_statistics&amp;' . PMA_generate_common_url(); ?>" >
654 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
655 <?php echo __('Refresh'); ?>
656 </a>
657 <span class="refreshList" style="display:none;">
658 <label for="queryChartRefresh"><?php echo __('Refresh rate: '); ?></label>
659 <?php refreshList('queryChartRefresh'); ?>
660 </span>
661 <a class="tabChart livequeriesLink" href="#">
662 <?php echo __('Live query chart'); ?>
663 </a>
664 </div>
665 <div class="tabInnerContent">
666 <?php printQueryStatistics(); ?>
667 </div>
668 </div>
669 <div id="statustabs_allvars">
670 <fieldset id="tableFilter">
671 <div class="buttonlinks">
672 <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=variables_table&amp;' . PMA_generate_common_url(); ?>" >
673 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
674 <?php echo __('Refresh'); ?>
675 </a>
676 </div>
677 <legend>Filters</legend>
678 <div class="formelement">
679 <label for="filterText"><?php echo __('Containing the word:'); ?></label>
680 <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
681 </div>
682 <div class="formelement">
683 <input type="checkbox" name="filterAlert" id="filterAlert">
684 <label for="filterAlert"><?php echo __('Show only alert values'); ?></label>
685 </div>
686 <div class="formelement">
687 <select id="filterCategory" name="filterCategory">
688 <option value=''><?php echo __('Filter by category...'); ?></option>
689 <?php
690 foreach ($sections as $section_id => $section_name) {
691 if (isset($categoryUsed[$section_id])) {
693 <option value='<?php echo $section_id; ?>'><?php echo $section_name; ?></option>
694 <?php
698 </select>
699 </div>
700 </fieldset>
701 <div id="linkSuggestions" class="defaultLinks" style="display:none">
702 <p class="notice"><?php echo __('Related links:'); ?>
703 <?php
704 foreach ($links as $section_name => $section_links) {
705 echo '<span class="status_'.$section_name.'"> ';
706 $i=0;
707 foreach ($section_links as $link_name => $link_url) {
708 if ($i > 0) echo ', ';
709 if ('doc' == $link_name) {
710 echo PMA_showMySQLDocu($link_url, $link_url);
711 } else {
712 echo '<a href="' . $link_url . '">' . $link_name . '</a>';
714 $i++;
716 echo '</span>';
718 unset($link_url, $link_name, $i);
720 </p>
721 </div>
722 <div class="tabInnerContent">
723 <?php printVariablesTable(); ?>
724 </div>
725 </div>
727 <div id="statustabs_charting">
728 <?php printMonitor(); ?>
729 </div>
730 </div>
731 </div>
733 <?php
735 function printQueryStatistics() {
736 global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
738 $hour_factor = 3600 / $server_status['Uptime'];
740 $total_queries = array_sum($used_queries);
743 <h3 id="serverstatusqueries">
744 <?php
745 /* l10n: Questions is the name of a MySQL Status variable */
746 echo sprintf(__('Questions since startup: %s'),PMA_formatNumber($total_queries, 0)) . ' ';
747 echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
749 <br>
750 <span>
751 <?php
752 echo '&oslash; '.__('per hour').': ';
753 echo PMA_formatNumber($total_queries * $hour_factor, 0);
754 echo '<br>';
756 echo '&oslash; '.__('per minute').': ';
757 echo PMA_formatNumber( $total_queries * 60 / $server_status['Uptime'], 0);
758 echo '<br>';
760 if ($total_queries / $server_status['Uptime'] >= 1) {
761 echo '&oslash; '.__('per second').': ';
762 echo PMA_formatNumber( $total_queries / $server_status['Uptime'], 0);
765 </span>
766 </h3>
767 <?php
769 // reverse sort by value to show most used statements first
770 arsort($used_queries);
772 $odd_row = true;
773 $count_displayed_rows = 0;
774 $perc_factor = 100 / $total_queries; //(- $server_status['Connections']);
778 <table id="serverstatusqueriesdetails" class="data sortable">
779 <col class="namecol" />
780 <col class="valuecol" span="3" />
781 <thead>
782 <tr><th><?php echo __('Statements'); ?></th>
783 <th><?php
784 /* l10n: # = Amount of queries */
785 echo __('#');
787 <th>&oslash; <?php echo __('per hour'); ?></th>
788 <th>%</th>
789 </tr>
790 </thead>
791 <tbody>
793 <?php
794 $chart_json = array();
795 $query_sum = array_sum($used_queries);
796 $other_sum = 0;
797 foreach ($used_queries as $name => $value) {
798 $odd_row = !$odd_row;
800 // For the percentage column, use Questions - Connections, because
801 // the number of connections is not an item of the Query types
802 // but is included in Questions. Then the total of the percentages is 100.
803 $name = str_replace(array('Com_', '_'), array('', ' '), $name);
805 // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
806 if ($value < $query_sum * 0.02 && count($chart_json)>6)
807 $other_sum += $value;
808 else $chart_json[$name] = $value;
810 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
811 <th class="name"><?php echo htmlspecialchars($name); ?></th>
812 <td class="value"><?php echo PMA_formatNumber($value, 5, 0, true); ?></td>
813 <td class="value"><?php echo
814 PMA_formatNumber($value * $hour_factor, 4, 1, true); ?></td>
815 <td class="value"><?php echo
816 PMA_formatNumber($value * $perc_factor, 0, 2); ?>%</td>
817 </tr>
818 <?php
821 </tbody>
822 </table>
824 <div id="serverstatusquerieschart">
825 <span style="display:none;">
826 <?php
827 if ($other_sum > 0)
828 $chart_json[__('Other')] = $other_sum;
830 echo json_encode($chart_json);
832 </span>
833 </div>
834 <?php
837 function printServerTraffic() {
838 global $server_status,$PMA_PHP_SELF;
839 global $server_master_status, $server_slave_status, $replication_types;
841 $hour_factor = 3600 / $server_status['Uptime'];
844 * starttime calculation
846 $start_time = PMA_DBI_fetch_value(
847 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
850 <h3><?php
851 echo sprintf(
852 __('Network traffic since startup: %s'),
853 implode(' ', PMA_formatByteDown( $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))
856 </h3>
859 <?php
860 echo sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'),
861 PMA_timespanFormat($server_status['Uptime']),
862 PMA_localisedDate($start_time)) . "\n";
864 </p>
866 <?php
867 if ($server_master_status || $server_slave_status) {
868 echo '<p class="notice">';
869 if ($server_master_status && $server_slave_status) {
870 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
871 } elseif ($server_master_status) {
872 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
873 } elseif ($server_slave_status) {
874 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
876 echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
877 echo '</p>';
880 /* if the server works as master or slave in replication process, display useful information */
881 if ($server_master_status || $server_slave_status)
884 <hr class="clearfloat" />
886 <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
887 <?php
889 foreach ($replication_types as $type)
891 if (${"server_{$type}_status"}) {
892 PMA_replication_print_status_table($type);
895 unset($types);
899 <table id="serverstatustraffic" class="data">
900 <thead>
901 <tr>
902 <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>
903 <th>&oslash; <?php echo __('per hour'); ?></th>
904 </tr>
905 </thead>
906 <tbody>
907 <tr class="noclick odd">
908 <th class="name"><?php echo __('Received'); ?></th>
909 <td class="value"><?php echo
910 implode(' ',
911 PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?></td>
912 <td class="value"><?php echo
913 implode(' ',
914 PMA_formatByteDown(
915 $server_status['Bytes_received'] * $hour_factor, 3, 1)); ?></td>
916 </tr>
917 <tr class="noclick even">
918 <th class="name"><?php echo __('Sent'); ?></th>
919 <td class="value"><?php echo
920 implode(' ',
921 PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?></td>
922 <td class="value"><?php echo
923 implode(' ',
924 PMA_formatByteDown(
925 $server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?></td>
926 </tr>
927 <tr class="noclick odd">
928 <th class="name"><?php echo __('Total'); ?></th>
929 <td class="value"><?php echo
930 implode(' ',
931 PMA_formatByteDown(
932 $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)
933 ); ?></td>
934 <td class="value"><?php echo
935 implode(' ',
936 PMA_formatByteDown(
937 ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
938 * $hour_factor, 3, 1)
939 ); ?></td>
940 </tr>
941 </tbody>
942 </table>
944 <table id="serverstatusconnections" class="data">
945 <thead>
946 <tr>
947 <th colspan="2"><?php echo __('Connections'); ?></th>
948 <th>&oslash; <?php echo __('per hour'); ?></th>
949 <th>%</th>
950 </tr>
951 </thead>
952 <tbody>
953 <tr class="noclick odd">
954 <th class="name"><?php echo __('max. concurrent connections'); ?></th>
955 <td class="value"><?php echo
956 PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
957 <td class="value">--- </td>
958 <td class="value">--- </td>
959 </tr>
960 <tr class="noclick even">
961 <th class="name"><?php echo __('Failed attempts'); ?></th>
962 <td class="value"><?php echo
963 PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
964 <td class="value"><?php echo
965 PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
966 4, 2, true); ?></td>
967 <td class="value"><?php echo
968 $server_status['Connections'] > 0
969 ? PMA_formatNumber(
970 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
971 0, 2, true) . '%'
972 : '--- '; ?></td>
973 </tr>
974 <tr class="noclick odd">
975 <th class="name"><?php echo __('Aborted'); ?></th>
976 <td class="value"><?php echo
977 PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
978 <td class="value"><?php echo
979 PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
980 4, 2, true); ?></td>
981 <td class="value"><?php echo
982 $server_status['Connections'] > 0
983 ? PMA_formatNumber(
984 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
985 0, 2, true) . '%'
986 : '--- '; ?></td>
987 </tr>
988 <tr class="noclick even">
989 <th class="name"><?php echo __('Total'); ?></th>
990 <td class="value"><?php echo
991 PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
992 <td class="value"><?php echo
993 PMA_formatNumber($server_status['Connections'] * $hour_factor,
994 4, 2); ?></td>
995 <td class="value"><?php echo
996 PMA_formatNumber(100, 0, 2); ?>%</td>
997 </tr>
998 </tbody>
999 </table>
1000 <?php
1002 $url_params = array();
1004 $show_full_sql = !empty($_REQUEST['full']);
1005 if ($show_full_sql) {
1006 $url_params['full'] = 1;
1007 $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
1008 } else {
1009 $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
1011 if (PMA_DRIZZLE) {
1012 $sql_query = "SELECT
1013 p.id AS Id,
1014 p.username AS User,
1015 p.host AS Host,
1016 p.db AS db,
1017 p.command AS Command,
1018 p.time AS Time,
1019 p.state AS State,
1020 " . ($show_full_sql ? 's.query' : 'p.info') . " AS Info
1021 FROM data_dictionary.PROCESSLIST p
1022 " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
1023 } else {
1024 $sql_query = $show_full_sql
1025 ? 'SHOW FULL PROCESSLIST'
1026 : 'SHOW PROCESSLIST';
1028 $result = PMA_DBI_query($sql_query);
1031 * Displays the page
1034 <table id="tableprocesslist" class="data clearfloat">
1035 <thead>
1036 <tr>
1037 <th><?php echo __('Processes'); ?></th>
1038 <th><?php echo __('ID'); ?></th>
1039 <th><?php echo __('User'); ?></th>
1040 <th><?php echo __('Host'); ?></th>
1041 <th><?php echo __('Database'); ?></th>
1042 <th><?php echo __('Command'); ?></th>
1043 <th><?php echo __('Time'); ?></th>
1044 <th><?php echo __('Status'); ?></th>
1045 <th><?php echo __('SQL query'); ?>
1046 <a href="<?php echo $full_text_link; ?>"
1047 title="<?php echo empty($full) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>">
1048 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . (empty($_REQUEST['full']) ? 'full' : 'partial'); ?>text.png"
1049 alt="<?php echo empty($_REQUEST['full']) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>" />
1050 </a>
1051 </th>
1052 </tr>
1053 </thead>
1054 <tbody>
1055 <?php
1056 $odd_row = true;
1057 while ($process = PMA_DBI_fetch_assoc($result)) {
1058 $url_params['kill'] = $process['Id'];
1059 $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
1061 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
1062 <td><a href="<?php echo $kill_process ; ?>"><?php echo __('Kill'); ?></a></td>
1063 <td class="value"><?php echo $process['Id']; ?></td>
1064 <td><?php echo $process['User']; ?></td>
1065 <td><?php echo $process['Host']; ?></td>
1066 <td><?php echo ((! isset($process['db']) || ! strlen($process['db'])) ? '<i>' . __('None') . '</i>' : $process['db']); ?></td>
1067 <td><?php echo $process['Command']; ?></td>
1068 <td class="value"><?php echo $process['Time']; ?></td>
1069 <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
1070 <td><?php echo (empty($process['Info']) ? '---' : PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']))); ?></td>
1071 </tr>
1072 <?php
1073 $odd_row = ! $odd_row;
1076 </tbody>
1077 </table>
1078 <?php
1081 function printVariablesTable() {
1082 global $server_status, $server_variables, $allocationMap, $links;
1084 * Messages are built using the message name
1086 $strShowStatus = array(
1087 'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
1088 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
1089 '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.'),
1090 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
1091 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
1092 '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.'),
1093 'Created_tmp_files' => __('How many temporary files mysqld has created.'),
1094 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
1095 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
1096 '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.'),
1097 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
1098 'Flush_commands' => __('The number of executed FLUSH statements.'),
1099 'Handler_commit' => __('The number of internal COMMIT statements.'),
1100 'Handler_delete' => __('The number of times a row was deleted from a table.'),
1101 '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.'),
1102 '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.'),
1103 '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.'),
1104 '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.'),
1105 '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.'),
1106 '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.'),
1107 '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.'),
1108 'Handler_rollback' => __('The number of internal ROLLBACK statements.'),
1109 'Handler_update' => __('The number of requests to update a row in a table.'),
1110 'Handler_write' => __('The number of requests to insert a row in a table.'),
1111 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'),
1112 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'),
1113 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'),
1114 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'),
1115 '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.'),
1116 '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.'),
1117 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'),
1118 '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.'),
1119 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'),
1120 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'),
1121 '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.'),
1122 '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.'),
1123 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'),
1124 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'),
1125 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'),
1126 'Innodb_data_pending_reads' => __('The current number of pending reads.'),
1127 'Innodb_data_pending_writes' => __('The current number of pending writes.'),
1128 'Innodb_data_read' => __('The amount of data read so far, in bytes.'),
1129 'Innodb_data_reads' => __('The total number of data reads.'),
1130 'Innodb_data_writes' => __('The total number of data writes.'),
1131 'Innodb_data_written' => __('The amount of data written so far, in bytes.'),
1132 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'),
1133 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'),
1134 '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.'),
1135 'Innodb_log_write_requests' => __('The number of log write requests.'),
1136 'Innodb_log_writes' => __('The number of physical writes to the log file.'),
1137 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'),
1138 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'),
1139 'Innodb_os_log_pending_writes' => __('Pending log file writes.'),
1140 'Innodb_os_log_written' => __('The number of bytes written to the log file.'),
1141 'Innodb_pages_created' => __('The number of pages created.'),
1142 '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.'),
1143 'Innodb_pages_read' => __('The number of pages read.'),
1144 'Innodb_pages_written' => __('The number of pages written.'),
1145 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'),
1146 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'),
1147 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'),
1148 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'),
1149 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'),
1150 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'),
1151 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'),
1152 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'),
1153 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'),
1154 '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.'),
1155 '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.'),
1156 '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.'),
1157 'Key_read_requests' => __('The number of requests to read a key block from the cache.'),
1158 '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.'),
1159 'Key_write_requests' => __('The number of requests to write a key block to the cache.'),
1160 'Key_writes' => __('The number of physical writes of a key block to disk.'),
1161 '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.'),
1162 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'),
1163 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'),
1164 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'),
1165 'Open_files' => __('The number of files that are open.'),
1166 'Open_streams' => __('The number of streams that are open (used mainly for logging).'),
1167 'Open_tables' => __('The number of tables that are open.'),
1168 '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.'),
1169 'Qcache_free_memory' => __('The amount of free memory for query cache.'),
1170 'Qcache_hits' => __('The number of cache hits.'),
1171 'Qcache_inserts' => __('The number of queries added to the cache.'),
1172 '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.'),
1173 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'),
1174 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'),
1175 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'),
1176 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'),
1177 '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.'),
1178 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'),
1179 '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.)'),
1180 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'),
1181 'Select_scan' => __('The number of joins that did a full scan of the first table.'),
1182 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'),
1183 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'),
1184 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'),
1185 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'),
1186 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'),
1187 '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.'),
1188 'Sort_range' => __('The number of sorts that were done with ranges.'),
1189 'Sort_rows' => __('The number of sorted rows.'),
1190 'Sort_scan' => __('The number of sorts that were done by scanning the table.'),
1191 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'),
1192 '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.'),
1193 '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.'),
1194 'Threads_connected' => __('The number of currently open connections.'),
1195 '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.)'),
1196 'Threads_running' => __('The number of threads that are not sleeping.')
1200 * define some alerts
1202 // name => max value before alert
1203 $alerts = array(
1204 // lower is better
1205 // variable => max value
1206 'Aborted_clients' => 0,
1207 'Aborted_connects' => 0,
1209 'Binlog_cache_disk_use' => 0,
1211 'Created_tmp_disk_tables' => 0,
1213 'Handler_read_rnd' => 0,
1214 'Handler_read_rnd_next' => 0,
1216 'Innodb_buffer_pool_pages_dirty' => 0,
1217 'Innodb_buffer_pool_reads' => 0,
1218 'Innodb_buffer_pool_wait_free' => 0,
1219 'Innodb_log_waits' => 0,
1220 'Innodb_row_lock_time_avg' => 10, // ms
1221 'Innodb_row_lock_time_max' => 50, // ms
1222 'Innodb_row_lock_waits' => 0,
1224 'Slow_queries' => 0,
1225 'Delayed_errors' => 0,
1226 'Select_full_join' => 0,
1227 'Select_range_check' => 0,
1228 'Sort_merge_passes' => 0,
1229 'Opened_tables' => 0,
1230 'Table_locks_waited' => 0,
1231 'Qcache_lowmem_prunes' => 0,
1233 'Qcache_free_blocks' => isset($server_status['Qcache_total_blocks']) ? $server_status['Qcache_total_blocks'] / 5 : 0,
1234 'Slow_launch_threads' => 0,
1236 // depends on Key_read_requests
1237 // normaly lower then 1:0.01
1238 'Key_reads' => isset($server_status['Key_read_requests']) ? (0.01 * $server_status['Key_read_requests']) : 0,
1239 // depends on Key_write_requests
1240 // normaly nearly 1:1
1241 'Key_writes' => isset($server_status['Key_write_requests']) ? (0.9 * $server_status['Key_write_requests']) : 0,
1243 'Key_buffer_fraction' => 0.5,
1245 // alert if more than 95% of thread cache is in use
1246 'Threads_cached' => isset($server_variables['thread_cache_size']) ? 0.95 * $server_variables['thread_cache_size'] : 0
1248 // higher is better
1249 // variable => min value
1250 //'Handler read key' => '> ',
1254 <table class="data sortable" id="serverstatusvariables">
1255 <col class="namecol" />
1256 <col class="valuecol" />
1257 <col class="descrcol" />
1258 <thead>
1259 <tr>
1260 <th><?php echo __('Variable'); ?></th>
1261 <th><?php echo __('Value'); ?></th>
1262 <th><?php echo __('Description'); ?></th>
1263 </tr>
1264 </thead>
1265 <tbody>
1266 <?php
1268 $odd_row = false;
1269 foreach ($server_status as $name => $value) {
1270 $odd_row = !$odd_row;
1272 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; echo isset($allocationMap[$name])?' s_'.$allocationMap[$name]:''; ?>">
1273 <th class="name"><?php echo htmlspecialchars(str_replace('_',' ',$name)) . PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); ?>
1274 </th>
1275 <td class="value"><?php
1276 if (isset($alerts[$name])) {
1277 if ($value > $alerts[$name]) {
1278 echo '<span class="attention">';
1279 } else {
1280 echo '<span class="allfine">';
1283 if ('%' === substr($name, -1, 1)) {
1284 echo PMA_formatNumber($value, 0, 2) . ' %';
1285 } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
1286 echo PMA_formatNumber($value, 3, 1);
1287 } elseif (is_numeric($value) && $value == (int) $value) {
1288 echo PMA_formatNumber($value, 3, 0);
1289 } elseif (is_numeric($value)) {
1290 echo PMA_formatNumber($value, 3, 1);
1291 } else {
1292 echo htmlspecialchars($value);
1294 if (isset($alerts[$name])) {
1295 echo '</span>';
1297 ?></td>
1298 <td class="descr">
1299 <?php
1300 if (isset($strShowStatus[$name ])) {
1301 echo $strShowStatus[$name];
1304 if (isset($links[$name])) {
1305 foreach ($links[$name] as $link_name => $link_url) {
1306 if ('doc' == $link_name) {
1307 echo PMA_showMySQLDocu($link_url, $link_url);
1308 } else {
1309 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
1310 "\n";
1313 unset($link_url, $link_name);
1316 </td>
1317 </tr>
1318 <?php
1321 </tbody>
1322 </table>
1323 <?php
1326 function printMonitor() {
1327 global $server_status, $server_db_isLocal;
1329 <div class="monitorLinks">
1330 <a href="#pauseCharts">
1331 <img src="themes/dot.gif" class="icon ic_play" alt="" />
1332 <?php echo __('Start Monitor'); ?>
1333 </a>
1334 <a href="#settingsPopup" rel="popupLink" style="display:none;">
1335 <img src="themes/dot.gif" class="icon ic_s_cog" alt="" />
1336 <?php echo __('Settings'); ?>
1337 </a>
1338 <?php if (!PMA_DRIZZLE) { ?>
1339 <a href="#monitorInstructionsDialog">
1340 <img src="themes/dot.gif" class="icon ic_b_help" alt="" />
1341 <?php echo __('Instructions/Setup'); ?>
1342 </a>
1343 <?php } ?>
1344 <a href="#endChartEditMode" style="display:none;">
1345 <img src="themes/dot.gif" class="icon ic_s_okay" alt="" />
1346 <?php echo __('Done rearranging/editing charts'); ?>
1347 </a>
1348 </div>
1350 <div class="popupContent settingsPopup">
1351 <a href="#addNewChart">
1352 <img src="themes/dot.gif" class="icon ic_b_chart" alt="" />
1353 <?php echo __('Add chart'); ?>
1354 </a> |
1355 <a href="#rearrangeCharts"> <?php echo __('Rearrange/edit charts'); ?></a><br>
1357 <?php echo __('Refresh rate:'); refreshList('gridChartRefresh'); ?><br>
1358 </p>
1360 <?php echo __('Chart columns:'); ?>
1361 <select name="chartColumns">
1362 <option>1</option>
1363 <option>2</option>
1364 <option>3</option>
1365 <option>4</option>
1366 <option>5</option>
1367 <option>6</option>
1368 <option>7</option>
1369 <option>8</option>
1370 <option>9</option>
1371 <option>10</option>
1372 </select>
1373 </p>
1374 <a href="#clearMonitorConfig"><?php echo __('Clear monitor config'); ?></a>
1375 </div>
1377 <div id="monitorInstructionsDialog" title="<?php echo __('Monitor Instructions'); ?>" style="display:none;">
1378 <?php echo __('The phpMyAdmin Monitor can assist you in optimizing the server configuration and track down time intensive
1379 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
1380 general_log produces a lot of data and increases server load by up to 15%'); ?>
1381 <p></p>
1382 <img class="ajaxIcon" src="<?php echo $GLOBALS['pmaThemeImage']; ?>ajax_clock_small.gif" alt="Loading">
1383 <div class="ajaxContent">
1384 </div>
1385 <div class="monitorUse" style="display:none;">
1386 <p></p>
1387 <?php echo __('<b>Using the monitor:</b><br/>
1388 Ok, you are good to go! Once you click \'Start monitor\' your browser will refresh all displayed charts
1389 in a regular interval. You may add charts and change the refresh rate under \'Settings\', or remove any chart
1390 using the cog icon on each respective chart.
1391 <p>When you get to see a sudden spike in activity, select the relevant time span on any chart by holding down the
1392 left mouse button and panning over the chart. This will load statistics from the logs helping you find what caused the
1393 activity spike.</p>');
1396 <img class="icon ic_s_attention" src="themes/dot.gif" alt="">
1397 <?php echo __('<b>Please note:</b>
1398 Enabling the general_log may increase the server load by 5-15%. Also be aware that generating statistics from the logs is a
1399 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.
1400 '); ?>
1401 </p>
1402 </div>
1403 </div>
1405 <div id="addChartDialog" title="Add chart" style="display:none;">
1406 <div id="tabGridVariables">
1407 <p><input type="text" name="chartTitle" value="<?php echo __('Chart Title'); ?>" /></p>
1408 <?php if ($server_db_isLocal) { ?>
1409 <input type="radio" name="chartType" value="cpu" id="chartCPU">
1410 <label for="chartCPU"><?php echo __('CPU Usage'); ?></label><br/>
1412 <input type="radio" name="chartType" value="memory" id="chartMemory">
1413 <label for="chartMemory"><?php echo __('Memory Usage'); ?></label><br/>
1415 <input type="radio" name="chartType" value="swap" id="chartSwap">
1416 <label for="chartSwap"><?php echo __('Swap Usage'); ?></label><br/>
1417 <?php } ?>
1418 <input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked">
1419 <label for="chartStatusVar"><?php echo __('Status variable(s)'); ?></label><br/>
1420 <div id="chartVariableSettings">
1421 <label for="chartSeries"><?php echo __('Select series:'); ?></label><br>
1422 <select id="chartSeries" name="varChartList" size="1">
1423 <option><?php echo __('Commonly monitored'); ?></option>
1424 <option>Processes</option>
1425 <option>Questions</option>
1426 <option>Connections</option>
1427 <option>Bytes_sent</option>
1428 <option>Bytes_received</option>
1429 <option>Threads_connected</option>
1430 <option>Created_tmp_disk_tables</option>
1431 <option>Handler_read_first</option>
1432 <option>Innodb_buffer_pool_wait_free</option>
1433 <option>Key_reads</option>
1434 <option>Open_tables</option>
1435 <option>Select_full_join</option>
1436 <option>Slow_queries</option>
1437 </select><br>
1438 <label for="variableInput"><?php echo __('or type variable name:'); ?> </label>
1439 <input type="text" name="variableInput" id="variableInput" />
1440 <p></p>
1441 <input type="checkbox" name="differentialValue" id="differentialValue" value="differential" checked="checked" />
1442 <label for="differentialValue"><?php echo __('Display as differential value'); ?></label><br>
1443 <input type="checkbox" id="useDivisor" name="useDivisor" value="1" />
1444 <label for="useDivisor"><?php echo __('Apply a divisor'); ?></label>
1445 <span class="divisorInput" style="display:none;">
1446 <input type="text" name="valueDivisor" size="4" value="1">
1447 (<a href="#kibDivisor"><?php echo __('KiB'); ?></a>, <a href="#mibDivisor"><?php echo __('MiB'); ?></a>)
1448 </span><br>
1450 <input type="checkbox" id="useUnit" name="useUnit" value="1" />
1451 <label for="useUnit"><?php echo __('Append unit to data values'); ?></label>
1453 <span class="unitInput" style="display:none;">
1454 <input type="text" name="valueUnit" size="4" value="">
1455 </span>
1457 <a href="#submitAddSeries"><b><?php echo __('Add this series'); ?></b></a>
1458 <span id="clearSeriesLink" style="display:none;">
1459 | <a href="#submitClearSeries"><?php echo __('Clear series'); ?></a>
1460 </span>
1461 </p>
1462 <?php echo __('Series in Chart:'); ?><br/>
1463 <span id="seriesPreview">
1464 <i><?php echo __('None'); ?></i>
1465 </span>
1466 </div>
1467 </div>
1468 </div>
1470 <div id="loadingLogsDialog" title="<?php echo __('Loading logs'); ?>" style="display:none;">
1471 </div>
1473 <?php if (!PMA_DRIZZLE) { ?>
1474 <div id="logAnalyseDialog" title="<?php echo __('Log statistics'); ?>">
1475 </div>
1476 <?php } ?>
1478 <table border="0" class="clearfloat" id="chartGrid">
1480 </table>
1481 <div id="logTable">
1482 <br/>
1483 </div>
1485 <script type="text/javascript">
1486 variableNames = [ <?php
1487 $i=0;
1488 foreach ($server_status as $name=>$value) {
1489 if (is_numeric($value)) {
1490 if ($i++ > 0) echo ", ";
1491 echo "'".$name."'";
1494 ?> ];
1495 </script>
1496 <?php
1499 /* Builds a <select> list for refresh rates */
1500 function refreshList($name,$defaultRate=5, $refreshRates=Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600)) {
1502 <select name="<?php echo $name; ?>">
1503 <?php
1504 foreach ($refreshRates as $rate) {
1505 $selected = ($rate == $defaultRate)?' selected="selected"':'';
1507 if ($rate<60)
1508 echo '<option value="'.$rate.'"'.$selected.'>'.sprintf(_ngettext('%d second', '%d seconds', $rate), $rate).'</option>';
1509 else
1510 echo '<option value="'.$rate.'"'.$selected.'>'.sprintf(_ngettext('%d minute', '%d minutes', $rate/60), $rate/60).'</option>';
1513 </select>
1514 <?php
1518 * cleanup of some deprecated values
1520 * @param array &$server_status
1522 function cleanDeprecated(&$server_status) {
1523 $deprecated = array(
1524 'Com_prepare_sql' => 'Com_stmt_prepare',
1525 'Com_execute_sql' => 'Com_stmt_execute',
1526 'Com_dealloc_sql' => 'Com_stmt_close',
1529 foreach ($deprecated as $old => $new) {
1530 if (isset($server_status[$old]) && isset($server_status[$new])) {
1531 unset($server_status[$old]);
1537 * Sends the footer
1539 require './libraries/footer.inc.php';