mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-14 07:06:28 +00:00
Delay loading required non-core modules and let pt-agent check for them manually.
This commit is contained in:
67
bin/pt-agent
67
bin/pt-agent
@@ -764,7 +764,9 @@ sub override {
|
|||||||
{
|
{
|
||||||
package Percona::WebAPI::Representation;
|
package Percona::WebAPI::Representation;
|
||||||
|
|
||||||
|
eval {
|
||||||
use JSON;
|
use JSON;
|
||||||
|
};
|
||||||
|
|
||||||
require Exporter;
|
require Exporter;
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
@@ -841,10 +843,12 @@ use warnings FATAL => 'all';
|
|||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||||
|
|
||||||
|
eval {
|
||||||
use LWP;
|
use LWP;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
};
|
||||||
|
|
||||||
use Scalar::Util qw(blessed);
|
use Scalar::Util qw(blessed);
|
||||||
use English qw(-no_match_vars);
|
|
||||||
|
|
||||||
use Lmo;
|
use Lmo;
|
||||||
use Percona::Toolkit;
|
use Percona::Toolkit;
|
||||||
@@ -5206,7 +5210,6 @@ use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
|||||||
use Scalar::Util qw(blessed);
|
use Scalar::Util qw(blessed);
|
||||||
use POSIX qw(signal_h);
|
use POSIX qw(signal_h);
|
||||||
use Time::HiRes qw(sleep time);
|
use Time::HiRes qw(sleep time);
|
||||||
use JSON qw(decode_json);
|
|
||||||
use File::Temp qw(tempfile);
|
use File::Temp qw(tempfile);
|
||||||
use File::Path;
|
use File::Path;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
@@ -5237,6 +5240,18 @@ my $state = {};
|
|||||||
my $exit_on_signals = 0;
|
my $exit_on_signals = 0;
|
||||||
my $logger;
|
my $logger;
|
||||||
|
|
||||||
|
my %deps = (
|
||||||
|
'DBD::mysql' => [qw(DBD::mysql libdbd-mysql-perl ...)],
|
||||||
|
'JSON' => [qw(JSON libjson-perl ...)],
|
||||||
|
'LWP' => [qw(LWP libwww-perl ...)],
|
||||||
|
'IO::Socket::SSL'=> [qw(IO::Socket::SSL libio-socket-ssl ...)],
|
||||||
|
);
|
||||||
|
|
||||||
|
# Will check this later.
|
||||||
|
eval {
|
||||||
|
use JSON qw(decode_json);
|
||||||
|
};
|
||||||
|
|
||||||
sub main {
|
sub main {
|
||||||
local @ARGV = @_;
|
local @ARGV = @_;
|
||||||
|
|
||||||
@@ -5270,7 +5285,12 @@ sub main {
|
|||||||
|
|
||||||
$o->usage_or_errors();
|
$o->usage_or_errors();
|
||||||
|
|
||||||
$OUTPUT_AUTOFLUSH = 1 if $o->get('interactive');
|
$OUTPUT_AUTOFLUSH = 1 if $o->get('interactive') || $o->get('install');
|
||||||
|
|
||||||
|
if ( !$o->get('install') ) {
|
||||||
|
check_deps();
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
# Connect to MysSQL later, maybe.
|
# Connect to MysSQL later, maybe.
|
||||||
@@ -8030,8 +8050,6 @@ sub install {
|
|||||||
|
|
||||||
$logger->quiet(Percona::Agent::Logger::level_number('ERROR'));
|
$logger->quiet(Percona::Agent::Logger::level_number('ERROR'));
|
||||||
|
|
||||||
$OUTPUT_AUTOFLUSH=1;
|
|
||||||
|
|
||||||
my $agent_my_cnf = '/etc/percona/agent/my.cnf';
|
my $agent_my_cnf = '/etc/percona/agent/my.cnf';
|
||||||
my $config_file = get_config_file();
|
my $config_file = get_config_file();
|
||||||
|
|
||||||
@@ -8068,26 +8086,7 @@ sub install {
|
|||||||
|
|
||||||
# Check Perl module dependencies
|
# Check Perl module dependencies
|
||||||
$next_step->();
|
$next_step->();
|
||||||
my $deps = [
|
check_deps();
|
||||||
[qw(DBD::mysql libdbd-mysql-perl ...)],
|
|
||||||
[qw(JSON libjson-perl ...)],
|
|
||||||
[qw(LWP libwww-perl ...)],
|
|
||||||
[qw(IO::Socket::SSL libio-socket-ssl ...)],
|
|
||||||
];
|
|
||||||
my @missing_deps;
|
|
||||||
foreach my $dep ( @$deps ) {
|
|
||||||
eval "require $dep->[0]";
|
|
||||||
if ( $EVAL_ERROR ) {
|
|
||||||
push @missing_deps, $dep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( @missing_deps ) {
|
|
||||||
warn "These required Perl modules need to be installed:\n\n";
|
|
||||||
foreach my $dep ( @missing_deps ) {
|
|
||||||
warn "$dep->[0]\n apt-get install $dep->[1]\n yum install $dep->[2]\n\n";
|
|
||||||
}
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 1. Must be root for --install.
|
# 1. Must be root for --install.
|
||||||
$next_step->();
|
$next_step->();
|
||||||
@@ -8291,6 +8290,24 @@ sub pseudo_random_password {
|
|||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check_deps {
|
||||||
|
my @missing_deps;
|
||||||
|
foreach my $pm ( sort keys %deps ) {
|
||||||
|
my $dep = $deps{$pm};
|
||||||
|
eval "require $dep->[0]";
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
push @missing_deps, $dep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( @missing_deps ) {
|
||||||
|
warn "These required Perl modules need to be installed:\n\n";
|
||||||
|
foreach my $dep ( @missing_deps ) {
|
||||||
|
warn "$dep->[0]\n apt-get install $dep->[1]\n yum install $dep->[2]\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scalar @missing_deps;
|
||||||
|
}
|
||||||
|
|
||||||
# ################## #
|
# ################## #
|
||||||
# Misc and util subs #
|
# Misc and util subs #
|
||||||
# ################## #
|
# ################## #
|
||||||
|
@@ -26,10 +26,12 @@ use warnings FATAL => 'all';
|
|||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||||
|
|
||||||
|
eval {
|
||||||
use LWP;
|
use LWP;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
};
|
||||||
|
|
||||||
use Scalar::Util qw(blessed);
|
use Scalar::Util qw(blessed);
|
||||||
use English qw(-no_match_vars);
|
|
||||||
|
|
||||||
use Lmo;
|
use Lmo;
|
||||||
use Percona::Toolkit;
|
use Percona::Toolkit;
|
||||||
|
@@ -20,7 +20,9 @@
|
|||||||
{
|
{
|
||||||
package Percona::WebAPI::Representation;
|
package Percona::WebAPI::Representation;
|
||||||
|
|
||||||
|
eval {
|
||||||
use JSON;
|
use JSON;
|
||||||
|
};
|
||||||
|
|
||||||
require Exporter;
|
require Exporter;
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
|
Reference in New Issue
Block a user