Centralised innodb buffer check and added to validate

This commit is contained in:
laf
2015-11-19 10:20:56 +00:00
parent 93f85af48b
commit 2e791308f1
3 changed files with 40 additions and 12 deletions

View File

@@ -1278,3 +1278,31 @@ function host_exists($hostname) {
return false;
}
}
/**
* Check the innodb buffer size
*
* @return array including the current set size and the currently used buffer
**/
function innodb_buffer_check() {
$pool['size'] = dbFetchCell('SELECT @@innodb_buffer_pool_size');
// The following query is from the excellent mysqltuner.pl by Major Hayden https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
$pool['used'] = dbFetchCell('SELECT SUM(DATA_LENGTH+INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ("information_schema", "performance_schema", "mysql") AND ENGINE = "InnoDB" GROUP BY ENGINE ORDER BY ENGINE ASC');
return $pool;
}
/**
* Print warning about InnoDB buffer size
*
* @param array $innodb_buffer An array that contains the used and current size
*
* @return string $output
**/
function warn_innodb_buffer($innodb_buffer) {
$output = 'InnoDB Buffersize too small.'.PHP_EOL;
$output .= 'Current size: '.($innodb_buffer['size'] / 1024 / 1024).' MiB'.PHP_EOL;
$output .= 'Minimum Required: '.($innodb_buffer['used'] / 1024 / 1024).' MiB'.PHP_EOL;
$output .= 'To ensure integrity, we\'re not going to pull any updates until the buffersize has been adjusted.'.PHP_EOL;
$output .= 'Config proposal: "innodb_buffer_pool_size = '.pow(2,ceil(log(($innodb_buffer['used'] / 1024 / 1024),2))).'M"'.PHP_EOL;
return $output;
}