init III
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user