2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * displays status variables with descriptions and some hints an optmizing
5 * + reset status variables
11 * no need for variables importing
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';
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']) {
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);
40 'x' => microtime(true)*1000,
41 'y_proc' => $num_procs,
42 'y_conn' => $c['Connections']
45 exit(json_encode($ret));
48 $queries = PMA_DBI_fetch_result(
50 WHERE (Variable_name LIKE 'Com_%' OR Variable_name = 'Questions')
51 AND Value > 0'", 0, 1);
52 cleanDeprecated($queries);
53 // admin commands are not queries
54 unset($queries['Com_admin_commands']);
55 $questions = $queries['Questions'];
56 unset($queries['Questions']);
58 //$sum=array_sum($queries);
60 'x' => microtime(true)*1000,
62 'pointInfo' => $queries
65 exit(json_encode($ret));
68 $traffic = PMA_DBI_fetch_result(
70 WHERE Variable_name = 'Bytes_received'
71 OR Variable_name = 'Bytes_sent'", 0, 1);
74 'x' => microtime(true)*1000,
75 'y_sent' => $traffic['Bytes_sent'],
76 'y_received' => $traffic['Bytes_received']
79 exit(json_encode($ret));
82 $ret = json_decode($_REQUEST['requiredData'], true);
83 $statusVars = array();
84 $sysinfo = $cpuload = $memory = 0;
86 foreach ($ret as $chart_id => $chartNodes) {
87 foreach ($chartNodes as $node_id => $node) {
88 switch ($node['dataType']) {
90 // Some white list filtering
91 if (!preg_match('/[^a-zA-Z_]+/',$node['name']))
92 $statusVars[] = $node['name'];
96 $result = PMA_DBI_query('SHOW PROCESSLIST');
97 $ret[$chart_id][$node_id]['y'] = PMA_DBI_num_rows($result);
102 require_once('libraries/sysinfo.lib.php');
103 $sysinfo = getSysInfo();
106 $cpuload = $sysinfo->loadavg();
108 if (PHP_OS
== 'Linux') {
109 $ret[$chart_id][$node_id]['idle'] = $cpuload['idle'];
110 $ret[$chart_id][$node_id]['busy'] = $cpuload['busy'];
112 $ret[$chart_id][$node_id]['y'] = $cpuload['loadavg'];
118 require_once('libraries/sysinfo.lib.php');
119 $sysinfo = getSysInfo();
122 $memory = $sysinfo->memory();
124 $ret[$chart_id][$node_id]['y'] = $memory[$node['name']];
130 $vars = PMA_DBI_fetch_result(
132 WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1);
134 foreach ($ret as $chart_id => $chartNodes) {
135 foreach ($chartNodes as $node_id => $node) {
136 if ($node['dataType'] == 'statusvar')
137 $ret[$chart_id][$node_id]['y'] = $vars[$node['name']];
141 $ret['x'] = microtime(true)*1000;
143 exit(json_encode($ret));
147 if (isset($_REQUEST['log_data'])) {
148 $start = intval($_REQUEST['time_start']);
149 $end = intval($_REQUEST['time_end']);
151 if ($_REQUEST['type'] == 'slow') {
152 $q = 'SELECT SUM(query_time) AS TIME(query_time), SUM(lock_time) as lock_time, '.
153 'SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined, sql_text, COUNT(sql_text) AS \'#\' '.
154 'FROM `mysql`.`slow_log` WHERE event_time > FROM_UNIXTIME('.$start.') '.
155 'AND event_time < FROM_UNIXTIME('.$end.') GROUP BY sql_text';
157 $result = PMA_DBI_try_query($q);
159 $return = array('rows' => array(), 'sum' => array());
162 while ($row = PMA_DBI_fetch_assoc($result)) {
163 $type = substr($row['sql_text'],0,strpos($row['sql_text'],' '));
164 $return['sum'][$type]++
;
165 $return['rows'][] = $row;
168 $return['sum']['TOTAL'] = array_sum($return['sum']);
170 PMA_DBI_free_result($result);
172 exit(json_encode($return));
175 if($_REQUEST['type'] == 'general') {
176 $limitTypes = (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes'])
177 ?
'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
179 $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, server_id, argument, count(argument) as \'#\' '.
180 'FROM `mysql`.`general_log` WHERE command_type=\'Query\' '.
181 'AND event_time > FROM_UNIXTIME('.$start.') AND event_time < FROM_UNIXTIME('.$end.') '.
182 $limitTypes . 'GROUP by argument'; // HAVING count > 1';
184 $result = PMA_DBI_try_query($q);
186 $return = array('rows' => array(), 'sum' => array());
188 $insertTables = array();
189 $insertTablesFirst = -1;
191 $removeVars = isset($_REQUEST['removeVariables']) && $_REQUEST['removeVariables'];
193 while ($row = PMA_DBI_fetch_assoc($result)) {
194 preg_match('/^(\w+)\s/',$row['argument'],$match);
195 $type = strtolower($match[1]);
197 if(!isset($return['sum'][$type])) $return['sum'][$type] = 0;
198 $return['sum'][$type] +
= $row['#'];
202 // Group inserts if selected
203 if($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i',$row['argument'],$matches)) {
204 $insertTables[$matches[2]]++
;
205 if ($insertTables[$matches[2]] > 1) {
206 $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
208 // Add a ... to the end of this query to indicate that there's been other queries
209 if($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.')
210 $return['rows'][$insertTablesFirst]['argument'] .= '<br/>...';
212 // Group this value, thus do not add to the result list
215 $insertTablesFirst = $i;
216 $insertTables[$matches[2]] +
= $row['#'] - 1;
222 // Cut off big inserts and updates, but append byte count therefor
223 if(strlen($row['argument']) > 180)
224 $row['argument'] = substr($row['argument'],0,160) . '... [' .
225 PMA_formatByteDown(strlen($row['argument']), 2).']';
232 $return['rows'][] = $row;
236 $return['sum']['TOTAL'] = array_sum($return['sum']);
237 $return['numRows'] = count($return['rows']);
239 PMA_DBI_free_result($result);
241 exit(json_encode($return));
245 if (isset($_REQUEST['logging_vars'])) {
246 if(isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
247 $value = PMA_sqlAddslashes($_REQUEST['varValue']);
248 if(!is_numeric($value)) $value="'".$value."'";
250 if(! preg_match("/[^a-zA-Z0-9_]+/",$_REQUEST['varName']))
251 PMA_DBI_query('SET GLOBAL '.$_REQUEST['varName'].' = '.$value);
255 $loggingVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES WHERE Variable_name IN ("general_log","slow_query_log","long_query_time","log_output")', 0, 1);
256 exit(json_encode($loggingVars));
259 if(isset($_REQUEST['query_analyzer'])) {
262 if ($profiling = PMA_profilingSupported())
263 PMA_DBI_query('SET PROFILING=1;');
265 // Do not cache query
266 $query = preg_replace('/^(\s*SELECT)/i','\\1 SQL_NO_CACHE',$_REQUEST['query']);
268 $result = PMA_DBI_try_query('EXPLAIN ' . $query);
269 $return['explain'] = PMA_DBI_fetch_assoc($result);
271 // In case an error happened
272 $return['error'] = PMA_DBI_getError();
274 PMA_DBI_free_result($result);
277 $return['profiling'] = array();
278 $result = PMA_DBI_try_query('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=1 ORDER BY seq');
279 while ($row = PMA_DBI_fetch_assoc($result)) {
280 $return['profiling'][]= $row;
282 PMA_DBI_free_result($result);
285 exit(json_encode($return));
291 * Replication library
293 require './libraries/replication.inc.php';
294 require_once './libraries/replication_gui.lib.php';
300 $GLOBALS['js_include'][] = 'server_status.js';
301 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
302 $GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
303 $GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
304 $GLOBALS['js_include'][] = 'jquery/jquery.json-2.2.js';
305 $GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
306 $GLOBALS['js_include'][] = 'jquery/jquery.sortableTable.js';
307 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
309 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
310 /* Files required for chart exporting */
311 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
312 $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
313 $GLOBALS['js_include'][] = 'canvg/canvg.js';
314 $GLOBALS['js_include'][] = 'canvg/rgbcolor.js';
315 $GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
316 $GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
319 * flush status variables if requested
321 if (isset($_REQUEST['flush'])) {
322 $_flush_commands = array(
328 if (in_array($_REQUEST['flush'], $_flush_commands)) {
329 PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
331 unset($_flush_commands);
335 * Kills a selected process
337 if (!empty($_REQUEST['kill'])) {
338 if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
339 $message = PMA_Message
::success(__('Thread %s was successfully killed.'));
341 $message = PMA_Message
::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
343 $message->addParam($_REQUEST['kill']);
344 //$message->display();
350 * get status from server
352 $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
355 * for some calculations we require also some server settings
357 $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
360 * cleanup of some deprecated values
362 cleanDeprecated($server_status);
365 * calculate some values
367 // Key_buffer_fraction
368 if (isset($server_status['Key_blocks_unused'])
369 && isset($server_variables['key_cache_block_size'])
370 && isset($server_variables['key_buffer_size'])) {
371 $server_status['Key_buffer_fraction_%'] =
373 - $server_status['Key_blocks_unused']
374 * $server_variables['key_cache_block_size']
375 / $server_variables['key_buffer_size']
377 } elseif (isset($server_status['Key_blocks_used'])
378 && isset($server_variables['key_buffer_size'])) {
379 $server_status['Key_buffer_fraction_%'] =
380 $server_status['Key_blocks_used']
382 / $server_variables['key_buffer_size'];
385 // Ratio for key read/write
386 if (isset($server_status['Key_writes'])
387 && isset($server_status['Key_write_requests'])
388 && $server_status['Key_write_requests'] > 0) {
389 $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
392 if (isset($server_status['Key_reads'])
393 && isset($server_status['Key_read_requests'])
394 && $server_status['Key_read_requests'] > 0) {
395 $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
398 // Threads_cache_hitrate
399 if (isset($server_status['Threads_created'])
400 && isset($server_status['Connections'])
401 && $server_status['Connections'] > 0) {
402 $server_status['Threads_cache_hitrate_%'] =
404 - $server_status['Threads_created']
405 / $server_status['Connections']
409 // Format Uptime_since_flush_status : show as days, hours, minutes, seconds
410 if (isset($server_status['Uptime_since_flush_status'])) {
411 $server_status['Uptime_since_flush_status'] = PMA_timespanFormat($server_status['Uptime_since_flush_status']);
415 * split variables in sections
417 $allocations = array(
418 // variable name => section
419 // variable names match when they begin with the given string
422 'Innodb_' => 'innodb',
424 'Handler_' => 'handler',
425 'Qcache_' => 'qcache',
426 'Threads_' => 'threads',
427 'Slow_launch_threads' => 'threads',
429 'Binlog_cache_' => 'binlog_cache',
430 'Created_tmp_' => 'created_tmp',
433 'Delayed_' => 'delayed',
434 'Not_flushed_delayed_rows' => 'delayed',
436 'Flush_commands' => 'query',
437 'Last_query_cost' => 'query',
438 'Slow_queries' => 'query',
439 'Queries' => 'query',
440 'Prepared_stmt_count' => 'query',
442 'Select_' => 'select',
445 'Open_tables' => 'table',
446 'Opened_tables' => 'table',
447 'Open_table_definitions' => 'table',
448 'Opened_table_definitions' => 'table',
449 'Table_locks_' => 'table',
451 'Rpl_status' => 'repl',
458 'Open_files' => 'files',
459 'Open_streams' => 'files',
460 'Opened_files' => 'files',
464 // section => section name (description)
466 'query' => __('SQL query'),
467 'innodb' => 'InnoDB',
469 'handler' => __('Handler'),
470 'qcache' => __('Query cache'),
471 'threads' => __('Threads'),
472 'binlog_cache' => __('Binary log'),
473 'created_tmp' => __('Temporary data'),
474 'delayed' => __('Delayed inserts'),
475 'key' => __('Key cache'),
476 'select' => __('Joins'),
477 'repl' => __('Replication'),
478 'sort' => __('Sorting'),
479 'table' => __('Tables'),
480 'tc' => __('Transaction coordinator'),
481 'files' => __('Files'),
486 * define some needfull links/commands
488 // variable or section name => (name => url)
491 $links['table'][__('Flush (close) all tables')]
492 = $PMA_PHP_SELF . '?flush=TABLES&' . PMA_generate_common_url();
493 $links['table'][__('Show open tables')]
494 = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
495 '&goto=server_status.php&' . PMA_generate_common_url();
497 if ($server_master_status) {
498 $links['repl'][__('Show slave hosts')]
499 = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
500 '&goto=server_status.php&' . PMA_generate_common_url();
501 $links['repl'][__('Show master status')] = '#replication_master';
503 if ($server_slave_status) {
504 $links['repl'][__('Show slave status')] = '#replication_slave';
507 $links['repl']['doc'] = 'replication';
509 $links['qcache'][__('Flush query cache')]
510 = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&' .
511 PMA_generate_common_url();
512 $links['qcache']['doc'] = 'query_cache';
514 //$links['threads'][__('Show processes')]
515 // = 'server_processlist.php?' . PMA_generate_common_url();
516 $links['threads']['doc'] = 'mysql_threads';
518 $links['key']['doc'] = 'myisam_key_cache';
520 $links['binlog_cache']['doc'] = 'binary_log';
522 $links['Slow_queries']['doc'] = 'slow_query_log';
524 $links['innodb'][__('Variables')]
525 = 'server_engines.php?engine=InnoDB&' . PMA_generate_common_url();
526 $links['innodb'][__('InnoDB Status')]
527 = 'server_engines.php?engine=InnoDB&page=Status&' .
528 PMA_generate_common_url();
529 $links['innodb']['doc'] = 'innodb';
532 // Variable to contain all com_ variables
533 $used_queries = array();
535 // Variable to map variable names to their respective section name (used for js category filtering)
536 $allocationMap = array();
538 // sort vars into arrays
539 foreach ($server_status as $name => $value) {
540 foreach ($allocations as $filter => $section) {
541 if (strpos($name, $filter) !== false) {
542 $allocationMap[$name] = $section;
543 if ($section == 'com' && $value > 0) $used_queries[$name] = $value;
544 break; // Only exits inner loop
549 // admin commands are not queries (e.g. they include COM_PING, which is excluded from $server_status['Questions'])
550 unset($used_queries['Com_admin_commands']);
552 /* Ajax request refresh */
553 if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
554 switch($_REQUEST['show']) {
555 case 'query_statistics':
556 printQueryStatistics();
558 case 'server_traffic':
559 printServerTraffic();
561 case 'variables_table':
562 // Prints the variables table
563 printVariablesTable();
576 * Does the common work
578 require './libraries/server_common.inc.php';
584 require './libraries/server_links.inc.php';
587 if (isset($_REQUEST['server']) && intval($_REQUEST['server'])) $server = intval($_REQUEST['server']);
589 $server_db_isLocal = strtolower($cfg['Servers'][$server]['host']) == 'localhost'
590 ||
$cfg['Servers'][$server]['host'] == '127.0.0.1'
591 ||
$cfg['Servers'][$server]['host'] == '::1';
594 <script type
="text/javascript">
595 pma_token
= '<?php echo $_SESSION[' PMA_token
']; ?>';
596 url_query
= '<?php echo str_replace('&
;','&',$url_query);?>';
597 server_time_diff
= new Date().getTime() - <?php
echo microtime(true)*1000; ?
>;
598 server_os
= '<?php echo PHP_OS; ?>';
599 is_superuser
= <?php
echo PMA_isSuperuser()?
'true':'false'; ?
>;
600 server_db_isLocal
= <?php
echo ($server_db_isLocal)?
'true':'false'; ?
>;
602 <div id
="serverstatus">
605 * Displays the sub-page heading
607 if ($GLOBALS['cfg']['MainPageIconic']) {
608 echo '<img class="icon ic_s_status" src="themes/dot.gif" width="16" height="16" alt="" />';
611 echo __('Runtime Information');
614 <div id
="serverStatusTabs">
616 <li
><a href
="#statustabs_traffic"><?php
echo __('Server'); ?
></a
></li
>
617 <li
><a href
="#statustabs_queries"><?php
echo __('Query statistics'); ?
></a
></li
>
618 <li
><a href
="#statustabs_allvars"><?php
echo __('All status variables'); ?
></a
></li
>
619 <li
><a href
="#statustabs_charting"><?php
echo __('Monitor'); ?
></a
></li
>
622 <div id
="statustabs_traffic">
623 <div
class="buttonlinks">
624 <a
class="tabRefresh" href
="<?php echo $PMA_PHP_SELF . '?show=server_traffic&' . PMA_generate_common_url(); ?>" >
625 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt
="ajax clock" style
="display: none;" />
626 <?php
echo __('Refresh'); ?
>
628 <span
class="refreshList" style
="display:none;">
629 <label
for="trafficChartRefresh"><?php
echo __('Refresh rate: '); ?
></label
>
630 <?php
refreshList('trafficChartRefresh'); ?
>
633 <a
class="tabChart livetrafficLink" href
="#">
634 <?php
echo __('Live traffic chart'); ?
>
636 <a
class="tabChart liveconnectionsLink" href
="#">
637 <?php
echo __('Live conn./process chart'); ?
>
640 <div
class="tabInnerContent">
641 <?php
printServerTraffic(); ?
>
644 <div id
="statustabs_queries">
645 <div
class="buttonlinks">
646 <a
class="tabRefresh" href
="<?php echo $PMA_PHP_SELF . '?show=query_statistics&' . PMA_generate_common_url(); ?>" >
647 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt
="ajax clock" style
="display: none;" />
648 <?php
echo __('Refresh'); ?
>
650 <span
class="refreshList" style
="display:none;">
651 <label
for="queryChartRefresh"><?php
echo __('Refresh rate: '); ?
></label
>
652 <?php
refreshList('queryChartRefresh'); ?
>
654 <a
class="tabChart livequeriesLink" href
="#">
655 <?php
echo __('Live query chart'); ?
>
658 <div
class="tabInnerContent">
659 <?php
printQueryStatistics(); ?
>
662 <div id
="statustabs_allvars">
663 <fieldset id
="tableFilter">
664 <div
class="buttonlinks">
665 <a
class="tabRefresh" href
="<?php echo $PMA_PHP_SELF . '?show=variables_table&' . PMA_generate_common_url(); ?>" >
666 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt
="ajax clock" style
="display: none;" />
667 <?php
echo __('Refresh'); ?
>
670 <legend
>Filters
</legend
>
671 <div
class="formelement">
672 <label
for="filterText"><?php
echo __('Containing the word:'); ?
></label
>
673 <input name
="filterText" type
="text" id
="filterText" style
="vertical-align: baseline;" />
675 <div
class="formelement">
676 <input type
="checkbox" name
="filterAlert" id
="filterAlert">
677 <label
for="filterAlert"><?php
echo __('Show only alert values'); ?
></label
>
679 <div
class="formelement">
680 <select id
="filterCategory" name
="filterCategory">
681 <option value
=''><?php
echo __('Filter by category...'); ?
></option
>
683 foreach ($sections as $section_id => $section_name) {
685 <option value
='<?php echo $section_id; ?>'><?php
echo $section_name; ?
></option
>
693 <div id
="linkSuggestions" class="defaultLinks" style
="display:none">
694 <p
class="notice"><?php
echo __('Related links:'); ?
>
696 foreach ($links as $section_name => $section_links) {
697 echo '<span class="status_'.$section_name.'"> ';
699 foreach ($section_links as $link_name => $link_url) {
700 if ($i > 0) echo ', ';
701 if ('doc' == $link_name) {
702 echo PMA_showMySQLDocu($link_url, $link_url);
704 echo '<a href="' . $link_url . '">' . $link_name . '</a>';
710 unset($link_url, $link_name, $i);
714 <div
class="tabInnerContent">
715 <?php
printVariablesTable(); ?
>
719 <div id
="statustabs_charting">
720 <?php
printMonitor(); ?
>
727 function printQueryStatistics() {
728 global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
730 $hour_factor = 3600 / $server_status['Uptime'];
732 $total_queries = array_sum($used_queries);
735 <h3 id
="serverstatusqueries">
737 /* l10n: Questions is the name of a MySQL Status variable */
738 echo sprintf(__('Questions since startup: %s'),PMA_formatNumber($total_queries, 0)) . ' ';
739 echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
744 echo 'ø '.__('per hour').': ';
745 echo PMA_formatNumber($total_queries * $hour_factor, 0);
748 echo 'ø '.__('per minute').': ';
749 echo PMA_formatNumber( $total_queries * 60 / $server_status['Uptime'], 0);
752 if ($total_queries / $server_status['Uptime'] >= 1) {
753 echo 'ø '.__('per second').': ';
754 echo PMA_formatNumber( $total_queries / $server_status['Uptime'], 0);
761 // reverse sort by value to show most used statements first
762 arsort($used_queries);
765 $count_displayed_rows = 0;
766 $perc_factor = 100 / $total_queries; //(- $server_status['Connections']);
770 <table id
="serverstatusqueriesdetails" class="data sortable">
771 <col
class="namecol" />
772 <col
class="valuecol" span
="3" />
774 <tr
><th
><?php
echo __('Statements'); ?
></th
>
776 /* l10n: # = Amount of queries */
779 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
786 $chart_json = array();
787 $query_sum = array_sum($used_queries);
789 foreach ($used_queries as $name => $value) {
790 $odd_row = !$odd_row;
792 // For the percentage column, use Questions - Connections, because
793 // the number of connections is not an item of the Query types
794 // but is included in Questions. Then the total of the percentages is 100.
795 $name = str_replace(array('Com_', '_'), array('', ' '), $name);
797 // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
798 if ($value < $query_sum * 0.02 && count($chart_json)>6)
799 $other_sum +
= $value;
800 else $chart_json[$name] = $value;
802 <tr
class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
803 <th
class="name"><?php
echo htmlspecialchars($name); ?
></th
>
804 <td
class="value"><?php
echo PMA_formatNumber($value, 5, 0, true); ?
></td
>
805 <td
class="value"><?php
echo
806 PMA_formatNumber($value * $hour_factor, 4, 1, true); ?
></td
>
807 <td
class="value"><?php
echo
808 PMA_formatNumber($value * $perc_factor, 0, 2); ?
>%
</td
>
816 <div id
="serverstatusquerieschart">
817 <span style
="display:none;">
820 $chart_json[__('Other')] = $other_sum;
822 echo json_encode($chart_json);
829 function printServerTraffic() {
830 global $server_status,$PMA_PHP_SELF;
831 global $server_master_status, $server_slave_status, $replication_types;
833 $hour_factor = 3600 / $server_status['Uptime'];
836 * starttime calculation
838 $start_time = PMA_DBI_fetch_value(
839 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']);
844 __('Network traffic since startup: %s'),
845 implode(' ', PMA_formatByteDown( $server_status['Bytes_received'] +
$server_status['Bytes_sent'], 3, 1))
852 echo sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'),
853 PMA_timespanFormat($server_status['Uptime']),
854 PMA_localisedDate($start_time)) . "\n";
859 if ($server_master_status ||
$server_slave_status) {
860 echo '<p class="notice">';
861 if ($server_master_status && $server_slave_status) {
862 echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
863 } elseif ($server_master_status) {
864 echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
865 } elseif ($server_slave_status) {
866 echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
868 echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
872 /* if the server works as master or slave in replication process, display useful information */
873 if ($server_master_status ||
$server_slave_status)
876 <hr
class="clearfloat" />
878 <h3
><a name
="replication"></a
><?php
echo __('Replication status'); ?
></h3
>
881 foreach ($replication_types as $type)
883 if ($
{"server_{$type}_status"}) {
884 PMA_replication_print_status_table($type);
891 <table id
="serverstatustraffic" class="data">
894 <th colspan
="2"><?php
echo __('Traffic') . ' ' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?
></th
>
895 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
899 <tr
class="noclick odd">
900 <th
class="name"><?php
echo __('Received'); ?
></th
>
901 <td
class="value"><?php
echo
903 PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?
></td
>
904 <td
class="value"><?php
echo
907 $server_status['Bytes_received'] * $hour_factor, 3, 1)); ?
></td
>
909 <tr
class="noclick even">
910 <th
class="name"><?php
echo __('Sent'); ?
></th
>
911 <td
class="value"><?php
echo
913 PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?
></td
>
914 <td
class="value"><?php
echo
917 $server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?
></td
>
919 <tr
class="noclick odd">
920 <th
class="name"><?php
echo __('Total'); ?
></th
>
921 <td
class="value"><?php
echo
924 $server_status['Bytes_received'] +
$server_status['Bytes_sent'], 3, 1)
926 <td
class="value"><?php
echo
929 ($server_status['Bytes_received'] +
$server_status['Bytes_sent'])
930 * $hour_factor, 3, 1)
936 <table id
="serverstatusconnections" class="data">
939 <th colspan
="2"><?php
echo __('Connections'); ?
></th
>
940 <th
>ø
; <?php
echo __('per hour'); ?
></th
>
945 <tr
class="noclick odd">
946 <th
class="name"><?php
echo __('max. concurrent connections'); ?
></th
>
947 <td
class="value"><?php
echo
948 PMA_formatNumber($server_status['Max_used_connections'], 0); ?
> </td
>
949 <td
class="value">--- </td
>
950 <td
class="value">--- </td
>
952 <tr
class="noclick even">
953 <th
class="name"><?php
echo __('Failed attempts'); ?
></th
>
954 <td
class="value"><?php
echo
955 PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?
></td
>
956 <td
class="value"><?php
echo
957 PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
959 <td
class="value"><?php
echo
960 $server_status['Connections'] > 0
962 $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
966 <tr
class="noclick odd">
967 <th
class="name"><?php
echo __('Aborted'); ?
></th
>
968 <td
class="value"><?php
echo
969 PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?
></td
>
970 <td
class="value"><?php
echo
971 PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
973 <td
class="value"><?php
echo
974 $server_status['Connections'] > 0
976 $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
980 <tr
class="noclick even">
981 <th
class="name"><?php
echo __('Total'); ?
></th
>
982 <td
class="value"><?php
echo
983 PMA_formatNumber($server_status['Connections'], 4, 0); ?
></td
>
984 <td
class="value"><?php
echo
985 PMA_formatNumber($server_status['Connections'] * $hour_factor,
987 <td
class="value"><?php
echo
988 PMA_formatNumber(100, 0, 2); ?
>%
</td
>
994 $url_params = array();
996 if (! empty($_REQUEST['full'])) {
997 $sql_query = 'SHOW FULL PROCESSLIST';
998 $url_params['full'] = 1;
999 $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
1001 $sql_query = 'SHOW PROCESSLIST';
1002 $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
1004 $result = PMA_DBI_query($sql_query);
1010 <table id
="tableprocesslist" class="data clearfloat">
1013 <th
><?php
echo __('Processes'); ?
></th
>
1014 <th
><?php
echo __('ID'); ?
></th
>
1015 <th
><?php
echo __('User'); ?
></th
>
1016 <th
><?php
echo __('Host'); ?
></th
>
1017 <th
><?php
echo __('Database'); ?
></th
>
1018 <th
><?php
echo __('Command'); ?
></th
>
1019 <th
><?php
echo __('Time'); ?
></th
>
1020 <th
><?php
echo __('Status'); ?
></th
>
1022 echo __('SQL query');
1023 if (! PMA_DRIZZLE
) { ?
>
1024 <a href
="<?php echo $full_text_link; ?>"
1025 title
="<?php echo empty($full) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>">
1026 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . (empty($_REQUEST['full']) ? 'full' : 'partial'); ?>text.png"
1027 alt
="<?php echo empty($_REQUEST['full']) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>" />
1036 while ($process = PMA_DBI_fetch_assoc($result)) {
1038 // Drizzle uses uppercase keys
1039 foreach ($process as $k => $v) {
1041 ?
ucfirst(strtolower($k))
1046 $url_params['kill'] = $process['Id'];
1047 $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
1049 <tr
class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
1050 <td
><a href
="<?php echo $kill_process ; ?>"><?php
echo __('Kill'); ?
></a
></td
>
1051 <td
class="value"><?php
echo $process['Id']; ?
></td
>
1052 <td
><?php
echo $process['User']; ?
></td
>
1053 <td
><?php
echo $process['Host']; ?
></td
>
1054 <td
><?php
echo ((! isset($process['db']) ||
! strlen($process['db'])) ?
'<i>' . __('None') . '</i>' : $process['db']); ?
></td
>
1055 <td
><?php
echo $process['Command']; ?
></td
>
1056 <td
class="value"><?php
echo $process['Time']; ?
></td
>
1057 <td
><?php
echo (empty($process['State']) ?
'---' : $process['State']); ?
></td
>
1058 <td
><?php
echo (empty($process['Info']) ?
'---' : PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']))); ?
></td
>
1061 $odd_row = ! $odd_row;
1069 function printVariablesTable() {
1070 global $server_status, $server_variables, $allocationMap, $links;
1072 * Messages are built using the message name
1074 $strShowStatus = array(
1075 'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
1076 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
1077 '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.'),
1078 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
1079 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
1080 '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.'),
1081 'Created_tmp_files' => __('How many temporary files mysqld has created.'),
1082 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
1083 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
1084 '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.'),
1085 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
1086 'Flush_commands' => __('The number of executed FLUSH statements.'),
1087 'Handler_commit' => __('The number of internal COMMIT statements.'),
1088 'Handler_delete' => __('The number of times a row was deleted from a table.'),
1089 '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.'),
1090 '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.'),
1091 '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.'),
1092 '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.'),
1093 '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.'),
1094 '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.'),
1095 '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.'),
1096 'Handler_rollback' => __('The number of internal ROLLBACK statements.'),
1097 'Handler_update' => __('The number of requests to update a row in a table.'),
1098 'Handler_write' => __('The number of requests to insert a row in a table.'),
1099 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'),
1100 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'),
1101 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'),
1102 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'),
1103 '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.'),
1104 '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.'),
1105 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'),
1106 '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.'),
1107 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'),
1108 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'),
1109 '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.'),
1110 '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.'),
1111 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'),
1112 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'),
1113 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'),
1114 'Innodb_data_pending_reads' => __('The current number of pending reads.'),
1115 'Innodb_data_pending_writes' => __('The current number of pending writes.'),
1116 'Innodb_data_read' => __('The amount of data read so far, in bytes.'),
1117 'Innodb_data_reads' => __('The total number of data reads.'),
1118 'Innodb_data_writes' => __('The total number of data writes.'),
1119 'Innodb_data_written' => __('The amount of data written so far, in bytes.'),
1120 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'),
1121 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'),
1122 '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.'),
1123 'Innodb_log_write_requests' => __('The number of log write requests.'),
1124 'Innodb_log_writes' => __('The number of physical writes to the log file.'),
1125 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'),
1126 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'),
1127 'Innodb_os_log_pending_writes' => __('Pending log file writes.'),
1128 'Innodb_os_log_written' => __('The number of bytes written to the log file.'),
1129 'Innodb_pages_created' => __('The number of pages created.'),
1130 '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.'),
1131 'Innodb_pages_read' => __('The number of pages read.'),
1132 'Innodb_pages_written' => __('The number of pages written.'),
1133 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'),
1134 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'),
1135 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'),
1136 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'),
1137 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'),
1138 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'),
1139 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'),
1140 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'),
1141 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'),
1142 '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.'),
1143 '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.'),
1144 '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.'),
1145 'Key_read_requests' => __('The number of requests to read a key block from the cache.'),
1146 '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.'),
1147 'Key_write_requests' => __('The number of requests to write a key block to the cache.'),
1148 'Key_writes' => __('The number of physical writes of a key block to disk.'),
1149 '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.'),
1150 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'),
1151 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'),
1152 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'),
1153 'Open_files' => __('The number of files that are open.'),
1154 'Open_streams' => __('The number of streams that are open (used mainly for logging).'),
1155 'Open_tables' => __('The number of tables that are open.'),
1156 '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.'),
1157 'Qcache_free_memory' => __('The amount of free memory for query cache.'),
1158 'Qcache_hits' => __('The number of cache hits.'),
1159 'Qcache_inserts' => __('The number of queries added to the cache.'),
1160 '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.'),
1161 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'),
1162 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'),
1163 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'),
1164 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'),
1165 '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.'),
1166 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'),
1167 '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.)'),
1168 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'),
1169 'Select_scan' => __('The number of joins that did a full scan of the first table.'),
1170 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'),
1171 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'),
1172 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'),
1173 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'),
1174 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'),
1175 '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.'),
1176 'Sort_range' => __('The number of sorts that were done with ranges.'),
1177 'Sort_rows' => __('The number of sorted rows.'),
1178 'Sort_scan' => __('The number of sorts that were done by scanning the table.'),
1179 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'),
1180 '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.'),
1181 '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.'),
1182 'Threads_connected' => __('The number of currently open connections.'),
1183 '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.)'),
1184 'Threads_running' => __('The number of threads that are not sleeping.')
1188 * define some alerts
1190 // name => max value before alert
1193 // variable => max value
1194 'Aborted_clients' => 0,
1195 'Aborted_connects' => 0,
1197 'Binlog_cache_disk_use' => 0,
1199 'Created_tmp_disk_tables' => 0,
1201 'Handler_read_rnd' => 0,
1202 'Handler_read_rnd_next' => 0,
1204 'Innodb_buffer_pool_pages_dirty' => 0,
1205 'Innodb_buffer_pool_reads' => 0,
1206 'Innodb_buffer_pool_wait_free' => 0,
1207 'Innodb_log_waits' => 0,
1208 'Innodb_row_lock_time_avg' => 10, // ms
1209 'Innodb_row_lock_time_max' => 50, // ms
1210 'Innodb_row_lock_waits' => 0,
1212 'Slow_queries' => 0,
1213 'Delayed_errors' => 0,
1214 'Select_full_join' => 0,
1215 'Select_range_check' => 0,
1216 'Sort_merge_passes' => 0,
1217 'Opened_tables' => 0,
1218 'Table_locks_waited' => 0,
1219 'Qcache_lowmem_prunes' => 0,
1221 'Qcache_free_blocks' => $server_status['Qcache_total_blocks'] / 5,
1222 'Slow_launch_threads' => 0,
1224 // depends on Key_read_requests
1225 // normaly lower then 1:0.01
1226 'Key_reads' => (0.01 * $server_status['Key_read_requests']),
1227 // depends on Key_write_requests
1228 // normaly nearly 1:1
1229 'Key_writes' => (0.9 * $server_status['Key_write_requests']),
1231 'Key_buffer_fraction' => 0.5,
1233 // alert if more than 95% of thread cache is in use
1234 'Threads_cached' => 0.95 * $server_variables['thread_cache_size']
1237 // variable => min value
1238 //'Handler read key' => '> ',
1242 <table
class="data sortable" id
="serverstatusvariables">
1243 <col
class="namecol" />
1244 <col
class="valuecol" />
1245 <col
class="descrcol" />
1248 <th
><?php
echo __('Variable'); ?
></th
>
1249 <th
><?php
echo __('Value'); ?
></th
>
1250 <th
><?php
echo __('Description'); ?
></th
>
1257 foreach ($server_status as $name => $value) {
1258 $odd_row = !$odd_row;
1260 <tr
class="noclick <?php echo $odd_row ? 'odd' : 'even'; echo isset($allocationMap[$name])?' s_'.$allocationMap[$name]:''; ?>">
1261 <th
class="name"><?php
echo htmlspecialchars(str_replace('_',' ',$name)) . PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); ?
>
1263 <td
class="value"><?php
1264 if (isset($alerts[$name])) {
1265 if ($value > $alerts[$name]) {
1266 echo '<span class="attention">';
1268 echo '<span class="allfine">';
1271 if ('%' === substr($name, -1, 1)) {
1272 echo PMA_formatNumber($value, 0, 2) . ' %';
1273 } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
1274 echo PMA_formatNumber($value, 3, 1);
1275 } elseif (is_numeric($value) && $value == (int) $value) {
1276 echo PMA_formatNumber($value, 3, 0);
1277 } elseif (is_numeric($value)) {
1278 echo PMA_formatNumber($value, 3, 1);
1280 echo htmlspecialchars($value);
1282 if (isset($alerts[$name])) {
1288 if (isset($strShowStatus[$name ])) {
1289 echo $strShowStatus[$name];
1292 if (isset($links[$name])) {
1293 foreach ($links[$name] as $link_name => $link_url) {
1294 if ('doc' == $link_name) {
1295 echo PMA_showMySQLDocu($link_url, $link_url);
1297 echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
1301 unset($link_url, $link_name);
1314 function printMonitor() {
1315 global $server_status, $server_db_isLocal;
1317 <div
class="monitorLinks">
1318 <a href
="#pauseCharts">
1319 <img src
="themes/dot.gif" class="icon ic_play" alt
="" />
1320 <?php
echo __('Start Monitor'); ?
>
1322 <a href
="#settingsPopup" rel
="popupLink" style
="display:none;">
1323 <img src
="themes/dot.gif" class="icon ic_s_cog" alt
="" />
1324 <?php
echo __('Settings'); ?
>
1326 <a href
="#monitorInstructionsDialog">
1327 <img src
="themes/dot.gif" class="icon ic_b_help" alt
="" />
1328 <?php
echo __('Instructions/Setup'); ?
>
1330 <a href
="#endChartEditMode" style
="display:none;">
1331 <img src
="themes/dot.gif" class="icon ic_s_okay" alt
="" />
1332 <?php
echo __('Done rearranging/editing charts'); ?
>
1336 <div
class="popupContent settingsPopup">
1337 <a href
="#addNewChart">
1338 <img src
="themes/dot.gif" class="icon ic_b_chart" alt
="" />
1339 <?php
echo __('Add chart'); ?
>
1341 <a href
="#rearrangeCharts"> <?php
echo __('Rearrange/edit charts'); ?
></a
><br
>
1343 <?php
echo __('Refresh rate:'); refreshList('gridChartRefresh'); ?
><br
>
1346 <?php
echo __('Chart columns:'); ?
>
1347 <select name
="chartColumns">
1360 <a href
="#clearMonitorConfig"><?php
echo __('Clear monitor config'); ?
></a
>
1363 <div id
="monitorInstructionsDialog" title
="<?php echo __('Monitor Instructions'); ?>" style
="display:none;">
1364 <?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%'); ?
>
1366 <img
class="ajaxIcon" src
="<?php echo $GLOBALS['pmaThemeImage']; ?>ajax_clock_small.gif" alt
="Loading">
1367 <div
class="ajaxContent">
1369 <div
class="monitorUse" style
="display:none;">
1371 <?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>');
1374 <img
class="icon ic_s_attention" src
="themes/dot.gif" alt
="">
1375 <?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.'); ?
>
1380 <div id
="addChartDialog" title
="Add chart" style
="display:none;">
1381 <div id
="tabGridVariables">
1382 <p
><input type
="text" name
="chartTitle" value
="<?php echo __('Chart Title'); ?>" /></p
>
1383 <?php
if ($server_db_isLocal) { ?
>
1384 <input type
="radio" name
="chartType" value
="cpu" id
="chartCPU">
1385 <label
for="chartCPU"><?php
echo __('CPU Usage'); ?
></label
><br
/>
1387 <input type
="radio" name
="chartType" value
="memory" id
="chartMemory">
1388 <label
for="chartMemory"><?php
echo __('Memory Usage'); ?
></label
><br
/>
1390 <input type
="radio" name
="chartType" value
="swap" id
="chartSwap">
1391 <label
for="chartSwap"><?php
echo __('Swap Usage'); ?
></label
><br
/>
1393 <input type
="radio" name
="chartType" value
="variable" id
="chartStatusVar" checked
="checked">
1394 <label
for="chartStatusVar"><?php
echo __('Status variable(s)'); ?
></label
><br
/>
1395 <div id
="chartVariableSettings">
1396 <label
for="chartSeries"><?php
echo __('Select series:'); ?
></label
><br
>
1397 <select id
="chartSeries" name
="varChartList" size
="1">
1398 <option
><?php
echo __('Commonly monitored'); ?
></option
>
1399 <option
>Processes
</option
>
1400 <option
>Questions
</option
>
1401 <option
>Connections
</option
>
1402 <option
>Bytes_sent
</option
>
1403 <option
>Bytes_received
</option
>
1404 <option
>Threads_connected
</option
>
1405 <option
>Created_tmp_disk_tables
</option
>
1406 <option
>Handler_read_first
</option
>
1407 <option
>Innodb_buffer_pool_wait_free
</option
>
1408 <option
>Key_reads
</option
>
1409 <option
>Open_tables
</option
>
1410 <option
>Select_full_join
</option
>
1411 <option
>Slow_queries
</option
>
1413 <label
for="variableInput"><?php
echo __('or type variable name:'); ?
> </label
>
1414 <input type
="text" name
="variableInput" id
="variableInput" />
1416 <input type
="checkbox" name
="differentialValue" id
="differentialValue" value
="differential" checked
="checked" />
1417 <label
for="differentialValue"><?php
echo __('Display as differential value'); ?
></label
><br
>
1418 <input type
="checkbox" id
="useDivisor" name
="useDivisor" value
="1" />
1419 <label
for="useDivisor"><?php
echo __('Apply a divisor'); ?
></label
>
1420 <span
class="divisorInput" style
="display:none;">
1421 <input type
="text" name
="valueDivisor" size
="4" value
="1">
1422 (<a href
="#kibDivisor"><?php
echo __('KiB'); ?
></a
>, <a href
="#mibDivisor"><?php
echo __('MiB'); ?
></a
>)
1425 <input type
="checkbox" id
="useUnit" name
="useUnit" value
="1" />
1426 <label
for="useUnit"><?php
echo __('Append unit to data values'); ?
></label
>
1428 <span
class="unitInput" style
="display:none;">
1429 <input type
="text" name
="valueUnit" size
="4" value
="">
1432 <a href
="#submitAddSeries"><b
><?php
echo __('Add this series'); ?
></b
></a
>
1433 <span id
="clearSeriesLink" style
="display:none;">
1434 |
<a href
="#submitClearSeries"><?php
echo __('Clear series'); ?
></a
>
1437 <?php
echo __('Series in Chart:'); ?
><br
/>
1438 <span id
="seriesPreview">
1439 <i
><?php
echo __('None'); ?
></i
>
1445 <div id
="loadingLogsDialog" title
="<?php echo __('Loading logs'); ?>" style
="display:none;">
1448 <div id
="logAnalyseDialog" title
="<?php echo __('Log statistics'); ?>" style
="display:none;">
1449 <p
> <?php
echo __('Selected time range:'); ?
>
1450 <input type
="text" name
="dateStart" class="datetimefield" value
="" /> -
1451 <input type
="text" name
="dateEnd" class="datetimefield" value
="" /></p
>
1452 <input type
="checkbox" id
="limitTypes" value
="1" checked
="checked" />
1453 <label
for="limitTypes">
1454 <?php
echo __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements'); ?
>
1457 <input type
="checkbox" id
="removeVariables" value
="1" checked
="checked" />
1458 <label
for="removeVariables">
1459 <?php
echo __('Remove variable data in INSERT statements for better grouping'); ?
>
1462 <?php
echo __('<p>Choose from which log you want the statistics to be generated from.</p> Results are grouped by query text.'); ?
>
1465 <div id
="queryAnalyzerDialog" title
="<?php echo __('Query analyzer'); ?>" style
="display:none;">
1466 <textarea id
="sqlquery"> </textarea
>
1468 <div
class="placeHolder"></div
>
1471 <table border
="0" class="clearfloat" id
="chartGrid">
1478 <script type
="text/javascript">
1479 variableNames
= [ <?php
1481 foreach ($server_status as $name=>$value) {
1482 if (is_numeric($value)) {
1483 if ($i++
> 0) echo ", ";
1492 /* Builds a <select> list for refresh rates */
1493 function refreshList($name,$defaultRate=5, $refreshRates=Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600)) {
1495 <select name
="<?php echo $name; ?>">
1497 foreach ($refreshRates as $rate) {
1498 $selected = ($rate == $defaultRate)?
' selected="selected"':'';
1501 echo '<option value="'.$rate.'"'.$selected.'>'.sprintf(_ngettext('%d second', '%d seconds', $rate), $rate).'</option>';
1503 echo '<option value="'.$rate.'"'.$selected.'>'.sprintf(_ngettext('%d minute', '%d minutes', $rate/60), $rate/60).'</option>';
1511 * cleanup of some deprecated values
1513 * @param array &$server_status
1515 function cleanDeprecated(&$server_status) {
1516 $deprecated = array(
1517 'Com_prepare_sql' => 'Com_stmt_prepare',
1518 'Com_execute_sql' => 'Com_stmt_execute',
1519 'Com_dealloc_sql' => 'Com_stmt_close',
1522 foreach ($deprecated as $old => $new) {
1523 if (isset($server_status[$old]) && isset($server_status[$new])) {
1524 unset($server_status[$old]);
1532 require './libraries/footer.inc.php';