This commit is contained in:
2024-10-14 00:08:40 +02:00
parent dbfba56f66
commit 1462d52e13
4572 changed files with 2658864 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::Charset;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
$DBObject->Prepare( SQL => "show variables like 'character_set_client'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[1] =~ /utf8/i ) {
$Self->AddResultOk(
Identifier => 'ClientEncoding',
Label => Translatable('Client Connection Charset'),
Value => $Row[1],
);
}
else {
$Self->AddResultProblem(
Identifier => 'ClientEncoding',
Label => Translatable('Client Connection Charset'),
Value => $Row[1],
Message => Translatable('Setting character_set_client needs to be utf8.'),
);
}
}
$DBObject->Prepare( SQL => "show variables like 'character_set_database'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[1] =~ /utf8mb4/i ) {
$Self->AddResultProblem(
Identifier => 'ServerEncoding',
Label => Translatable('Server Database Charset'),
Value => $Row[1],
Message =>
"This character set is not yet supported, please see https://bugs.otrs.org/show_bug.cgi?id=12361. Please convert your database to the character set 'utf8'.",
);
}
elsif ( $Row[1] =~ /utf8/i ) {
$Self->AddResultOk(
Identifier => 'ServerEncoding',
Label => Translatable('Server Database Charset'),
Value => $Row[1],
);
}
else {
$Self->AddResultProblem(
Identifier => 'ServerEncoding',
Label => Translatable('Server Database Charset'),
Value => $Row[1],
Message => Translatable("The setting character_set_database needs to be 'utf8'."),
);
}
}
my @TablesWithInvalidCharset;
# Views have engine == null, ignore those.
$DBObject->Prepare( SQL => 'show table status where engine is not null' );
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[14] =~ /^utf8mb4/i || $Row[14] !~ /^utf8/i ) {
push @TablesWithInvalidCharset, $Row[0];
}
}
if (@TablesWithInvalidCharset) {
$Self->AddResultProblem(
Identifier => 'TableEncoding',
Label => Translatable('Table Charset'),
Value => join( ', ', @TablesWithInvalidCharset ),
Message => Translatable("There were tables found which do not have 'utf8' as charset."),
);
}
else {
$Self->AddResultOk(
Identifier => 'TableEncoding',
Label => Translatable('Table Charset'),
Value => '',
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,82 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::InnoDBLogFileSize;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
# Default storage engine variable has changed its name in MySQL 5.5.3, we need to support both of them for now.
# <= 5.5.2 storage_engine
# >= 5.5.3 default_storage_engine
my $DefaultStorageEngine = '';
$DBObject->Prepare( SQL => "show variables like 'storage_engine'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
$DefaultStorageEngine = $Row[1];
}
if ( !$DefaultStorageEngine ) {
$DBObject->Prepare( SQL => "show variables like 'default_storage_engine'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
$DefaultStorageEngine = $Row[1];
}
}
if ( lc $DefaultStorageEngine ne 'innodb' ) {
return $Self->GetResults();
}
$DBObject->Prepare( SQL => "show variables like 'innodb_log_file_size'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
if (
!$Row[1]
|| $Row[1] < 1024 * 1024 * 256
)
{
$Self->AddResultProblem(
Label => Translatable('InnoDB Log File Size'),
Value => $Row[1] / 1024 / 1024 . ' MB',
Message =>
Translatable("The setting innodb_log_file_size must be at least 256 MB."),
);
}
else {
$Self->AddResultOk(
Label => Translatable('InnoDB Log File Size'),
Value => $Row[1] / 1024 / 1024 . ' MB',
);
}
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,82 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::InvalidDefaultValues;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
my $DatabaseName = $Kernel::OM->Get('Kernel::Config')->Get('Database');
# Check for datetime fields with invalid default values
# (default values with a date of "0000-00-00 00:00:00").
$DBObject->Prepare(
SQL => '
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema = ?
AND DATA_TYPE = "datetime"
AND COLUMN_DEFAULT = "0000-00-00 00:00:00"
',
Bind => [ \$DatabaseName ],
);
# Collect all tables, their columns and default values like described above.
my $ErrorMessage;
while ( my @Row = $DBObject->FetchrowArray() ) {
my $Table = $Row[0];
my $Column = $Row[1];
my $Default = $Row[2];
$ErrorMessage .= "$Table ($Column) '$Default'\n";
}
if ($ErrorMessage) {
$Self->AddResultProblem(
Identifier => 'TablesWithInvalidDefaultValues',
Label => Translatable('Invalid Default Values'),
Value => $ErrorMessage,
Message => Translatable(
'Tables with invalid default values were found. In order to fix it automatically, please run: bin/otrs.Console.pl Maint::Database::Check --repair'
),
);
}
else {
$Self->AddResultOk(
Identifier => 'TablesWithInvalidDefaultValues',
Label => Translatable('Invalid Default Values'),
Value => '',
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,62 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::MaxAllowedPacket;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
$DBObject->Prepare( SQL => "show variables like 'max_allowed_packet'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
if (
!$Row[1]
|| $Row[1] < 1024 * 1024 * 64
)
{
$Self->AddResultProblem(
Label => Translatable('Maximum Query Size'),
Value => $Row[1] / 1024 / 1024 . ' MB',
Message =>
Translatable("The setting 'max_allowed_packet' must be higher than 64 MB."),
);
}
else {
$Self->AddResultOk(
Label => Translatable('Maximum Query Size'),
Value => $Row[1] / 1024 / 1024 . ' MB',
);
}
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,67 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::Performance;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
$DBObject->Prepare( SQL => "show variables like 'query_cache_size'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
if (
!$Row[1]
|| $Row[1] < 1024 * 1024 * 10
|| $Row[1] > 1024 * 1024 * 600
)
{
$Self->AddResultWarning(
Identifier => 'QueryCacheSize',
Label => Translatable('Query Cache Size'),
Value => $Row[1],
Message =>
Translatable(
"The setting 'query_cache_size' should be used (higher than 10 MB but not more than 512 MB)."
),
);
}
else {
$Self->AddResultOk(
Identifier => 'QueryCacheSize',
Label => Translatable('Query Cache Size'),
Value => $Row[1],
);
}
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,75 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::Size;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
my $DBName;
$DBObject->Prepare(
SQL => "SELECT DATABASE()",
Limit => 1,
);
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[0] ) {
$DBName = $Row[0];
}
}
$DBObject->Prepare(
SQL => "SELECT ROUND((SUM(data_length + index_length) / 1024 / 1024 / 1024),3) "
. "FROM information_schema.TABLES WHERE table_schema = ? GROUP BY table_schema",
Bind => [ \$DBName ],
Limit => 1,
);
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[0] ) {
$Self->AddResultInformation(
Label => Translatable('Database Size'),
Value => "$Row[0] GB",
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Size'),
Value => $Row[0],
Message => Translatable('Could not determine database size.')
);
}
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,88 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::StorageEngine;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
# Default storage engine variable has changed its name in MySQL 5.5.3, we need to support both of them for now.
# <= 5.5.2 storage_engine
# >= 5.5.3 default_storage_engine
my $DefaultStorageEngine;
$DBObject->Prepare( SQL => "show variables like 'storage_engine'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
$DefaultStorageEngine = $Row[1];
}
if ( !$DefaultStorageEngine ) {
$DBObject->Prepare( SQL => "show variables like 'default_storage_engine'" );
while ( my @Row = $DBObject->FetchrowArray() ) {
$DefaultStorageEngine = $Row[1];
}
}
if ($DefaultStorageEngine) {
$Self->AddResultOk(
Identifier => 'DefaultStorageEngine',
Label => Translatable('Default Storage Engine'),
Value => $DefaultStorageEngine,
);
}
$DBObject->Prepare(
SQL => "show table status where engine != ?",
Bind => [ \$DefaultStorageEngine ],
);
my @TablesWithDifferentStorageEngine;
while ( my @Row = $DBObject->FetchrowArray() ) {
push @TablesWithDifferentStorageEngine, $Row[0];
}
if (@TablesWithDifferentStorageEngine) {
$Self->AddResultProblem(
Identifier => 'TablesWithDifferentStorageEngine',
Label => Translatable('Table Storage Engine'),
Value => join( ', ', @TablesWithDifferentStorageEngine ),
Message => Translatable('Tables with a different storage engine than the default engine were found.')
);
}
else {
$Self->AddResultOk(
Identifier => 'TablesWithDifferentStorageEngine',
Label => Translatable('Table Storage Engine'),
Value => '',
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,65 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::SupportDataCollector::Plugin::Database::mysql::Version;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'mysql' ) {
return $Self->GetResults();
}
# version check
my $Version = $DBObject->Version();
if ( $Version =~ /^(MySQL|MariaDB) (\d{1,3})\.(\d{1,3}).*/ ) {
if ( $2 >= 5 ) {
$Self->AddResultOk(
Label => Translatable('Database Version'),
Value => $Version,
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Version'),
Value => $Version,
Message => Translatable("MySQL 5.x or higher is required."),
);
}
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Version'),
Value => $Version,
Message => Translatable("Could not determine database version."),
);
}
return $Self->GetResults();
}
1;