home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / engines / innodb.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  13.5 KB  |  344 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * @version $Id: innodb.lib.php 10478 2007-07-09 19:41:38Z lem9 $
  5.  */
  6.  
  7. /**
  8.  *
  9.  */
  10. class PMA_StorageEngine_innodb extends PMA_StorageEngine
  11. {
  12.     /**
  13.      * @uses    $GLOBALS['strInnoDBDataHomeDir']
  14.      * @uses    $GLOBALS['strInnoDBDataHomeDirDesc']
  15.      * @uses    $GLOBALS['strInnoDBDataFilePath']
  16.      * @uses    $GLOBALS['strInnoDBAutoextendIncrement']
  17.      * @uses    $GLOBALS['strInnoDBAutoextendIncrementDesc']
  18.      * @uses    $GLOBALS['strInnoDBBufferPoolSize']
  19.      * @uses    $GLOBALS['strInnoDBBufferPoolSizeDesc']
  20.      * @uses    PMA_ENGINE_DETAILS_TYPE_NUMERIC
  21.      * @uses    PMA_ENGINE_DETAILS_TYPE_SIZE
  22.      * @return  array
  23.      */
  24.     function getVariables()
  25.     {
  26.         return array(
  27.             'innodb_data_home_dir' => array(
  28.                 'title' => $GLOBALS['strInnoDBDataHomeDir'],
  29.                 'desc'  => $GLOBALS['strInnoDBDataHomeDirDesc'],
  30.             ),
  31.             'innodb_data_file_path' => array(
  32.                 'title' => $GLOBALS['strInnoDBDataFilePath'],
  33.             ),
  34.             'innodb_autoextend_increment' => array(
  35.                 'title' => $GLOBALS['strInnoDBAutoextendIncrement'],
  36.                 'desc'  => $GLOBALS['strInnoDBAutoextendIncrementDesc'],
  37.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  38.             ),
  39.             'innodb_buffer_pool_size' => array(
  40.                 'title' => $GLOBALS['strInnoDBBufferPoolSize'],
  41.                 'desc'  => $GLOBALS['strInnoDBBufferPoolSizeDesc'],
  42.                 'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
  43.             ),
  44.             'innodb_additional_mem_pool_size' => array(
  45.                 'title' => 'innodb_additional_mem_pool_size',
  46.                 'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
  47.             ),
  48.             'innodb_buffer_pool_awe_mem_mb' => array(
  49.                 'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
  50.             ),
  51.             'innodb_checksums' => array(
  52.             ),
  53.             'innodb_commit_concurrency' => array(
  54.             ),
  55.             'innodb_concurrency_tickets' => array(
  56.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  57.             ),
  58.             'innodb_doublewrite' => array(
  59.             ),
  60.             'innodb_fast_shutdown' => array(
  61.             ),
  62.             'innodb_file_io_threads' => array(
  63.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  64.             ),
  65.             'innodb_file_per_table' => array(
  66.             ),
  67.             'innodb_flush_log_at_trx_commit' => array(
  68.             ),
  69.             'innodb_flush_method' => array(
  70.             ),
  71.             'innodb_force_recovery' => array(
  72.             ),
  73.             'innodb_lock_wait_timeout' => array(
  74.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  75.             ),
  76.             'innodb_locks_unsafe_for_binlog' => array(
  77.             ),
  78.             'innodb_log_arch_dir' => array(
  79.             ),
  80.             'innodb_log_archive' => array(
  81.             ),
  82.             'innodb_log_buffer_size' => array(
  83.                 'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
  84.             ),
  85.             'innodb_log_file_size' => array(
  86.                 'type'  => PMA_ENGINE_DETAILS_TYPE_SIZE,
  87.             ),
  88.             'innodb_log_files_in_group' => array(
  89.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  90.             ),
  91.             'innodb_log_group_home_dir' => array(
  92.             ),
  93.             'innodb_max_dirty_pages_pct' => array(
  94.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  95.             ),
  96.             'innodb_max_purge_lag' => array(
  97.             ),
  98.             'innodb_mirrored_log_groups' => array(
  99.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  100.             ),
  101.             'innodb_open_files' => array(
  102.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  103.             ),
  104.             'innodb_support_xa' => array(
  105.             ),
  106.             'innodb_sync_spin_loops' => array(
  107.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  108.             ),
  109.             'innodb_table_locks' => array(
  110.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  111.             ),
  112.             'innodb_thread_concurrency' => array(
  113.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  114.             ),
  115.             'innodb_thread_sleep_delay' => array(
  116.                 'type'  => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  117.             ),
  118.          );
  119.     }
  120.  
  121.     /**
  122.      * @return  string  SQL query LIKE pattern
  123.      */
  124.     function getVariablesLikePattern()
  125.     {
  126.         return 'innodb\\_%';
  127.     }
  128.  
  129.     /**
  130.      * @uses    $this->support
  131.      * @uses    PMA_ENGINE_SUPPORT_YES
  132.      * @uses    PMA_MYSQL_INT_VERSION
  133.      * @uses    $GLOBALS['strBufferPool']
  134.      * @uses    $GLOBALS['strInnodbStat']
  135.      * @return  array   detail pages
  136.      */
  137.     function getInfoPages()
  138.     {
  139.         if ($this->support < PMA_ENGINE_SUPPORT_YES) {
  140.             return array();
  141.         }
  142.         $pages = array();
  143.         if (PMA_MYSQL_INT_VERSION >= 50002) {
  144.             $pages['Bufferpool'] = $GLOBALS['strBufferPool'];
  145.         }
  146.         $pages['Status'] = $GLOBALS['strInnodbStat'];
  147.         return $pages;
  148.     }
  149.  
  150.     /**
  151.      * returns html tables with stats over inno db buffer pool
  152.      *
  153.      * @uses    PMA_MYSQL_INT_VERSION
  154.      * @uses    PMA_DBI_fetch_result()
  155.      * @uses    PMA_formatNumber()
  156.      * @uses    PMA_formatByteDown()
  157.      * @uses    $GLOBALS['strBufferPoolUsage']
  158.      * @uses    $GLOBALS['strTotalUC']
  159.      * @uses    $GLOBALS['strInnoDBPages']
  160.      * @uses    $GLOBALS['strFreePages']
  161.      * @uses    $GLOBALS['strDirtyPages']
  162.      * @uses    $GLOBALS['strDataPages']
  163.      * @uses    $GLOBALS['strPagesToBeFlushed']
  164.      * @uses    $GLOBALS['strBusyPages']
  165.      * @uses    $GLOBALS['strLatchedPages']
  166.      * @uses    $GLOBALS['strBufferPoolActivity']
  167.      * @uses    $GLOBALS['strReadRequests']
  168.      * @uses    $GLOBALS['strWriteRequests']
  169.      * @uses    $GLOBALS['strBufferReadMisses']
  170.      * @uses    $GLOBALS['strBufferWriteWaits']
  171.      * @uses    $GLOBALS['strBufferReadMissesInPercent']
  172.      * @uses    $GLOBALS['strBufferWriteWaitsInPercent']
  173.      * @uses    join()
  174.      * @uses    htmlspecialchars()
  175.      * @uses    PMA_formatNumber()
  176.      * @return  string  html table with stats
  177.      */
  178.     function getPageBufferpool()
  179.     {
  180.         if (PMA_MYSQL_INT_VERSION < 50002) {
  181.             return false;
  182.         }
  183.         // rabus: The following query is only possible because we know
  184.         // that we are on MySQL 5 here (checked above)!
  185.         // side note: I love MySQL 5 for this. :-)
  186.         $sql = '
  187.              SHOW STATUS
  188.             WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
  189.                OR Variable_name = \'Innodb_page_size\';';
  190.         $status = PMA_DBI_fetch_result($sql, 0, 1);
  191.  
  192.         $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
  193.                 . '    <caption class="tblHeaders">' . "\n"
  194.                 . '        ' . $GLOBALS['strBufferPoolUsage'] . "\n"
  195.                 . '    </caption>' . "\n"
  196.                 . '    <tfoot>' . "\n"
  197.                 . '        <tr>' . "\n"
  198.                 . '            <th colspan="2">' . "\n"
  199.                 . '                ' . $GLOBALS['strTotalUC'] . "\n"
  200.                 . '                : ' . PMA_formatNumber(
  201.                         $status['Innodb_buffer_pool_pages_total'], 0)
  202.                 . ' ' . $GLOBALS['strInnoDBPages']
  203.                 . ' / '
  204.                 . join(' ',
  205.                     PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n"
  206.                 . '            </th>' . "\n"
  207.                 . '        </tr>' . "\n"
  208.                 . '    </tfoot>' . "\n"
  209.                 . '    <tbody>' . "\n"
  210.                 . '        <tr class="odd">' . "\n"
  211.                 . '            <th>' . $GLOBALS['strFreePages'] . '</th>' . "\n"
  212.                 . '            <td class="value">'
  213.                 . PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0)
  214.                 . '</td>' . "\n"
  215.                 . '        </tr>' . "\n"
  216.                 . '        <tr class="even">' . "\n"
  217.                 . '            <th>' . $GLOBALS['strDirtyPages'] . '</th>' . "\n"
  218.                 . '            <td class="value">'
  219.                 . PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0)
  220.                 . '</td>' . "\n"
  221.                 . '        </tr>' . "\n"
  222.                 . '        <tr class="odd">' . "\n"
  223.                 . '            <th>' . $GLOBALS['strDataPages'] . '</th>' . "\n"
  224.                 . '            <td class="value">'
  225.                 . PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n"
  226.                 . '</td>' . "\n"
  227.                 . '        </tr>' . "\n"
  228.                 . '        <tr class="even">' . "\n"
  229.                 . '            <th>' . $GLOBALS['strPagesToBeFlushed'] . '</th>' . "\n"
  230.                 . '            <td class="value">'
  231.                 . PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n"
  232.                 . '</td>' . "\n"
  233.                 . '        </tr>' . "\n"
  234.                 . '        <tr class="odd">' . "\n"
  235.                 . '            <th>' . $GLOBALS['strBusyPages'] . '</th>' . "\n"
  236.                 . '            <td class="value">'
  237.                 . PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n"
  238.                 . '</td>' . "\n"
  239.                 . '        </tr>' . "\n"
  240.                 . '        <tr class="even">' . "\n"
  241.                 . '            <th>' . $GLOBALS['strLatchedPages'] . '</th>' . "\n"
  242.                 . '            <td class="value">'
  243.                 . PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . "\n"
  244.                 . '</td>' . "\n"
  245.                 . '        </tr>' . "\n"
  246.                 . '    </tbody>' . "\n"
  247.                 . '</table>' . "\n\n"
  248.                 . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n"
  249.                 . '    <caption class="tblHeaders">' . "\n"
  250.                 . '        ' . $GLOBALS['strBufferPoolActivity'] . "\n"
  251.                 . '    </caption>' . "\n"
  252.                 . '    <tbody>' . "\n"
  253.                 . '        <tr class="odd">' . "\n"
  254.                 . '            <th>' . $GLOBALS['strReadRequests'] . '</th>' . "\n"
  255.                 . '            <td class="value">'
  256.                 . PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n"
  257.                 . '</td>' . "\n"
  258.                 . '        </tr>' . "\n"
  259.                 . '        <tr class="even">' . "\n"
  260.                 . '            <th>' . $GLOBALS['strWriteRequests'] . '</th>' . "\n"
  261.                 . '            <td class="value">'
  262.                 . PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n"
  263.                 . '</td>' . "\n"
  264.                 . '        </tr>' . "\n"
  265.                 . '        <tr class="odd">' . "\n"
  266.                 . '            <th>' . $GLOBALS['strBufferReadMisses'] . '</th>' . "\n"
  267.                 . '            <td class="value">'
  268.                 . PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n"
  269.                 . '</td>' . "\n"
  270.                 . '        </tr>' . "\n"
  271.                 . '        <tr class="even">' . "\n"
  272.                 . '            <th>' . $GLOBALS['strBufferWriteWaits'] . '</th>' . "\n"
  273.                 . '            <td class="value">'
  274.                 . PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n"
  275.                 . '</td>' . "\n"
  276.                 . '        </tr>' . "\n"
  277.                 . '        <tr class="odd">' . "\n"
  278.                 . '            <th>' . $GLOBALS['strBufferReadMissesInPercent'] . '</th>' . "\n"
  279.                 . '            <td class="value">'
  280.                 . ($status['Innodb_buffer_pool_read_requests'] == 0
  281.                     ? '---'
  282.                     : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n"
  283.                 . '</td>' . "\n"
  284.                 . '        </tr>' . "\n"
  285.                 . '        <tr class="even">' . "\n"
  286.                 . '            <th>' . $GLOBALS['strBufferWriteWaitsInPercent'] . '</th>' . "\n"
  287.                 . '            <td class="value">'
  288.                 . ($status['Innodb_buffer_pool_write_requests'] == 0
  289.                     ? '---'
  290.                     : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n"
  291.                 . '</td>' . "\n"
  292.                 . '        </tr>' . "\n"
  293.                 . '    </tbody>' . "\n"
  294.                 . '</table>' . "\n";
  295.         return $output;
  296.     }
  297.  
  298.     /**
  299.      * returns InnoDB status
  300.      *
  301.      * @uses    htmlspecialchars()
  302.      * @uses    PMA_DBI_fetch_value()
  303.      * @return  string  result of SHOW INNODB STATUS inside pre tags
  304.      */
  305.     function getPageStatus()
  306.     {
  307.         return '<pre id="pre_innodb_status">' . "\n"
  308.             . htmlspecialchars(PMA_DBI_fetch_value('SHOW INNODB STATUS;')) . "\n"
  309.             . '</pre>' . "\n";
  310.     }
  311.  
  312.     /**
  313.      * returns content for page $id
  314.      *
  315.      * @uses    $this->getInfoPages()
  316.      * @uses    array_key_exists()
  317.      * @param   string  $id page id
  318.      * @return  string  html output
  319.      */
  320.     function getPage($id)
  321.     {
  322.         if (! array_key_exists($id, $this->getInfoPages())) {
  323.             return false;
  324.         }
  325.  
  326.         $id = 'getPage' . $id;
  327.  
  328.         return $this->$id();
  329.     }
  330.  
  331.     /**
  332.      * returns string with filename for the MySQL helppage
  333.      * about this storage engne
  334.      *
  335.      * @return  string  mysql helppage filename
  336.      */
  337.     function getMysqlHelpPage()
  338.     {
  339.         return 'innodb';
  340.     }
  341. }
  342.  
  343. ?>
  344.