PageRenderTime 70ms CodeModel.GetById 20ms app.highlight 38ms RepoModel.GetById 1ms app.codeStats 1ms

/phpmyadmin/server_status.php

https://bitbucket.org/adarshj/convenient_website
PHP | 1814 lines | 1468 code | 197 blank | 149 comment | 153 complexity | 17fa8f1ea8e4afb659192941d7da6208 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   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
   6 *
   7 * @package PhpMyAdmin
   8 */
   9
  10/**
  11 * no need for variables importing
  12 * @ignore
  13 */
  14if (! defined('PMA_NO_VARIABLES_IMPORT')) {
  15    define('PMA_NO_VARIABLES_IMPORT', true);
  16}
  17
  18if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
  19    $GLOBALS['is_header_sent'] = true;
  20}
  21
  22require_once './libraries/common.inc.php';
  23
  24/**
  25 * Ajax request
  26 */
  27
  28if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
  29    // Send with correct charset
  30    header('Content-Type: text/html; charset=UTF-8');
  31
  32    // real-time charting data
  33    if (isset($_REQUEST['chart_data'])) {
  34        switch($_REQUEST['type']) {
  35        // Process and Connections realtime chart
  36        case 'proc':
  37            $c = PMA_DBI_fetch_result("SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1);
  38            $result = PMA_DBI_query('SHOW PROCESSLIST');
  39            $num_procs = PMA_DBI_num_rows($result);
  40
  41            $ret = array(
  42                'x'      => microtime(true) * 1000,
  43                'y_proc' => $num_procs,
  44                'y_conn' => $c['Connections']
  45            );
  46
  47            exit(json_encode($ret));
  48
  49        // Query realtime chart
  50        case 'queries':
  51            if (PMA_DRIZZLE) {
  52                $sql = "SELECT concat('Com_', variable_name), variable_value
  53                    FROM data_dictionary.GLOBAL_STATEMENTS
  54                    WHERE variable_value > 0
  55                      UNION
  56                    SELECT variable_name, variable_value
  57                    FROM data_dictionary.GLOBAL_STATUS
  58                    WHERE variable_name = 'Questions'";
  59                $queries = PMA_DBI_fetch_result($sql, 0, 1);
  60            } else {
  61                $queries = PMA_DBI_fetch_result(
  62                    "SHOW GLOBAL STATUS
  63                    WHERE (Variable_name LIKE 'Com_%' OR Variable_name = 'Questions')
  64                        AND Value > 0", 0, 1
  65                );
  66            }
  67            cleanDeprecated($queries);
  68            // admin commands are not queries
  69            unset($queries['Com_admin_commands']);
  70            $questions = $queries['Questions'];
  71            unset($queries['Questions']);
  72
  73            //$sum=array_sum($queries);
  74            $ret = array(
  75                'x'         => microtime(true) * 1000,
  76                'y'         => $questions,
  77                'pointInfo' => $queries
  78            );
  79
  80            exit(json_encode($ret));
  81
  82        // Traffic realtime chart
  83        case 'traffic':
  84            $traffic = PMA_DBI_fetch_result(
  85                "SHOW GLOBAL STATUS
  86                WHERE Variable_name = 'Bytes_received'
  87                    OR Variable_name = 'Bytes_sent'", 0, 1
  88            );
  89
  90            $ret = array(
  91                'x'          => microtime(true) * 1000,
  92                'y_sent'     => $traffic['Bytes_sent'],
  93                'y_received' => $traffic['Bytes_received']
  94            );
  95
  96            exit(json_encode($ret));
  97
  98        // Data for the monitor
  99        case 'chartgrid':
 100            $ret = json_decode($_REQUEST['requiredData'], true);
 101            $statusVars = array();
 102            $serverVars = array();
 103            $sysinfo = $cpuload = $memory = 0;
 104            $pName = '';
 105
 106            /* Accumulate all required variables and data */
 107            // For each chart
 108            foreach ($ret as $chart_id => $chartNodes) {
 109                // For each data series
 110                foreach ($chartNodes as $node_id => $nodeDataPoints) {
 111                    // For each data point in the series (usually just 1)
 112                    foreach ($nodeDataPoints as $point_id => $dataPoint) {
 113                        $pName = $dataPoint['name'];
 114
 115                        switch ($dataPoint['type']) {
 116                        /* We only collect the status and server variables here to
 117                         * read them all in one query, and only afterwards assign them.
 118                         * Also do some white list filtering on the names
 119                        */
 120                        case 'servervar':
 121                            if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
 122                                $serverVars[] = $pName;
 123                            }
 124                            break;
 125
 126                        case 'statusvar':
 127                            if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
 128                                $statusVars[] = $pName;
 129                            }
 130                            break;
 131
 132                        case 'proc':
 133                            $result = PMA_DBI_query('SHOW PROCESSLIST');
 134                            $ret[$chart_id][$node_id][$point_id]['value'] = PMA_DBI_num_rows($result);
 135                            break;
 136
 137                        case 'cpu':
 138                            if (!$sysinfo) {
 139                                include_once 'libraries/sysinfo.lib.php';
 140                                $sysinfo = getSysInfo();
 141                            }
 142                            if (!$cpuload) {
 143                                $cpuload = $sysinfo->loadavg();
 144                            }
 145
 146                            if (PHP_OS == 'Linux') {
 147                                $ret[$chart_id][$node_id][$point_id]['idle'] = $cpuload['idle'];
 148                                $ret[$chart_id][$node_id][$point_id]['busy'] = $cpuload['busy'];
 149                            } else
 150                                $ret[$chart_id][$node_id][$point_id]['value'] = $cpuload['loadavg'];
 151
 152                            break;
 153
 154                        case 'memory':
 155                            if (!$sysinfo) {
 156                                include_once 'libraries/sysinfo.lib.php';
 157                                $sysinfo = getSysInfo();
 158                            }
 159                            if (!$memory) {
 160                                $memory  = $sysinfo->memory();
 161                            }
 162
 163                            $ret[$chart_id][$node_id][$point_id]['value'] = $memory[$pName];
 164                            break;
 165                        } /* switch */
 166                    } /* foreach */
 167                } /* foreach */
 168            } /* foreach */
 169
 170            // Retrieve all required status variables
 171            if (count($statusVars)) {
 172                $statusVarValues = PMA_DBI_fetch_result(
 173                    "SHOW GLOBAL STATUS
 174                    WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1
 175                );
 176            } else {
 177                $statusVarValues = array();
 178            }
 179
 180            // Retrieve all required server variables
 181            if (count($serverVars)) {
 182                $serverVarValues = PMA_DBI_fetch_result(
 183                    "SHOW GLOBAL VARIABLES
 184                    WHERE Variable_name='" . implode("' OR Variable_name='", $serverVars) . "'", 0, 1
 185                );
 186            } else {
 187                $serverVarValues = array();
 188            }
 189
 190            // ...and now assign them
 191            foreach ($ret as $chart_id => $chartNodes) {
 192                foreach ($chartNodes as $node_id => $nodeDataPoints) {
 193                    foreach ($nodeDataPoints as $point_id => $dataPoint) {
 194                        switch($dataPoint['type']) {
 195                        case 'statusvar':
 196                            $ret[$chart_id][$node_id][$point_id]['value'] = $statusVarValues[$dataPoint['name']];
 197                            break;
 198                        case 'servervar':
 199                            $ret[$chart_id][$node_id][$point_id]['value'] = $serverVarValues[$dataPoint['name']];
 200                            break;
 201                        }
 202                    }
 203                }
 204            }
 205
 206            $ret['x'] = microtime(true) * 1000;
 207
 208            exit(json_encode($ret));
 209        }
 210    }
 211
 212    if (isset($_REQUEST['log_data'])) {
 213        if (PMA_MYSQL_INT_VERSION < 50106) {
 214            /* FIXME: why this? */
 215            exit('""');
 216        }
 217
 218        $start = intval($_REQUEST['time_start']);
 219        $end = intval($_REQUEST['time_end']);
 220
 221        if ($_REQUEST['type'] == 'slow') {
 222            $q = 'SELECT start_time, user_host, Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, '.
 223                 'SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined, db, sql_text, COUNT(sql_text) AS \'#\' '.
 224                 'FROM `mysql`.`slow_log` WHERE start_time > FROM_UNIXTIME(' . $start . ') '.
 225                 'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
 226
 227            $result = PMA_DBI_try_query($q);
 228
 229            $return = array('rows' => array(), 'sum' => array());
 230            $type = '';
 231
 232            while ($row = PMA_DBI_fetch_assoc($result)) {
 233                $type = strtolower(substr($row['sql_text'], 0, strpos($row['sql_text'], ' ')));
 234
 235                switch($type) {
 236                case 'insert':
 237                case 'update':
 238                    // Cut off big inserts and updates, but append byte count therefor
 239                    if (strlen($row['sql_text']) > 220) {
 240                        $row['sql_text'] = substr($row['sql_text'], 0, 200)
 241                            . '... ['
 242                            .  implode(' ', PMA_formatByteDown(strlen($row['sql_text']), 2, 2))
 243                            . ']';
 244                    }
 245                    break;
 246                default:
 247                    break;
 248                }
 249
 250                if (!isset($return['sum'][$type])) {
 251                    $return['sum'][$type] = 0;
 252                }
 253                $return['sum'][$type] += $row['#'];
 254                $return['rows'][] = $row;
 255            }
 256
 257            $return['sum']['TOTAL'] = array_sum($return['sum']);
 258            $return['numRows'] = count($return['rows']);
 259
 260            PMA_DBI_free_result($result);
 261
 262            exit(json_encode($return));
 263        }
 264
 265        if ($_REQUEST['type'] == 'general') {
 266            $limitTypes = (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes'])
 267                            ? 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
 268
 269            $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, server_id, argument, count(argument) as \'#\' '.
 270                 'FROM `mysql`.`general_log` WHERE command_type=\'Query\' '.
 271                 'AND event_time > FROM_UNIXTIME(' . $start . ') AND event_time < FROM_UNIXTIME(' . $end . ') '.
 272                 $limitTypes . 'GROUP by argument'; // HAVING count > 1';
 273
 274            $result = PMA_DBI_try_query($q);
 275
 276            $return = array('rows' => array(), 'sum' => array());
 277            $type = '';
 278            $insertTables = array();
 279            $insertTablesFirst = -1;
 280            $i = 0;
 281            $removeVars = isset($_REQUEST['removeVariables']) && $_REQUEST['removeVariables'];
 282
 283            while ($row = PMA_DBI_fetch_assoc($result)) {
 284                preg_match('/^(\w+)\s/', $row['argument'], $match);
 285                $type = strtolower($match[1]);
 286
 287                if (!isset($return['sum'][$type])) {
 288                    $return['sum'][$type] = 0;
 289                }
 290                $return['sum'][$type] += $row['#'];
 291
 292                switch($type) {
 293                case 'insert':
 294                    // Group inserts if selected
 295                    if ($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i', $row['argument'], $matches)) {
 296                        $insertTables[$matches[2]]++;
 297                        if ($insertTables[$matches[2]] > 1) {
 298                            $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
 299
 300                            // Add a ... to the end of this query to indicate that there's been other queries
 301                            if ($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.') {
 302                                $return['rows'][$insertTablesFirst]['argument'] .= '<br/>...';
 303                            }
 304
 305                            // Group this value, thus do not add to the result list
 306                            continue 2;
 307                        } else {
 308                            $insertTablesFirst = $i;
 309                            $insertTables[$matches[2]] += $row['#'] - 1;
 310                        }
 311                    }
 312                    // No break here
 313
 314                case 'update':
 315                    // Cut off big inserts and updates, but append byte count therefor
 316                    if (strlen($row['argument']) > 220) {
 317                        $row['argument'] = substr($row['argument'], 0, 200)
 318                            . '... ['
 319                            .  implode(' ', PMA_formatByteDown(strlen($row['argument'])), 2, 2)
 320                            . ']';
 321                    }
 322                    break;
 323
 324                default:
 325                    break;
 326                }
 327
 328                $return['rows'][] = $row;
 329                $i++;
 330            }
 331
 332            $return['sum']['TOTAL'] = array_sum($return['sum']);
 333            $return['numRows'] = count($return['rows']);
 334
 335            PMA_DBI_free_result($result);
 336
 337            exit(json_encode($return));
 338        }
 339    }
 340
 341    if (isset($_REQUEST['logging_vars'])) {
 342        if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
 343            $value = PMA_sqlAddslashes($_REQUEST['varValue']);
 344            if (!is_numeric($value)) {
 345                $value="'" . $value . "'";
 346            }
 347
 348            if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])) {
 349                PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value);
 350            }
 351
 352        }
 353
 354        $loggingVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES WHERE Variable_name IN ("general_log","slow_query_log","long_query_time","log_output")', 0, 1);
 355        exit(json_encode($loggingVars));
 356    }
 357
 358    if (isset($_REQUEST['query_analyzer'])) {
 359        $return = array();
 360
 361        if (strlen($_REQUEST['database'])) {
 362            PMA_DBI_select_db($_REQUEST['database']);
 363        }
 364
 365        if ($profiling = PMA_profilingSupported()) {
 366            PMA_DBI_query('SET PROFILING=1;');
 367        }
 368
 369        // Do not cache query
 370        $query = preg_replace('/^(\s*SELECT)/i', '\\1 SQL_NO_CACHE', $_REQUEST['query']);
 371
 372        $result = PMA_DBI_try_query($query);
 373        $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
 374
 375        $result = PMA_DBI_try_query('EXPLAIN ' . $query);
 376        while ($row = PMA_DBI_fetch_assoc($result)) {
 377            $return['explain'][] = $row;
 378        }
 379
 380        // In case an error happened
 381        $return['error'] = PMA_DBI_getError();
 382
 383        PMA_DBI_free_result($result);
 384
 385        if ($profiling) {
 386            $return['profiling'] = array();
 387            $result = PMA_DBI_try_query('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=1 ORDER BY seq');
 388            while ($row = PMA_DBI_fetch_assoc($result)) {
 389                $return['profiling'][]= $row;
 390            }
 391            PMA_DBI_free_result($result);
 392        }
 393
 394        exit(json_encode($return));
 395    }
 396
 397    if (isset($_REQUEST['advisor'])) {
 398        include 'libraries/Advisor.class.php';
 399        $advisor = new Advisor();
 400        exit(json_encode($advisor->run()));
 401    }
 402}
 403
 404
 405/**
 406 * Replication library
 407 */
 408if (PMA_DRIZZLE) {
 409    $server_master_status = false;
 410    $server_slave_status = false;
 411} else {
 412    include_once './libraries/replication.inc.php';
 413    include_once './libraries/replication_gui.lib.php';
 414}
 415
 416/**
 417 * JS Includes
 418 */
 419
 420$GLOBALS['js_include'][] = 'server_status.js';
 421$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
 422$GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
 423$GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
 424// Charting
 425$GLOBALS['js_include'][] = 'highcharts/highcharts.js';
 426/* Files required for chart exporting */
 427$GLOBALS['js_include'][] = 'highcharts/exporting.js';
 428/* < IE 9 doesn't support canvas natively */
 429if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
 430    $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
 431}
 432$GLOBALS['js_include'][] = 'canvg/canvg.js';
 433// for profiling chart
 434$GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js';
 435$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.pieRenderer.js';
 436
 437/**
 438 * flush status variables if requested
 439 */
 440if (isset($_REQUEST['flush'])) {
 441    $_flush_commands = array(
 442        'STATUS',
 443        'TABLES',
 444        'QUERY CACHE',
 445    );
 446
 447    if (in_array($_REQUEST['flush'], $_flush_commands)) {
 448        PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
 449    }
 450    unset($_flush_commands);
 451}
 452
 453/**
 454 * Kills a selected process
 455 */
 456if (!empty($_REQUEST['kill'])) {
 457    if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
 458        $message = PMA_Message::success(__('Thread %s was successfully killed.'));
 459    } else {
 460        $message = PMA_Message::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
 461    }
 462    $message->addParam($_REQUEST['kill']);
 463    //$message->display();
 464}
 465
 466
 467
 468/**
 469 * get status from server
 470 */
 471$server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
 472if (PMA_DRIZZLE) {
 473    // Drizzle doesn't put query statistics into variables, add it
 474    $sql = "SELECT concat('Com_', variable_name), variable_value
 475        FROM data_dictionary.GLOBAL_STATEMENTS";
 476    $statements = PMA_DBI_fetch_result($sql, 0, 1);
 477    $server_status = array_merge($server_status, $statements);
 478}
 479
 480/**
 481 * for some calculations we require also some server settings
 482 */
 483$server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
 484
 485/**
 486 * cleanup of some deprecated values
 487 */
 488cleanDeprecated($server_status);
 489
 490/**
 491 * calculate some values
 492 */
 493// Key_buffer_fraction
 494if (isset($server_status['Key_blocks_unused'])
 495    && isset($server_variables['key_cache_block_size'])
 496    && isset($server_variables['key_buffer_size'])
 497) {
 498    $server_status['Key_buffer_fraction_%']
 499        = 100
 500        - $server_status['Key_blocks_unused']
 501        * $server_variables['key_cache_block_size']
 502        / $server_variables['key_buffer_size']
 503        * 100;
 504} elseif (isset($server_status['Key_blocks_used'])
 505        && isset($server_variables['key_buffer_size'])) {
 506    $server_status['Key_buffer_fraction_%']
 507        = $server_status['Key_blocks_used']
 508        * 1024
 509        / $server_variables['key_buffer_size'];
 510}
 511
 512// Ratio for key read/write
 513if (isset($server_status['Key_writes'])
 514    && isset($server_status['Key_write_requests'])
 515    && $server_status['Key_write_requests'] > 0
 516) {
 517    $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
 518}
 519
 520if (isset($server_status['Key_reads'])
 521    && isset($server_status['Key_read_requests'])
 522    && $server_status['Key_read_requests'] > 0
 523) {
 524    $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
 525}
 526
 527// Threads_cache_hitrate
 528if (isset($server_status['Threads_created'])
 529    && isset($server_status['Connections'])
 530    && $server_status['Connections'] > 0
 531) {
 532
 533    $server_status['Threads_cache_hitrate_%']
 534        = 100 - $server_status['Threads_created'] / $server_status['Connections'] * 100;
 535}
 536
 537/**
 538 * split variables in sections
 539 */
 540$allocations = array(
 541    // variable name => section
 542    // variable names match when they begin with the given string
 543
 544    'Com_'              => 'com',
 545    'Innodb_'           => 'innodb',
 546    'Ndb_'              => 'ndb',
 547    'Handler_'          => 'handler',
 548    'Qcache_'           => 'qcache',
 549    'Threads_'          => 'threads',
 550    'Slow_launch_threads' => 'threads',
 551
 552    'Binlog_cache_'     => 'binlog_cache',
 553    'Created_tmp_'      => 'created_tmp',
 554    'Key_'              => 'key',
 555
 556    'Delayed_'          => 'delayed',
 557    'Not_flushed_delayed_rows' => 'delayed',
 558
 559    'Flush_commands'    => 'query',
 560    'Last_query_cost'   => 'query',
 561    'Slow_queries'      => 'query',
 562    'Queries'           => 'query',
 563    'Prepared_stmt_count' => 'query',
 564
 565    'Select_'           => 'select',
 566    'Sort_'             => 'sort',
 567
 568    'Open_tables'       => 'table',
 569    'Opened_tables'     => 'table',
 570    'Open_table_definitions' => 'table',
 571    'Opened_table_definitions' => 'table',
 572    'Table_locks_'      => 'table',
 573
 574    'Rpl_status'        => 'repl',
 575    'Slave_'            => 'repl',
 576
 577    'Tc_'               => 'tc',
 578
 579    'Ssl_'              => 'ssl',
 580
 581    'Open_files'        => 'files',
 582    'Open_streams'      => 'files',
 583    'Opened_files'      => 'files',
 584);
 585
 586$sections = array(
 587    // section => section name (description)
 588    'com'           => 'Com',
 589    'query'         => __('SQL query'),
 590    'innodb'        => 'InnoDB',
 591    'ndb'           => 'NDB',
 592    'handler'       => __('Handler'),
 593    'qcache'        => __('Query cache'),
 594    'threads'       => __('Threads'),
 595    'binlog_cache'  => __('Binary log'),
 596    'created_tmp'   => __('Temporary data'),
 597    'delayed'       => __('Delayed inserts'),
 598    'key'           => __('Key cache'),
 599    'select'        => __('Joins'),
 600    'repl'          => __('Replication'),
 601    'sort'          => __('Sorting'),
 602    'table'         => __('Tables'),
 603    'tc'            => __('Transaction coordinator'),
 604    'files'         => __('Files'),
 605    'ssl'           => 'SSL',
 606    'other'         => __('Other')
 607);
 608
 609/**
 610 * define some needfull links/commands
 611 */
 612// variable or section name => (name => url)
 613$links = array();
 614
 615$links['table'][__('Flush (close) all tables')]
 616    = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
 617$links['table'][__('Show open tables')]
 618    = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
 619        '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
 620
 621if ($server_master_status) {
 622    $links['repl'][__('Show slave hosts')]
 623        = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
 624            '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
 625    $links['repl'][__('Show master status')] = '#replication_master';
 626}
 627if ($server_slave_status) {
 628    $links['repl'][__('Show slave status')] = '#replication_slave';
 629}
 630
 631$links['repl']['doc'] = 'replication';
 632
 633$links['qcache'][__('Flush query cache')]
 634    = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
 635        PMA_generate_common_url();
 636$links['qcache']['doc'] = 'query_cache';
 637
 638//$links['threads'][__('Show processes')]
 639//    = 'server_processlist.php?' . PMA_generate_common_url();
 640$links['threads']['doc'] = 'mysql_threads';
 641
 642$links['key']['doc'] = 'myisam_key_cache';
 643
 644$links['binlog_cache']['doc'] = 'binary_log';
 645
 646$links['Slow_queries']['doc'] = 'slow_query_log';
 647
 648$links['innodb'][__('Variables')]
 649    = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
 650$links['innodb'][__('InnoDB Status')]
 651    = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
 652        PMA_generate_common_url();
 653$links['innodb']['doc'] = 'innodb';
 654
 655
 656// Variable to contain all com_ variables (query statistics)
 657$used_queries = array();
 658
 659// Variable to map variable names to their respective section name
 660// (used for js category filtering)
 661$allocationMap = array();
 662
 663// Variable to mark used sections
 664$categoryUsed = array();
 665
 666// sort vars into arrays
 667foreach ($server_status as $name => $value) {
 668    $section_found = false;
 669    foreach ($allocations as $filter => $section) {
 670        if (strpos($name, $filter) !== false) {
 671            $allocationMap[$name] = $section;
 672            $categoryUsed[$section] = true;
 673            $section_found = true;
 674            if ($section == 'com' && $value > 0) {
 675                $used_queries[$name] = $value;
 676            }
 677            break; // Only exits inner loop
 678        }
 679    }
 680    if (!$section_found) {
 681        $allocationMap[$name] = 'other';
 682        $categoryUsed['other'] = true;
 683    }
 684}
 685
 686if (PMA_DRIZZLE) {
 687    $used_queries = PMA_DBI_fetch_result(
 688        'SELECT * FROM data_dictionary.global_statements',
 689        0,
 690        1
 691    );
 692    unset($used_queries['admin_commands']);
 693} else {
 694    // admin commands are not queries (e.g. they include COM_PING,
 695    // which is excluded from $server_status['Questions'])
 696    unset($used_queries['Com_admin_commands']);
 697}
 698
 699/* Ajax request refresh */
 700if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
 701    switch($_REQUEST['show']) {
 702    case 'query_statistics':
 703        printQueryStatistics();
 704        exit();
 705    case 'server_traffic':
 706        printServerTraffic();
 707        exit();
 708    case 'variables_table':
 709        // Prints the variables table
 710        printVariablesTable();
 711        exit();
 712
 713    default:
 714        break;
 715    }
 716}
 717
 718$server_db_isLocal = strtolower($cfg['Server']['host']) == 'localhost'
 719                              || $cfg['Server']['host'] == '127.0.0.1'
 720                              || $cfg['Server']['host'] == '::1';
 721
 722PMA_AddJSVar(
 723    'pma_token',
 724    $_SESSION[' PMA_token ']
 725);
 726PMA_AddJSVar(
 727    'url_query',
 728    str_replace('&amp;', '&', PMA_generate_common_url($db))
 729);
 730PMA_AddJSVar(
 731    'server_time_diff',
 732    'new Date().getTime() - ' . (microtime(true) * 1000),
 733    false
 734);
 735PMA_AddJSVar(
 736    'server_os',
 737    PHP_OS
 738);
 739PMA_AddJSVar(
 740    'is_superuser',
 741    PMA_isSuperuser()
 742);
 743PMA_AddJSVar(
 744    'server_db_isLocal',
 745    $server_db_isLocal
 746);
 747PMA_AddJSVar(
 748    'profiling_docu',
 749    PMA_showMySQLDocu('general-thread-states', 'general-thread-states')
 750);
 751PMA_AddJSVar(
 752    'explain_docu',
 753    PMA_showMySQLDocu('explain-output', 'explain-output')
 754);
 755
 756/**
 757 * start output
 758 */
 759
 760 /**
 761 * Does the common work
 762 */
 763require './libraries/server_common.inc.php';
 764
 765
 766
 767/**
 768 * Displays the links
 769 */
 770require './libraries/server_links.inc.php';
 771
 772?>
 773<div id="serverstatus">
 774    <h2><?php
 775/**
 776 * Displays the sub-page heading
 777 */
 778if ($GLOBALS['cfg']['MainPageIconic']) {
 779    echo PMA_getImage('s_status.png');
 780}
 781
 782echo __('Runtime Information');
 783
 784?></h2>
 785    <div id="serverStatusTabs">
 786        <ul>
 787            <li><a href="#statustabs_traffic"><?php echo __('Server'); ?></a></li>
 788            <li><a href="#statustabs_queries"><?php echo __('Query statistics'); ?></a></li>
 789            <li><a href="#statustabs_allvars"><?php echo __('All status variables'); ?></a></li>
 790            <li class="jsfeature"><a href="#statustabs_charting"><?php echo __('Monitor'); ?></a></li>
 791            <li class="jsfeature"><a href="#statustabs_advisor"><?php echo __('Advisor'); ?></a></li>
 792        </ul>
 793
 794        <div id="statustabs_traffic" class="clearfloat">
 795            <div class="buttonlinks jsfeature">
 796                <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=server_traffic&amp;' . PMA_generate_common_url(); ?>" >
 797                    <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
 798                    <?php echo __('Refresh'); ?>
 799                </a>
 800                <span class="refreshList" style="display:none;">
 801                    <label for="id_trafficChartRefresh"><?php echo __('Refresh rate: '); ?></label>
 802                    <?php refreshList('trafficChartRefresh'); ?>
 803                </span>
 804
 805                <a class="tabChart livetrafficLink" href="#">
 806                    <?php echo __('Live traffic chart'); ?>
 807                </a>
 808                <a class="tabChart liveconnectionsLink" href="#">
 809                    <?php echo __('Live conn./process chart'); ?>
 810                </a>
 811            </div>
 812            <div class="tabInnerContent">
 813                <?php printServerTraffic(); ?>
 814            </div>
 815        </div>
 816        <div id="statustabs_queries" class="clearfloat">
 817            <div class="buttonlinks jsfeature">
 818                <a class="tabRefresh"  href="<?php echo $PMA_PHP_SELF . '?show=query_statistics&amp;' . PMA_generate_common_url(); ?>" >
 819                    <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
 820                    <?php echo __('Refresh'); ?>
 821                </a>
 822                <span class="refreshList" style="display:none;">
 823                    <label for="id_queryChartRefresh"><?php echo __('Refresh rate: '); ?></label>
 824                       <?php refreshList('queryChartRefresh'); ?>
 825                </span>
 826                <a class="tabChart livequeriesLink" href="#">
 827                    <?php echo __('Live query chart'); ?>
 828                </a>
 829            </div>
 830            <div class="tabInnerContent">
 831                <?php printQueryStatistics(); ?>
 832            </div>
 833        </div>
 834        <div id="statustabs_allvars" class="clearfloat">
 835            <fieldset id="tableFilter" class="jsfeature">
 836                <div class="buttonlinks">
 837                    <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=variables_table&amp;' . PMA_generate_common_url(); ?>" >
 838                        <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
 839                        <?php echo __('Refresh'); ?>
 840                    </a>
 841                </div>
 842                <legend><?php echo __('Filters'); ?></legend>
 843                <div class="formelement">
 844                    <label for="filterText"><?php echo __('Containing the word:'); ?></label>
 845                    <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
 846                </div>
 847                <div class="formelement">
 848                    <input type="checkbox" name="filterAlert" id="filterAlert" />
 849                    <label for="filterAlert"><?php echo __('Show only alert values'); ?></label>
 850                </div>
 851                <div class="formelement">
 852                    <select id="filterCategory" name="filterCategory">
 853                        <option value=''><?php echo __('Filter by category...'); ?></option>
 854                <?php
 855                        foreach ($sections as $section_id => $section_name) {
 856                            if (isset($categoryUsed[$section_id])) {
 857                ?>
 858                                <option value='<?php echo $section_id; ?>'><?php echo $section_name; ?></option>
 859                <?php
 860                            }
 861                        }
 862                ?>
 863                    </select>
 864                </div>
 865                <div class="formelement">
 866                    <input type="checkbox" name="dontFormat" id="dontFormat" />
 867                    <label for="dontFormat"><?php echo __('Show unformatted values'); ?></label>
 868                </div>
 869            </fieldset>
 870            <div id="linkSuggestions" class="defaultLinks" style="display:none">
 871                <p class="notice"><?php echo __('Related links:'); ?>
 872                <?php
 873                foreach ($links as $section_name => $section_links) {
 874                    echo '<span class="status_' . $section_name . '"> ';
 875                    $i=0;
 876                    foreach ($section_links as $link_name => $link_url) {
 877                        if ($i > 0) {
 878                            echo ', ';
 879                        }
 880                        if ('doc' == $link_name) {
 881                            echo PMA_showMySQLDocu($link_url, $link_url);
 882                        } else {
 883                            echo '<a href="' . $link_url . '">' . $link_name . '</a>';
 884                        }
 885                        $i++;
 886                    }
 887                    echo '</span>';
 888                }
 889                unset($link_url, $link_name, $i);
 890                ?>
 891                </p>
 892            </div>
 893            <div class="tabInnerContent">
 894                <?php printVariablesTable(); ?>
 895            </div>
 896        </div>
 897
 898        <div id="statustabs_charting" class="jsfeature">
 899            <?php printMonitor(); ?>
 900        </div>
 901
 902        <div id="statustabs_advisor" class="jsfeature">
 903            <div class="tabLinks">
 904                <?php echo PMA_getImage('play.png'); ?> <a href="#startAnalyzer"><?php echo __('Run analyzer'); ?></a>
 905                <?php echo PMA_getImage('b_help.png'); ?> <a href="#openAdvisorInstructions"><?php echo __('Instructions'); ?></a>
 906            </div>
 907            <div class="tabInnerContent clearfloat">
 908            </div>
 909            <div id="advisorInstructionsDialog" style="display:none;">
 910            <?php
 911            echo '<p>';
 912            echo __('The Advisor system can provide recommendations on server variables by analyzing the server status variables.');
 913            echo '</p> <p>';
 914            echo __('Do note however that this system provides recommendations based on simple calculations and by rule of thumb which may not necessarily apply to your system.');
 915            echo '</p> <p>';
 916            echo __('Prior to changing any of the configuration, be sure to know what you are changing (by reading the documentation) and how to undo the change. Wrong tuning can have a very negative effect on performance.');
 917            echo '</p> <p>';
 918            echo __('The best way to tune your system would be to change only one setting at a time, observe or benchmark your database, and undo the change if there was no clearly measurable improvement.');
 919            echo '</p>';
 920            ?>
 921            </div>
 922        </div>
 923    </div>
 924</div>
 925
 926<?php
 927
 928function printQueryStatistics()
 929{
 930    global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
 931
 932    $hour_factor   = 3600 / $server_status['Uptime'];
 933
 934    $total_queries = array_sum($used_queries);
 935
 936    ?>
 937    <h3 id="serverstatusqueries">
 938        <?php
 939        /* l10n: Questions is the name of a MySQL Status variable */
 940        echo sprintf(__('Questions since startup: %s'), PMA_formatNumber($total_queries, 0)) . ' ';
 941        echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
 942        ?>
 943        <br />
 944        <span>
 945        <?php
 946        echo '&oslash; ' . __('per hour') . ': ';
 947        echo PMA_formatNumber($total_queries * $hour_factor, 0);
 948        echo '<br />';
 949
 950        echo '&oslash; ' . __('per minute') . ': ';
 951        echo PMA_formatNumber($total_queries * 60 / $server_status['Uptime'], 0);
 952        echo '<br />';
 953
 954        if ($total_queries / $server_status['Uptime'] >= 1) {
 955            echo '&oslash; ' . __('per second') . ': ';
 956            echo PMA_formatNumber($total_queries / $server_status['Uptime'], 0);
 957        }
 958        ?>
 959        </span>
 960    </h3>
 961    <?php
 962
 963    // reverse sort by value to show most used statements first
 964    arsort($used_queries);
 965
 966    $odd_row        = true;
 967    $count_displayed_rows = 0;
 968    $perc_factor    = 100 / $total_queries; //(- $server_status['Connections']);
 969
 970    ?>
 971
 972        <table id="serverstatusqueriesdetails" class="data sortable noclick">
 973        <col class="namecol" />
 974        <col class="valuecol" span="3" />
 975        <thead>
 976            <tr><th><?php echo __('Statements'); ?></th>
 977                <th><?php
 978                    /* l10n: # = Amount of queries */
 979                    echo __('#');
 980                    ?>
 981                </th>
 982                <th>&oslash; <?php echo __('per hour'); ?></th>
 983                <th>%</th>
 984            </tr>
 985        </thead>
 986        <tbody>
 987
 988    <?php
 989    $chart_json = array();
 990    $query_sum = array_sum($used_queries);
 991    $other_sum = 0;
 992    foreach ($used_queries as $name => $value) {
 993        $odd_row = !$odd_row;
 994
 995        // For the percentage column, use Questions - Connections, because
 996        // the number of connections is not an item of the Query types
 997        // but is included in Questions. Then the total of the percentages is 100.
 998        $name = str_replace(array('Com_', '_'), array('', ' '), $name);
 999
1000        // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
1001        if ($value < $query_sum * 0.02 && count($chart_json)>6) {
1002            $other_sum += $value;
1003        } else {
1004            $chart_json[$name] = $value;
1005        }
1006    ?>
1007            <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
1008                <th class="name"><?php echo htmlspecialchars($name); ?></th>
1009                <td class="value"><?php echo htmlspecialchars(PMA_formatNumber($value, 5, 0, true)); ?></td>
1010                <td class="value"><?php echo
1011                    htmlspecialchars(PMA_formatNumber($value * $hour_factor, 4, 1, true)); ?></td>
1012                <td class="value"><?php echo
1013                    htmlspecialchars(PMA_formatNumber($value * $perc_factor, 0, 2)); ?>%</td>
1014            </tr>
1015    <?php
1016    }
1017    ?>
1018        </tbody>
1019        </table>
1020
1021        <div id="serverstatusquerieschart">
1022            <span style="display:none;">
1023        <?php
1024            if ($other_sum > 0) {
1025                $chart_json[__('Other')] = $other_sum;
1026            }
1027
1028            echo json_encode($chart_json);
1029        ?>
1030            </span>
1031        </div>
1032        <?php
1033}
1034
1035function printServerTraffic()
1036{
1037    global $server_status, $PMA_PHP_SELF;
1038    global $server_master_status, $server_slave_status, $replication_types;
1039
1040    $hour_factor    = 3600 / $server_status['Uptime'];
1041
1042    /**
1043     * starttime calculation
1044     */
1045    $start_time = PMA_DBI_fetch_value(
1046        'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']
1047    );
1048
1049    ?>
1050    <h3><?php
1051    echo sprintf(
1052        __('Network traffic since startup: %s'),
1053        implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))
1054    );
1055    ?>
1056    </h3>
1057
1058    <p>
1059    <?php
1060    echo sprintf(
1061        __('This MySQL server has been running for %1$s. It started up on %2$s.'),
1062        PMA_timespanFormat($server_status['Uptime']),
1063        PMA_localisedDate($start_time)
1064    ) . "\n";
1065    ?>
1066    </p>
1067
1068    <?php
1069    if ($server_master_status || $server_slave_status) {
1070        echo '<p class="notice">';
1071        if ($server_master_status && $server_slave_status) {
1072            echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
1073        } elseif ($server_master_status) {
1074            echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
1075        } elseif ($server_slave_status) {
1076            echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
1077        }
1078        echo ' ';
1079        echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
1080        echo '</p>';
1081    }
1082
1083    /* if the server works as master or slave in replication process, display useful information */
1084    if ($server_master_status || $server_slave_status) {
1085    ?>
1086      <hr class="clearfloat" />
1087
1088      <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
1089    <?php
1090
1091        foreach ($replication_types as $type) {
1092            if (${"server_{$type}_status"}) {
1093                PMA_replication_print_status_table($type);
1094            }
1095        }
1096        unset($types);
1097    }
1098    ?>
1099
1100    <table id="serverstatustraffic" class="data noclick">
1101    <thead>
1102    <tr>
1103        <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>
1104        <th>&oslash; <?php echo __('per hour'); ?></th>
1105    </tr>
1106    </thead>
1107    <tbody>
1108    <tr class="odd">
1109        <th class="name"><?php echo __('Received'); ?></th>
1110        <td class="value"><?php echo
1111            implode(' ',
1112                PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?></td>
1113        <td class="value"><?php echo
1114            implode(' ',
1115                PMA_formatByteDown(
1116                    $server_status['Bytes_received'] * $hour_factor, 3, 1)); ?></td>
1117    </tr>
1118    <tr class="even">
1119        <th class="name"><?php echo __('Sent'); ?></th>
1120        <td class="value"><?php echo
1121            implode(' ',
1122                PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?></td>
1123        <td class="value"><?php echo
1124            implode(' ',
1125                PMA_formatByteDown(
1126                    $server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?></td>
1127    </tr>
1128    <tr class="odd">
1129        <th class="name"><?php echo __('Total'); ?></th>
1130        <td class="value"><?php echo
1131            implode(' ',
1132                PMA_formatByteDown(
1133                    $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)
1134            ); ?></td>
1135        <td class="value"><?php echo
1136            implode(' ',
1137                PMA_formatByteDown(
1138                    ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
1139                    * $hour_factor, 3, 1)
1140            ); ?></td>
1141    </tr>
1142    </tbody>
1143    </table>
1144
1145    <table id="serverstatusconnections" class="data noclick">
1146    <thead>
1147    <tr>
1148        <th colspan="2"><?php echo __('Connections'); ?></th>
1149        <th>&oslash; <?php echo __('per hour'); ?></th>
1150        <th>%</th>
1151    </tr>
1152    </thead>
1153    <tbody>
1154    <tr class="odd">
1155        <th class="name"><?php echo __('max. concurrent connections'); ?></th>
1156        <td class="value"><?php echo
1157            PMA_formatNumber($server_status['Max_used_connections'], 0); ?>  </td>
1158        <td class="value">--- </td>
1159        <td class="value">--- </td>
1160    </tr>
1161    <tr class="even">
1162        <th class="name"><?php echo __('Failed attempts'); ?></th>
1163        <td class="value"><?php echo
1164            PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
1165        <td class="value"><?php echo
1166            PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
1167                4, 2, true); ?></td>
1168        <td class="value"><?php echo
1169            $server_status['Connections'] > 0
1170          ? PMA_formatNumber(
1171                $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
1172                0, 2, true) . '%'
1173          : '--- '; ?></td>
1174    </tr>
1175    <tr class="odd">
1176        <th class="name"><?php echo __('Aborted'); ?></th>
1177        <td class="value"><?php echo
1178            PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
1179        <td class="value"><?php echo
1180            PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
1181                4, 2, true); ?></td>
1182        <td class="value"><?php echo
1183            $server_status['Connections'] > 0
1184          ? PMA_formatNumber(
1185                $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
1186                0, 2, true) . '%'
1187          : '--- '; ?></td>
1188    </tr>
1189    <tr class="even">
1190        <th class="name"><?php echo __('Total'); ?></th>
1191        <td class="value"><?php echo
1192            PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
1193        <td class="value"><?php echo
1194            PMA_formatNumber($server_status['Connections'] * $hour_factor,
1195                4, 2); ?></td>
1196        <td class="value"><?php echo
1197            PMA_formatNumber(100, 0, 2); ?>%</td>
1198    </tr>
1199    </tbody>
1200    </table>
1201    <?php
1202
1203    $url_params = array();
1204
1205    $show_full_sql = !empty($_REQUEST['full']);
1206    if ($show_full_sql) {
1207        $url_params['full'] = 1;
1208        $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
1209    } else {
1210        $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
1211    }
1212    if (PMA_DRIZZLE) {
1213        $sql_query = "SELECT
1214                p.id       AS Id,
1215                p.username AS User,
1216                p.host     AS Host,
1217                p.db       AS db,
1218                p.command  AS Command,
1219                p.time     AS Time,
1220                p.state    AS State,
1221                " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info
1222            FROM data_dictionary.PROCESSLIST p
1223                " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
1224    } else {
1225        $sql_query = $show_full_sql
1226            ? 'SHOW FULL PROCESSLIST'
1227            : 'SHOW PROCESSLIST';
1228    }
1229    $result = PMA_DBI_query($sql_query);
1230
1231    /**
1232     * Displays the page
1233     */
1234    ?>
1235    <table id="tableprocesslist" class="data clearfloat noclick">
1236    <thead>
1237    <tr>
1238        <th><?php echo __('Processes'); ?></th>
1239        <th><?php echo __('ID'); ?></th>
1240        <th><?php echo __('User'); ?></th>
1241        <th><?php echo __('Host'); ?></th>
1242        <th><?php echo __('Database'); ?></th>
1243        <th><?php echo __('Command'); ?></th>
1244        <th><?php echo __('Time'); ?></th>
1245        <th><?php echo __('Status'); ?></th>
1246        <th><?php
1247            echo __('SQL query');
1248            if (! PMA_DRIZZLE) {
1249                ?>
1250            <a href="<?php echo $full_text_link; ?>"
1251                title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>">
1252                <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?>text.png"
1253                alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>" />
1254            </a>
1255            <?php } ?>
1256        </th>
1257    </tr>
1258    </thead>
1259    <tbody>
1260    <?php
1261    $odd_row = true;
1262    while ($process = PMA_DBI_fetch_assoc($result)) {
1263        $url_params['kill'] = $process['Id'];
1264        $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
1265        ?>
1266    <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
1267        <td><a href="<?php echo $kill_process ; ?>"><?php echo __('Kill'); ?></a></td>
1268        <td class="value"><?php echo $process['Id']; ?></td>
1269        <td><?php echo $process['User']; ?></td>
1270        <td><?php echo $process['Host']; ?></td>
1271        <td><?php echo ((! isset($process['db']) || ! strlen($process['db'])) ? '<i>' . __('None') . '</i>' : $process['db']); ?></td>
1272        <td><?php echo $process['Command']; ?></td>
1273        <td class="value"><?php echo $process['Time']; ?></td>
1274        <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
1275        <td>
1276        <?php
1277        if (empty($process['Info'])) {
1278            echo '---';
1279        } else {
1280            if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
1281                echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
1282            } else {
1283                echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
1284            }
1285        }
1286        ?>
1287        </td>
1288    </tr>
1289        <?php
1290        $odd_row = ! $odd_row;
1291    }
1292    ?>
1293    </tbody>
1294    </table>
1295    <?php
1296}
1297
1298function printVariablesTable()
1299{
1300    global $server_status, $server_variables, $allocationMap, $links;
1301    /**
1302     * Messages are built using the message name
1303     */
1304    $strShowStatus = array(
1305        'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
1306        'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
1307        '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.'),
1308        'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
1309        'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
1310        '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.'),
1311        'Created_tmp_files' => __('How many temporary files mysqld has created.'),
1312        'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
1313        'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
1314        '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.'),
1315        'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
1316        'Flush_commands'  => __('The number of executed FLUSH statements.'),
1317        'Handler_commit' => __('The number of internal COMMIT statements.'),
1318        'Handler_delete' => __('The number of times a row was deleted from a table.'),
1319        '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.'),
1320        '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.'),
1321        '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.'),
1322        '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.'),
1323        'Handler_read_prev' => __('The number of requests to read the previous row in key order. T…

Large files files are truncated, but you can click here to view the full file