Skip to content

Commit

Permalink
InnoDB buffer pool monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Mar 5, 2005
1 parent afc1245 commit 857fdb0
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 37 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ $Source$
libraries/engines/myisam.lib.php:
- Moved engine-specific settings into plugins;
- Added ability to create multiple sub-pages in server_engines.php for
a specific engine.
a specific engine;
- Added a few InnoDB variables. To be continued. :-)
- New InnoDB buffer pool monitor for MySQL >= 5.0.2.

2005-03-04 Marc Delisle <lem9@users.sourceforge.net>
* Documentation.html, libraries/common.lib.php: new FAQ 2.8 about
Expand Down
113 changes: 101 additions & 12 deletions libraries/engines/innodb.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function getVariables() {
),
'innodb_data_file_path' => array(
'title' => $GLOBALS['strInnoDBDataFilePath']
),
'innodb_autoextend_increment' => array(
'title' => $GLOBALS['strInnoDBAutoextendIncrement'],
'desc' => $GLOBALS['strInnoDBAutoextendIncrementDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC
)
);
}
Expand All @@ -20,21 +25,105 @@ function getVariablesLikePattern () {
}

function getInfoPages () {
return array(
'status' => $GLOBALS['strInnodbStat']
);
if ($this->support < PMA_ENGINE_SUPPORT_YES) {
return array();
}
$pages = array();
if (PMA_MYSQL_INT_VERSION >= 50002) {
$pages['bufferpool'] = $GLOBALS['strBufferPool'];
}
$pages['status'] = $GLOBALS['strInnodbStat'];
return $pages;
}

function getPage($id) {
if ($id == 'status') {
$res = PMA_DBI_query('SHOW INNODB STATUS;');
$row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res);
return '<pre>' . "\n"
. htmlspecialchars($row[0]) . "\n"
. '</pre>' . "\n";
} else {
return FALSE;
global $cfg;

switch ($id) {
case 'bufferpool':
if (PMA_MYSQL_INT_VERSION < 50002) {
return FALSE;
}
$res = PMA_DBI_query('SHOW STATUS LIKE \'Innodb\\_buffer\\_pool\\_%\'');
$status = array();
while ($row = PMA_DBI_fetch_row($res)) {
$status[$row[0]] = $row[1];
}
PMA_DBI_free_result($res);
unset($res, $row);
$output = '<table>' . "\n"
. ' <thead>' . "\n"
. ' <tr>' . "\n"
. ' <th colspan="4">' . "\n"
. ' ' . $GLOBALS['strBufferPoolUsage'] . "\n"
. ' </th>' . "\n"
. ' </tr>' . "\n"
. ' </thead>' . "\n"
. ' <tfoot>' . "\n"
. ' <tr>' . "\n"
. ' <th>' . "\n"
. ' ' . $GLOBALS['strTotalUC'] . "\n"
. ' </th>' . "\n"
. ' <th>' . "\n"
. ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_total']) . "\n"
. ' </th>' . "\n"
. ' </tr>' . "\n"
. ' </tfoot>' . "\n"
. ' <tbody>' . "\n"
. ' <tr>' . "\n"
. ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
. ' &nbsp;' . $GLOBALS['strFreePages'] . '&nbsp;' . "\n"
. ' </td>' . "\n"
. ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
. ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_free']) . "\n"
. ' </td>' . "\n"
. ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' &nbsp;' . $GLOBALS['strDirtyPages'] . '&nbsp;' . "\n"
. ' </td>' . "\n"
. ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_dirty']) . "\n"
. ' </td>' . "\n"
. ' </tr>' . "\n"
. ' <tr>' . "\n"
. ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' &nbsp;' . $GLOBALS['strDataPages'] . '&nbsp;' . "\n"
. ' </td>' . "\n"
. ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_data']) . "\n"
. ' </td>' . "\n"
. ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' &nbsp;' . $GLOBALS['strPagesToBeFlushed'] . '&nbsp;' . "\n"
. ' </td>' . "\n"
. ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_flushed']) . "\n"
. ' </td>' . "\n"
. ' </tr>' . "\n"
. ' <tr>' . "\n"
. ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
. ' &nbsp;' . $GLOBALS['strBusyPages'] . '&nbsp;' . "\n"
. ' </td>' . "\n"
. ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
. ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_misc']) . "\n"
. ' </td>' . "\n"
. ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' &nbsp;' . $GLOBALS['strLatchedPages'] . '&nbsp;' . "\n"
. ' </td>' . "\n"
. ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
. ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_latched']) . "\n"
. ' </td>' . "\n"
. ' </tr>' . "\n"
. ' </tbody>' . "\n"
. '</table>' . "\n";
return $output;
case 'status':
$res = PMA_DBI_query('SHOW INNODB STATUS;');
$row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res);
return '<pre>' . "\n"
. htmlspecialchars($row[0]) . "\n"
. '</pre>' . "\n";
default:
return FALSE;
}
}
}
Expand Down
49 changes: 25 additions & 24 deletions server_engines.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
define('PMA_ENGINE_DETAILS_TYPE_PLAINTEXT', 0);
define('PMA_ENGINE_DETAILS_TYPE_SIZE', 1);
define('PMA_ENGINE_DETAILS_TYPE_NUMERIC', 2); //Has no effect yet...
define('PMA_ENGINE_DETAILS_TYPE_BOOLEAN', 3); // 'ON' or 'OFF'
function PMA_generateEngineDetails($variables, $like = NULL, $indent = 0) {
global $cfg;

Expand Down Expand Up @@ -69,36 +70,36 @@ function PMA_generateEngineDetails($variables, $like = NULL, $indent = 0) {
foreach ($variables as $var => $details) {
if (!isset($mysql_vars[$var])) continue;

if (!isset($details['type'])) $details['type'] = PMA_ENGINE_DETAILS_TYPE_PLAINTEXT;
$is_num = $details['type'] == PMA_ENGINE_DETAILS_TYPE_SIZE || $details['type'] == PMA_ENGINE_DETAILS_TYPE_NUMERIC;
if (!isset($details['type'])) $details['type'] = PMA_ENGINE_DETAILS_TYPE_PLAINTEXT;
$is_num = $details['type'] == PMA_ENGINE_DETAILS_TYPE_SIZE || $details['type'] == PMA_ENGINE_DETAILS_TYPE_NUMERIC;

$bgcolor = $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];

$dt_table .= $spaces . ' <tr>' . "\n"
. $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n";
if (!empty($variables[$var]['desc'])) {
$dt_table .= $spaces . ' ' . PMA_showHint($details['desc']) . "\n";
}
$dt_table .= $spaces . ' </td>' . "\n"
. $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n"
. $spaces . ' &nbsp;' . $details['title'] . '&nbsp;' . "\n"
. $spaces . ' </td>' . "\n"
. $spaces . ' <td bgcolor="' . $bgcolor . '"' . ($is_num ? ' align="right"' : '') . '>' . "\n"
. $spaces . ' &nbsp;';
. $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n";
if (!empty($variables[$var]['desc'])) {
$dt_table .= $spaces . ' ' . PMA_showHint($details['desc']) . "\n";
}
$dt_table .= $spaces . ' </td>' . "\n"
. $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n"
. $spaces . ' &nbsp;' . $details['title'] . '&nbsp;' . "\n"
. $spaces . ' </td>' . "\n"
. $spaces . ' <td bgcolor="' . $bgcolor . '"' . ($is_num ? ' align="right"' : '') . '>' . "\n"
. $spaces . ' &nbsp;';
switch ($details['type']) {
case PMA_ENGINE_DETAILS_TYPE_SIZE:
$parsed_size = PMA_formatByteDown($mysql_vars[$var]);
$dt_table .= $parsed_size[0] . '&nbsp;' . $parsed_size[1];
unset($parsed_size);
break;
default:
$dt_table .= htmlspecialchars($mysql_vars[$var]);
}
$dt_table .= '&nbsp;' . "\n"
. $spaces . ' </td>' . "\n"
. $spaces . ' </tr>' . "\n";
case PMA_ENGINE_DETAILS_TYPE_SIZE:
$parsed_size = PMA_formatByteDown($mysql_vars[$var]);
$dt_table .= $parsed_size[0] . '&nbsp;' . $parsed_size[1];
unset($parsed_size);
break;
default:
$dt_table .= htmlspecialchars($mysql_vars[$var]);
}
$dt_table .= '&nbsp;' . "\n"
. $spaces . ' </td>' . "\n"
. $spaces . ' </tr>' . "\n";
$useBgcolorOne = !$useBgcolorOne;
$has_content = TRUE;
$has_content = TRUE;
}

if (!$has_content) return '';
Expand Down

0 comments on commit 857fdb0

Please sign in to comment.