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,64 @@
# --
# 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::OutdatedTables;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::DB',
'Kernel::System::Package',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
my %ExistingTables = map { lc($_) => 1 } $Kernel::OM->Get('Kernel::System::DB')->ListTables();
my @OutdatedTables;
# This table was removed with OTRS 6 (if empty).
if ( $ExistingTables{gi_object_lock_state} ) {
my $SolManConnectorInstalled;
for my $Package ( $Kernel::OM->Get('Kernel::System::Package')->RepositoryList() ) {
if ( $Package->{Name}->{Content} eq 'OTRSGenericInterfaceConnectorSAPSolMan' ) {
$SolManConnectorInstalled = 1;
}
}
push @OutdatedTables, 'gi_object_lock_state' if !$SolManConnectorInstalled;
}
if ( !@OutdatedTables ) {
$Self->AddResultOk(
Label => Translatable('Outdated Tables'),
Value => '',
);
}
else {
$Self->AddResultWarning(
Label => Translatable('Outdated Tables'),
Value => join( ', ', @OutdatedTables ),
Message => Translatable("Outdated tables were found in the database. These can be removed if empty."),
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,84 @@
# --
# 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::TablePresence;
use strict;
use warnings;
use parent qw(Kernel::System::SupportDataCollector::PluginBase);
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::DB',
'Kernel::System::Main',
'Kernel::System::XML',
);
sub GetDisplayPath {
return Translatable('Database');
}
sub Run {
my $Self = shift;
# table check
my $File = $Kernel::OM->Get('Kernel::Config')->Get('Home') . '/scripts/database/otrs-schema.xml';
if ( !-f $File ) {
$Self->AddResultProblem(
Label => Translatable('Table Presence'),
Value => '',
Message => Translatable("Internal Error: Could not open file."),
);
}
my $ContentRef = $Kernel::OM->Get('Kernel::System::Main')->FileRead(
Location => $File,
Mode => 'utf8',
);
if ( !ref $ContentRef && !${$ContentRef} ) {
$Self->AddResultProblem(
Label => Translatable('Table Check'),
Value => '',
Message => Translatable("Internal Error: Could not read file."),
);
}
my @XMLHash = $Kernel::OM->Get('Kernel::System::XML')->XMLParse2XMLHash( String => ${$ContentRef} );
my %ExistingTables = map { lc($_) => 1 } $Kernel::OM->Get('Kernel::System::DB')->ListTables();
my @MissingTables;
TABLE:
for my $Table ( @{ $XMLHash[1]->{database}->[1]->{Table} } ) {
next TABLE if !$Table;
if ( !$ExistingTables{ lc( $Table->{Name} ) } ) {
push( @MissingTables, $Table->{Name} );
}
}
if ( !@MissingTables ) {
$Self->AddResultOk(
Label => Translatable('Table Presence'),
Value => '',
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Table Presence'),
Value => join( ', ', @MissingTables ),
Message => Translatable("Tables found which are not present in the database."),
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,64 @@
# --
# 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::mssql::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 'mssql' ) {
return $Self->GetResults();
}
$DBObject->Prepare(
SQL => 'exec sp_spaceused',
Limit => 1,
);
while ( my @Row = $DBObject->FetchrowArray() ) {
# $Row[0] database_name
# $Row[1] database_size
# $Row[2] unallocated space
if ( $Row[1] ) {
$Self->AddResultInformation(
Label => Translatable('Database Size'),
Value => $Row[1],
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Size'),
Value => $Row[1],
Message => Translatable('Could not determine database size.')
);
}
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,56 @@
# --
# 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::mssql::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 'mssql' ) {
return $Self->GetResults();
}
# version check
my $Version = $DBObject->Version();
if ($Version) {
$Self->AddResultInformation(
Label => Translatable('Database Version'),
Value => $Version,
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Version'),
Value => $Version,
Message => Translatable("Could not determine database version."),
);
}
return $Self->GetResults();
}
1;

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;

View File

@@ -0,0 +1,100 @@
# --
# 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::oracle::NLS;
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 'oracle' ) {
return $Self->GetResults();
}
if ( $ENV{NLS_LANG} && $ENV{NLS_LANG} =~ m/al32utf-?8/i ) {
$Self->AddResultOk(
Identifier => 'NLS_LANG',
Label => Translatable('NLS_LANG Setting'),
Value => $ENV{NLS_LANG},
);
}
else {
$Self->AddResultProblem(
Identifier => 'NLS_LANG',
Label => Translatable('NLS_LANG Setting'),
Value => $ENV{NLS_LANG},
Message => Translatable('NLS_LANG must be set to al32utf8 (e.g. GERMAN_GERMANY.AL32UTF8).'),
);
}
if ( $ENV{NLS_DATE_FORMAT} && $ENV{NLS_DATE_FORMAT} eq "YYYY-MM-DD HH24:MI:SS" ) {
$Self->AddResultOk(
Identifier => 'NLS_DATE_FORMAT',
Label => Translatable('NLS_DATE_FORMAT Setting'),
Value => $ENV{NLS_DATE_FORMAT},
);
}
else {
$Self->AddResultProblem(
Identifier => 'NLS_DATE_FORMAT',
Label => Translatable('NLS_DATE_FORMAT Setting'),
Value => $ENV{NLS_DATE_FORMAT},
Message => Translatable("NLS_DATE_FORMAT must be set to 'YYYY-MM-DD HH24:MI:SS'."),
);
}
my $CreateTime;
$DBObject->Prepare(
SQL => "SELECT create_time FROM valid",
Limit => 1
);
while ( my @Row = $DBObject->FetchrowArray() ) {
$CreateTime = $Row[0];
}
if (
$CreateTime
&& $CreateTime =~ /^\d\d\d\d-(\d|\d\d)-(\d|\d\d)\s(\d|\d\d):(\d|\d\d):(\d|\d\d)/
)
{
$Self->AddResultOk(
Identifier => 'NLS_DATE_FORMAT_SELECT',
Label => Translatable('NLS_DATE_FORMAT Setting SQL Check'),
Value => $ENV{NLS_DATE_FORMAT}, # use environment variable to avoid different values
);
}
else {
$Self->AddResultProblem(
Identifier => 'NLS_DATE_FORMAT_SELECT',
Label => Translatable('NLS_DATE_FORMAT Setting SQL Check'),
Value => $CreateTime,
Message => Translatable("NLS_DATE_FORMAT must be set to 'YYYY-MM-DD HH24:MI:SS'."),
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,135 @@
# --
# 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::oracle::PrimaryKeySequencesAndTriggers;
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;
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') ne 'oracle' ) {
return $Self->GetResults();
}
# Get all table names.
my @Tables = $DBObject->ListTables();
my %SequenceNameFromTableName;
for my $TableName (@Tables) {
my $Sequence = $DBObject->{Backend}->_SequenceName(
TableName => $TableName,
);
# Convert to lower case.
$Sequence = lc $Sequence;
$SequenceNameFromTableName{$Sequence} = 1;
}
# Get all sequence names.
$DBObject->Prepare(
SQL => 'SELECT sequence_name FROM user_sequences',
);
my @SequenceNames;
while ( my @Row = $DBObject->FetchrowArray() ) {
# Convert to lower case.
push @SequenceNames, lc $Row[0];
}
my @WrongSequenceNames;
SEQUENCE:
for my $SequenceName (@SequenceNames) {
next SEQUENCE if $SequenceNameFromTableName{$SequenceName};
# Remember wrong sequence name.
push @WrongSequenceNames, $SequenceName;
}
# Get all trigger names.
$DBObject->Prepare(
SQL => 'SELECT trigger_name FROM user_triggers',
);
my @TriggerNames;
while ( my @Row = $DBObject->FetchrowArray() ) {
# Convert to lower case.
push @TriggerNames, lc $Row[0];
}
my @WrongTriggerNames;
TRIGGER:
for my $TriggerName (@TriggerNames) {
my $SequenceName = $TriggerName;
# Remove the last part of the sequence name.
$SequenceName =~ s{ _t \z }{}xms;
next TRIGGER if $SequenceNameFromTableName{$SequenceName};
# Remember wrong trigger name.
push @WrongTriggerNames, $TriggerName;
}
my $Error;
if (@WrongSequenceNames) {
$Error .= "Seqences:\n";
$Error .= join "\n", @WrongSequenceNames;
$Error .= "\n\n";
}
if (@WrongTriggerNames) {
$Error .= "Triggers:\n";
$Error .= join "\n", @WrongTriggerNames;
$Error .= "\n\n";
}
if ($Error) {
$Self->AddResultProblem(
Identifier => 'PrimaryKeySequencesAndTriggers',
Label => Translatable('Primary Key Sequences and Triggers'),
Value => $Error,
Message => Translatable(
'The following sequences and/or triggers with possible wrong names have been found. Please rename them manually.'
),
);
}
else {
$Self->AddResultOk(
Identifier => 'PrimaryKeySequencesAndTriggers',
Label => Translatable('Primary Key Sequences and Triggers'),
Value => '',
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,56 @@
# --
# 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::oracle::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 'oracle' ) {
return $Self->GetResults();
}
# version check
my $Version = $DBObject->Version();
if ($Version) {
$Self->AddResultInformation(
Label => Translatable('Database Version'),
Value => $Version,
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Version'),
Value => $Version,
Message => Translatable("Could not determine database version."),
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,77 @@
# --
# 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::postgresql::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') !~ m{^postgresql} ) {
return $Self->GetResults();
}
$DBObject->Prepare( SQL => 'show client_encoding' );
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[0] =~ /(UNICODE|utf-?8)/i ) {
$Self->AddResultOk(
Identifier => 'ClientEncoding',
Label => Translatable('Client Connection Charset'),
Value => $Row[0],
);
}
else {
$Self->AddResultProblem(
Identifier => 'ClientEncoding',
Label => Translatable('Client Connection Charset'),
Value => $Row[0],
Message => Translatable('Setting client_encoding needs to be UNICODE or UTF8.'),
);
}
}
$DBObject->Prepare( SQL => 'show server_encoding' );
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[0] =~ /(UNICODE|utf-?8)/i ) {
$Self->AddResultOk(
Identifier => 'ServerEncoding',
Label => Translatable('Server Database Charset'),
Value => $Row[0],
);
}
else {
$Self->AddResultProblem(
Identifier => 'ServerEncoding',
Label => Translatable('Server Database Charset'),
Value => $Row[0],
Message => Translatable('Setting server_encoding needs to be UNICODE or UTF8.'),
);
}
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,56 @@
# --
# 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::postgresql::DateStyle;
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') !~ m{^postgresql} ) {
return $Self->GetResults();
}
$DBObject->Prepare( SQL => 'show DateStyle' );
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[0] =~ /^ISO/i ) {
$Self->AddResultOk(
Label => Translatable('Date Format'),
Value => $Row[0],
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Date Format'),
Value => $Row[0],
Message => Translatable('Setting DateStyle needs to be ISO.'),
);
}
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,101 @@
# --
# 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::postgresql::PrimaryKeySequences;
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;
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
if ( $DBObject->GetDatabaseFunction('Type') !~ m{^postgresql} ) {
return $Self->GetResults();
}
# Get all table names.
my @Tables = $DBObject->ListTables();
my %SequenceNameFromTableName;
for my $TableName (@Tables) {
my $Sequence = $DBObject->{Backend}->_SequenceName(
TableName => $TableName,
);
# Special handling for a table with no id column but with a object_id column.
if ( $TableName eq 'dynamic_field_obj_id_name' ) {
$Sequence = 'dynamic_field_obj_id_name_object_id_seq';
}
# Convert to lower case.
$Sequence = lc $Sequence;
$SequenceNameFromTableName{$Sequence} = 1;
}
# Get all sequence names.
$DBObject->Prepare(
SQL => "SELECT relname FROM pg_class WHERE relkind = 'S'",
);
my @SequenceNames;
while ( my @Row = $DBObject->FetchrowArray() ) {
push @SequenceNames, lc $Row[0];
}
my @WrongSequenceNames;
SEQUENCE:
for my $SequenceName (@SequenceNames) {
next SEQUENCE if $SequenceNameFromTableName{$SequenceName};
# Remember wrong sequence name.
push @WrongSequenceNames, $SequenceName;
}
if (@WrongSequenceNames) {
my $Error = join "\n", @WrongSequenceNames;
$Error .= "\n";
$Self->AddResultProblem(
Identifier => 'PrimaryKeySequences',
Label => Translatable('Primary Key Sequences'),
Value => $Error,
Message => Translatable(
'The following sequences with possible wrong names have been found. Please rename them manually.'
),
);
}
else {
$Self->AddResultOk(
Identifier => 'PrimaryKeySequences',
Label => Translatable('Primary Key Sequences'),
Value => '',
);
}
return $Self->GetResults();
}
1;

View File

@@ -0,0 +1,61 @@
# --
# 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::postgresql::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') !~ m{^postgresql} ) {
return $Self->GetResults();
}
# version check
$DBObject->Prepare(
SQL => "SELECT pg_size_pretty(pg_database_size(current_database()))",
LIMIT => 1,
);
while ( my @Row = $DBObject->FetchrowArray() ) {
if ( $Row[0] ) {
$Self->AddResultInformation(
Label => Translatable('Database Size'),
Value => $Row[0],
);
}
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,64 @@
# --
# 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::postgresql::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') !~ m{^postgresql} ) {
return $Self->GetResults();
}
my $Version = $DBObject->Version();
my ( $VersionMajor, $VersionMinor ) = $Version =~ m/^PostgreSQL \s+ (\d{1,3}) \. (\d{1,3})/ismx;
if ($VersionMajor) {
if ( sprintf( '%03d%03d', $VersionMajor, $VersionMinor ) >= 9_002 ) {
$Self->AddResultOk(
Label => Translatable('Database Version'),
Value => $Version,
);
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Version'),
Value => $Version,
Message => Translatable('PostgreSQL 9.2 or higher is required.')
);
}
}
else {
$Self->AddResultProblem(
Label => Translatable('Database Version'),
Value => $Version,
Message => Translatable('Could not determine database version.')
);
}
return $Self->GetResults();
}
1;