mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Added ability to show links to fixes for validate (#6054)
* feature: Added ability to show links to fixes for validate * Finish this PR up and add a few more messages Move collation checks to print_list()
This commit is contained in:
@@ -1481,6 +1481,12 @@ function get_auth_ad_group_filter($groupname)
|
|||||||
*/
|
*/
|
||||||
function print_list($list, $format, $max = 10)
|
function print_list($list, $format, $max = 10)
|
||||||
{
|
{
|
||||||
|
if (is_array(current($list))) {
|
||||||
|
$list = array_map(function ($item) {
|
||||||
|
return implode(' ', $item);
|
||||||
|
}, $list);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (array_slice($list, 0, $max) as $item) {
|
foreach (array_slice($list, 0, $max) as $item) {
|
||||||
printf($format, $item);
|
printf($format, $item);
|
||||||
}
|
}
|
||||||
|
72
validate.php
72
validate.php
@@ -145,7 +145,11 @@ if (isset($config['user'])) {
|
|||||||
// This isn't just the log directory, let's print the list to the user
|
// This isn't just the log directory, let's print the list to the user
|
||||||
$files = explode(PHP_EOL, $find_result);
|
$files = explode(PHP_EOL, $find_result);
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
print_fail("We have found some files that are owned by a different user than $tmp_user, this will stop you updating automatically and / or rrd files being updated causing graphs to fail:\nIf you don't run a bespoke install then you can fix this by running `chown -R $tmp_user:$tmp_user ".$config['install_dir']."`");
|
print_fail(
|
||||||
|
"We have found some files that are owned by a different user than $tmp_user, " .
|
||||||
|
'this will stop you updating automatically and / or rrd files being updated causing graphs to fail.',
|
||||||
|
"chown -R $tmp_user:$tmp_user {$config['install_dir']}"
|
||||||
|
);
|
||||||
print_list($files, "\t %s\n");
|
print_list($files, "\t %s\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,7 +167,7 @@ if (mysqli_connect_error()) {
|
|||||||
|
|
||||||
// Test for MySQL Strict mode
|
// Test for MySQL Strict mode
|
||||||
$strict_mode = dbFetchCell("SELECT @@global.sql_mode");
|
$strict_mode = dbFetchCell("SELECT @@global.sql_mode");
|
||||||
if (strstr($strict_mode, 'STRICT_TRANS_TABLES')) {
|
if (str_contains($strict_mode, 'STRICT_TRANS_TABLES')) {
|
||||||
//FIXME - Come back to this once other MySQL modes are fixed
|
//FIXME - Come back to this once other MySQL modes are fixed
|
||||||
//print_fail('You have MySQL STRICT_TRANS_TABLES enabled, please disable this until full support has been added: https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html');
|
//print_fail('You have MySQL STRICT_TRANS_TABLES enabled, please disable this until full support has been added: https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html');
|
||||||
}
|
}
|
||||||
@@ -175,23 +179,17 @@ if (empty($strict_mode) === false) {
|
|||||||
// Test for correct character set and collation
|
// Test for correct character set and collation
|
||||||
$collation = dbFetchRows("SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA S WHERE schema_name = '" . $config['db_name'] . "' AND ( DEFAULT_CHARACTER_SET_NAME != 'utf8' OR DEFAULT_COLLATION_NAME != 'utf8_unicode_ci')");
|
$collation = dbFetchRows("SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA S WHERE schema_name = '" . $config['db_name'] . "' AND ( DEFAULT_CHARACTER_SET_NAME != 'utf8' OR DEFAULT_COLLATION_NAME != 'utf8_unicode_ci')");
|
||||||
if (empty($collation) !== true) {
|
if (empty($collation) !== true) {
|
||||||
print_fail('MySQL Database collation is wrong: ' . implode(' ', $collation[0]));
|
print_fail('MySQL Database collation is wrong: ' . implode(' ', $collation[0]), 'http://bit.ly/2lAG9H8');
|
||||||
}
|
}
|
||||||
$collation = dbFetchRows("SELECT T.TABLE_NAME, C.CHARACTER_SET_NAME, C.COLLATION_NAME FROM information_schema.TABLES AS T, information_schema.COLLATION_CHARACTER_SET_APPLICABILITY AS C WHERE C.collation_name = T.table_collation AND T.table_schema = '" . $config['db_name'] . "' AND ( C.CHARACTER_SET_NAME != 'utf8' OR C.COLLATION_NAME != 'utf8_unicode_ci' );");
|
$collation_tables = dbFetchRows("SELECT T.TABLE_NAME, C.CHARACTER_SET_NAME, C.COLLATION_NAME FROM information_schema.TABLES AS T, information_schema.COLLATION_CHARACTER_SET_APPLICABILITY AS C WHERE C.collation_name = T.table_collation AND T.table_schema = '" . $config['db_name'] . "' AND ( C.CHARACTER_SET_NAME != 'utf8' OR C.COLLATION_NAME != 'utf8_unicode_ci' );");
|
||||||
if (empty($collation) !== true) {
|
if (empty($collation_tables) !== true) {
|
||||||
$error = '';
|
print_fail('MySQL tables collation is wrong: ', 'http://bit.ly/2lAG9H8');
|
||||||
foreach ($collation as $id => $data) {
|
print_list($collation_tables, "\t %s\n");
|
||||||
$error .= implode(' ', $data) . PHP_EOL;
|
|
||||||
}
|
|
||||||
print_fail('MySQL tables collation is wrong: ' . $error);
|
|
||||||
}
|
}
|
||||||
$collation = dbFetchRows("SELECT TABLE_NAME, COLUMN_NAME, CHARACTER_SET_NAME, COLLATION_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . $config['db_name'] . "' AND ( CHARACTER_SET_NAME != 'utf8' OR COLLATION_NAME != 'utf8_unicode_ci' );");
|
$collation_columns = dbFetchRows("SELECT TABLE_NAME, COLUMN_NAME, CHARACTER_SET_NAME, COLLATION_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . $config['db_name'] . "' AND ( CHARACTER_SET_NAME != 'utf8' OR COLLATION_NAME != 'utf8_unicode_ci' );");
|
||||||
if (empty($collation) !== true) {
|
if (empty($collation_columns) !== true) {
|
||||||
$error = '';
|
print_fail('MySQL column collation is wrong: ', 'http://bit.ly/2lAG9H8');
|
||||||
foreach ($collation as $id => $data) {
|
print_list($collation_columns, "\t %s\n");
|
||||||
$error .= implode(' ', $data) . PHP_EOL;
|
|
||||||
}
|
|
||||||
print_fail('MySQL column collation is wrong: ' . $error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ini_tz = ini_get('date.timezone');
|
$ini_tz = ini_get('date.timezone');
|
||||||
@@ -199,7 +197,10 @@ $sh_tz = rtrim(shell_exec('date +%Z'));
|
|||||||
$php_tz = date('T');
|
$php_tz = date('T');
|
||||||
|
|
||||||
if (empty($ini_tz)) {
|
if (empty($ini_tz)) {
|
||||||
print_fail('You have no timezone set for php: http://php.net/manual/en/datetime.configuration.php#ini.date.timezone.');
|
print_fail(
|
||||||
|
'You have no timezone set for php.',
|
||||||
|
'http://php.net/manual/en/datetime.configuration.php#ini.date.timezone'
|
||||||
|
);
|
||||||
} elseif ($sh_tz !== $php_tz) {
|
} elseif ($sh_tz !== $php_tz) {
|
||||||
print_fail("You have a different system timezone ($sh_tz) specified to the php configured timezone ($php_tz), please correct this.");
|
print_fail("You have a different system timezone ($sh_tz) specified to the php configured timezone ($php_tz), please correct this.");
|
||||||
}
|
}
|
||||||
@@ -217,7 +218,7 @@ if (!$config['rrdcached']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (substr(sprintf('%o', fileperms($config['rrd_dir'])), -3) != 775) {
|
if (substr(sprintf('%o', fileperms($config['rrd_dir'])), -3) != 775) {
|
||||||
print_warn('Your RRD directory is not set to 0775, please check our installation instructions');
|
print_warn('Your RRD directory is not set to 0775', "chmod 775 {$config['rrd_dir']}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +248,7 @@ foreach ($bins as $bin) {
|
|||||||
if (!$cmd) {
|
if (!$cmd) {
|
||||||
print_fail("$bin location is incorrect or bin not installed. \n\tYou can also manually set the path to $bin by placing the following in config.php: \n\t\$config['$bin'] = \"/path/to/$bin\";");
|
print_fail("$bin location is incorrect or bin not installed. \n\tYou can also manually set the path to $bin by placing the following in config.php: \n\t\$config['$bin'] = \"/path/to/$bin\";");
|
||||||
} elseif (in_array($bin, $suid_bins) && !(fileperms($cmd) & 2048)) {
|
} elseif (in_array($bin, $suid_bins) && !(fileperms($cmd) & 2048)) {
|
||||||
print_fail("$bin should be suid, please chmod u+s $cmd");
|
print_fail("$bin should be suid!", "chmod u+s $cmd");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,16 +424,35 @@ function print_ok($msg)
|
|||||||
}//end print_ok()
|
}//end print_ok()
|
||||||
|
|
||||||
|
|
||||||
function print_fail($msg)
|
function print_fail($msg, $fix = null)
|
||||||
{
|
{
|
||||||
c_echo("[%RFAIL%n] $msg\n");
|
c_echo("[%RFAIL%n] $msg");
|
||||||
}//end print_fail()
|
if ($fix && strlen($msg) > 72) {
|
||||||
|
echo PHP_EOL . " ";
|
||||||
|
}
|
||||||
|
print_fix($fix);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function print_warn($msg)
|
function print_warn($msg, $fix = null)
|
||||||
{
|
{
|
||||||
c_echo("[%YWARN%n] $msg\n");
|
c_echo("[%YWARN%n] $msg");
|
||||||
}//end print_warn()
|
if ($fix && strlen($msg) > 72) {
|
||||||
|
echo PHP_EOL . " ";
|
||||||
|
}
|
||||||
|
print_fix($fix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $fix
|
||||||
|
*/
|
||||||
|
function print_fix($fix)
|
||||||
|
{
|
||||||
|
if (!empty($fix)) {
|
||||||
|
c_echo(" [%BFIX%n] %B$fix%n");
|
||||||
|
}
|
||||||
|
echo PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
function check_rrdcached()
|
function check_rrdcached()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user