mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-21 18:24:38 +00:00
Don't try https and http: use https if possible, else http. Lower timeout from 5 to 3 seconds. Start updating/fixing pt-archiver/version_check.t.
This commit is contained in:
@@ -4736,9 +4736,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -4752,7 +4754,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -4760,22 +4762,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -4787,7 +4788,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -4795,7 +4801,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -4815,13 +4821,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -4853,7 +4860,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -4890,7 +4897,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -4905,7 +4912,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -5196,7 +5203,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -4410,9 +4410,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -4426,7 +4428,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -4434,22 +4436,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -4461,7 +4462,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -4469,7 +4475,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -4489,13 +4495,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -4527,7 +4534,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -4564,7 +4571,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -4579,7 +4586,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -4870,7 +4877,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -3326,9 +3326,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -3342,7 +3344,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -3350,22 +3352,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -3377,7 +3378,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -3385,7 +3391,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -3405,13 +3411,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -3443,7 +3450,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -3480,7 +3487,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -3495,7 +3502,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -3786,7 +3793,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -4221,9 +4221,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -4237,7 +4239,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -4245,22 +4247,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -4272,7 +4273,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -4280,7 +4286,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -4300,13 +4306,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -4338,7 +4345,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -4375,7 +4382,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -4390,7 +4397,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -4681,7 +4688,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -4082,9 +4082,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -4098,7 +4100,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -4106,22 +4108,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -4133,7 +4134,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -4141,7 +4147,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -4161,13 +4167,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -4199,7 +4206,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -4236,7 +4243,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -4251,7 +4258,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -4542,7 +4549,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
54
bin/pt-find
54
bin/pt-find
@@ -2894,9 +2894,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -2910,7 +2912,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -2918,22 +2920,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -2945,7 +2946,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -2953,7 +2959,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -2973,13 +2979,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -3011,7 +3018,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -3048,7 +3055,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -3063,7 +3070,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -3354,7 +3361,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -2836,9 +2836,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -2852,7 +2854,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -2860,22 +2862,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -2887,7 +2888,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -2895,7 +2901,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -2915,13 +2921,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -2953,7 +2960,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -2990,7 +2997,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -3005,7 +3012,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -3296,7 +3303,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -4062,9 +4062,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -4078,7 +4080,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -4086,22 +4088,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -4113,7 +4114,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -4121,7 +4127,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -4141,13 +4147,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -4179,7 +4186,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -4216,7 +4223,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -4231,7 +4238,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -4522,7 +4529,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -5537,9 +5537,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -5553,7 +5555,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -5561,22 +5563,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -5588,7 +5589,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -5596,7 +5602,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -5616,13 +5622,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -5654,7 +5661,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -5691,7 +5698,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -5706,7 +5713,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -5997,7 +6004,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
54
bin/pt-kill
54
bin/pt-kill
@@ -5759,9 +5759,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -5775,7 +5777,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -5783,22 +5785,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -5810,7 +5811,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -5818,7 +5824,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -5838,13 +5844,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -5876,7 +5883,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -5913,7 +5920,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -5928,7 +5935,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -6219,7 +6226,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -7209,9 +7209,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -7225,7 +7227,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -7233,22 +7235,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -7260,7 +7261,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -7268,7 +7274,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -7288,13 +7294,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -7326,7 +7333,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -7363,7 +7370,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -7378,7 +7385,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -7669,7 +7676,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -7492,9 +7492,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -7508,7 +7510,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -7516,22 +7518,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -7543,7 +7544,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -7551,7 +7557,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -7571,13 +7577,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -7609,7 +7616,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -7646,7 +7653,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -7661,7 +7668,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -7952,7 +7959,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -13121,9 +13121,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -13137,7 +13139,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -13145,22 +13147,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -13172,7 +13173,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -13180,7 +13186,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -13200,13 +13206,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -13238,7 +13245,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -13275,7 +13282,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -13290,7 +13297,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -13581,7 +13588,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -3437,9 +3437,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -3453,7 +3455,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -3461,22 +3463,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -3488,7 +3489,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -3496,7 +3502,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -3516,13 +3522,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -3554,7 +3561,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -3591,7 +3598,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -3606,7 +3613,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -3897,7 +3904,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -4061,9 +4061,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -4077,7 +4079,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -4085,22 +4087,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -4112,7 +4113,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -4120,7 +4126,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -4140,13 +4146,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -4178,7 +4185,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -4215,7 +4222,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -4230,7 +4237,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -4521,7 +4528,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -775,9 +775,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -791,7 +793,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -799,22 +801,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -826,7 +827,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -834,7 +840,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -854,13 +860,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -892,7 +899,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -929,7 +936,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -944,7 +951,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -1235,7 +1242,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -8899,9 +8899,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -8915,7 +8917,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -8923,22 +8925,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -8950,7 +8951,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -8958,7 +8964,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -8978,13 +8984,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -9016,7 +9023,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -9053,7 +9060,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -9068,7 +9075,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -9359,7 +9366,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -11718,9 +11718,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -11734,7 +11736,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -11742,22 +11744,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -11769,7 +11770,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -11777,7 +11783,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -11797,13 +11803,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -11835,7 +11842,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -11872,7 +11879,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -11887,7 +11894,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -12178,7 +12185,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -4344,9 +4344,11 @@ sub version_check_time_limit {
|
||||
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -4360,7 +4362,7 @@ sub version_check {
|
||||
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -4368,22 +4370,21 @@ sub version_check {
|
||||
PTDEBUG && _d(scalar @$instances_to_check, 'instances to check');
|
||||
return unless @$instances_to_check;
|
||||
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -4395,7 +4396,12 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
eval {
|
||||
update_check_times(
|
||||
instances => $instances_to_check,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
@@ -4403,7 +4409,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -4423,13 +4429,14 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -4461,7 +4468,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -4498,7 +4505,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -4513,7 +4520,7 @@ sub pingback {
|
||||
my $url = $args{url};
|
||||
my $instances = $args{instances};
|
||||
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
my $response = $ua->request('GET', $url);
|
||||
PTDEBUG && _d('Server response:', Dumper($response));
|
||||
@@ -4804,7 +4811,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -96,9 +96,11 @@ sub version_check_time_limit {
|
||||
# e.g. https://stage.v.percona.com for testing.
|
||||
sub version_check {
|
||||
my (%args) = @_;
|
||||
eval {
|
||||
my $instances = $args{instances} || [];
|
||||
|
||||
my $instances = $args{instances} || [];
|
||||
my $instances_to_check;
|
||||
|
||||
eval {
|
||||
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
|
||||
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
|
||||
return;
|
||||
@@ -116,7 +118,7 @@ sub version_check {
|
||||
push @$instances, { name => 'system', id => 0 };
|
||||
|
||||
# Get the instances which haven't been checked in the 24 hours.
|
||||
my $instances_to_check = get_instances_to_check(
|
||||
$instances_to_check = get_instances_to_check(
|
||||
instances => $instances,
|
||||
vc_file => $args{vc_file}, # testing
|
||||
now => $args{now}, # testing
|
||||
@@ -127,22 +129,21 @@ sub version_check {
|
||||
# Get the list of program to check from Percona. Try using
|
||||
# https first; fallback to http if that fails (probably because
|
||||
# IO::Socket::SSL isn't installed).
|
||||
my $advice;
|
||||
PROTOCOL:
|
||||
foreach my $protocol ( qw(https http) ) {
|
||||
$advice = eval {
|
||||
pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
};
|
||||
last PROTOCOL unless $EVAL_ERROR;
|
||||
PTDEBUG && _d('--version-check error:', $EVAL_ERROR);
|
||||
my $protocol = 'https'; # optimistic, but...
|
||||
eval { require IO::Socket::SSL; };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
$protocol = 'http';
|
||||
}
|
||||
PTDEBUG && _d('Using', $protocol);
|
||||
|
||||
my $advice = pingback(
|
||||
instances => $instances_to_check,
|
||||
protocol => $protocol,
|
||||
url => $args{url} # testing
|
||||
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|
||||
|| "$protocol://v.percona.com",
|
||||
);
|
||||
if ( $advice ) {
|
||||
PTDEBUG && _d('Advice:', Dumper($advice));
|
||||
if ( scalar @$advice > 1) {
|
||||
@@ -154,7 +155,13 @@ sub version_check {
|
||||
}
|
||||
print join("\n", map { "# * $_" } @$advice), "\n\n";
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Version check failed:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
# Always update the vc file, even if the version check fails.
|
||||
eval {
|
||||
# Update the check time for things we checked. I.e. if we
|
||||
# didn't check it, do _not_ update its time.
|
||||
update_check_times(
|
||||
@@ -164,7 +171,7 @@ sub version_check {
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('--version-check failed:', $EVAL_ERROR);
|
||||
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
|
||||
}
|
||||
|
||||
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {
|
||||
@@ -184,7 +191,8 @@ sub get_instances_to_check {
|
||||
my $vc_file = $args{vc_file} || version_check_file();
|
||||
|
||||
if ( !-f $vc_file ) {
|
||||
PTDEBUG && _d($vc_file, 'does not exist; version checking all instances');
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'does not exist;',
|
||||
'version checking all instances');
|
||||
return $instances;
|
||||
}
|
||||
|
||||
@@ -194,7 +202,7 @@ sub get_instances_to_check {
|
||||
# all and check only the instances for the current tool.
|
||||
open my $fh, '<', $vc_file or die "Cannot open $vc_file: $OS_ERROR";
|
||||
chomp(my $file_contents = do { local $/ = undef; <$fh> });
|
||||
PTDEBUG && _d($vc_file, 'contents:', $file_contents);
|
||||
PTDEBUG && _d('Version check file', $vc_file, 'contents:', $file_contents);
|
||||
close $fh;
|
||||
my %last_check_time_for = $file_contents =~ /^([^,]+),(.+)$/mg;
|
||||
|
||||
@@ -228,7 +236,7 @@ sub update_check_times {
|
||||
PTDEBUG && _d('Updating last check time:', $now);
|
||||
|
||||
open my $fh, '>', $vc_file or die "Cannot write to $vc_file: $OS_ERROR";
|
||||
foreach my $instance ( sort { $a->{id} <=> $b->{id} } @$instances ) {
|
||||
foreach my $instance ( sort { $a->{id} cmp $b->{id} } @$instances ) {
|
||||
PTDEBUG && _d('Updated:', Dumper($instance));
|
||||
print { $fh } $instance->{id} . ',' . $now . "\n";
|
||||
}
|
||||
@@ -271,7 +279,7 @@ sub get_instance_id {
|
||||
}
|
||||
my $id = md5_hex($name);
|
||||
|
||||
PTDEBUG && _d('MySQL instance', $name, 'is', $id);
|
||||
PTDEBUG && _d('MySQL instance:', $id, $name, $dsn);
|
||||
|
||||
return $name, $id;
|
||||
}
|
||||
@@ -290,7 +298,7 @@ sub pingback {
|
||||
my $instances = $args{instances};
|
||||
|
||||
# Optional args
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 5 );
|
||||
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
|
||||
|
||||
# GET https://upgrade.percona.com, the server will return
|
||||
# a plaintext list of items/programs it wants the tool
|
||||
@@ -618,7 +626,6 @@ sub get_from_mysql {
|
||||
'on', $instance->{name});
|
||||
push @versions, $version;
|
||||
}
|
||||
|
||||
$version_for{ $instance->{id} } = join(' ', @versions);
|
||||
}
|
||||
|
||||
|
@@ -32,19 +32,17 @@ my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $cmd = "$trunk/bin/pt-archiver";
|
||||
my @args = qw(--dry-run --where 1=1);
|
||||
|
||||
# Pingback.pm does this too.
|
||||
my $dir = File::Spec->tmpdir();
|
||||
my $check_time_file = File::Spec->catfile($dir,'percona-toolkit-version-check');
|
||||
unlink $check_time_file if -f $check_time_file;
|
||||
my $vc_file = VersionCheck::version_check_file();
|
||||
unlink $vc_file if -f $vc_file;
|
||||
|
||||
$sb->create_dbs($master_dbh, ['test']);
|
||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||
|
||||
$output = `PTVCDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check http 2>&1`;
|
||||
$output = `PTDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check 2>&1`;
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/(?:VersionCheck|Pingback|Percona suggests)/,
|
||||
qr/VersionCheck/,
|
||||
"Looks like the version-check happened"
|
||||
) or diag($output);
|
||||
|
||||
@@ -56,23 +54,33 @@ is_deeply(
|
||||
) or diag(Dumper($rows));
|
||||
|
||||
ok(
|
||||
-f $check_time_file,
|
||||
"Created percona-toolkit-version-check file"
|
||||
-f $vc_file,
|
||||
"Created version check file"
|
||||
);
|
||||
|
||||
my $orig_vc_file = `cat $vc_file 2>/dev/null`;
|
||||
|
||||
# ###########################################################################
|
||||
# v-c file should limit checks to 1 per 24 hours
|
||||
# ###########################################################################
|
||||
|
||||
$output = `PTVCDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check http 2>&1`;
|
||||
$output = `PTDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check 2>&1`;
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/It is not time to --version-check again/,
|
||||
"Doesn't always check because of time limit"
|
||||
qr/0 instances to check/,
|
||||
"No instances to check because of time limit"
|
||||
);
|
||||
|
||||
unlink $check_time_file if -f $check_time_file;
|
||||
my $new_vc_file = `cat $vc_file 2>/dev/null`;
|
||||
|
||||
is(
|
||||
$new_vc_file,
|
||||
$orig_vc_file,
|
||||
"Version check file not changed"
|
||||
);
|
||||
|
||||
unlink $vc_file if -f $vc_file;
|
||||
|
||||
# ###########################################################################
|
||||
# Fake v.percona.com not responding by using a different, non-existent URL.
|
||||
@@ -80,17 +88,17 @@ unlink $check_time_file if -f $check_time_file;
|
||||
|
||||
my $t0 = time;
|
||||
|
||||
$output = `PTVCDEBUG=1 PERCONA_VERSION_CHECK_URL='http://x.percona.com' $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check http 2>&1`;
|
||||
$output = `PTDEBUG=1 PERCONA_VERSION_CHECK_URL='http://x.percona.com' $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check 2>&1`;
|
||||
|
||||
my $t = time - $t0;
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/Error.+?(?:GET on http:\/\/x\.percona\.com.+?HTTP status 5\d+|Failed to get any program versions; should have at least gotten Perl)/,
|
||||
qr/Error.+?(?:GET on https?:\/\/x\.percona\.com.+?HTTP status 5\d+|Failed to get any program versions; should have at least gotten Perl)/,
|
||||
"The Percona server didn't respond"
|
||||
);
|
||||
|
||||
# In actuality it should only wait 2s, but on slow boxes all the other
|
||||
# In actuality it should only wait 3s, but on slow boxes all the other
|
||||
# stuff the tool does may cause the time to be much greater than 2.
|
||||
# If nothing else, this tests that the timeout isn't something crazy
|
||||
# like 30s.
|
||||
@@ -101,40 +109,38 @@ cmp_ok(
|
||||
"Tool waited a short while for the Percona server to respond"
|
||||
);
|
||||
|
||||
unlink $vc_file if -f $vc_file;
|
||||
|
||||
# ###########################################################################
|
||||
# Disable the v-c (for now it's disabled by default, so by "disable" here
|
||||
# we just mean "don't pass --version-check").
|
||||
# Disable the v-c. It's already disabled, actually: test-env requires
|
||||
# no-version-check in /etc/percona-toolkit/percona-toolkit.conf (to keep
|
||||
# every test everywhere from version-checking).
|
||||
# ###########################################################################
|
||||
|
||||
unlink $check_time_file if -f $check_time_file;
|
||||
|
||||
$output = `PTVCDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge 2>&1`;
|
||||
$output = `PTDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge 2>&1`;
|
||||
|
||||
unlike(
|
||||
$output,
|
||||
qr/(?:VersionCheck|Pingback|Percona suggests)/,
|
||||
qr/VersionCheck/,
|
||||
"Looks like no --version-check disabled the version-check"
|
||||
) or diag($output);
|
||||
|
||||
ok(
|
||||
!-f $check_time_file,
|
||||
!-f $vc_file,
|
||||
"percona-toolkit-version-check file not created with --no-version-check"
|
||||
);
|
||||
|
||||
# PERCONA_VERSION_CHECK=0 is handled in Pingback, so it will print a line
|
||||
# for PTVCDEBUG saying why it didn't run. So we just check that it doesn't
|
||||
# create the file which also signifies that it didn't run.
|
||||
$output = `PTVCDEBUG=1 PERCONA_VERSION_CHECK=0 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check http 2>&1`;
|
||||
$output = `PTDEBUG=1 PERCONA_VERSION_CHECK=0 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --version-check 2>&1`;
|
||||
|
||||
ok(
|
||||
!-f $check_time_file,
|
||||
!-f $vc_file,
|
||||
"Looks like PERCONA_VERSION_CHECK=0 disabled the version-check"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
unlink $check_time_file if -f $check_time_file;
|
||||
unlink $vc_file if -f $vc_file;
|
||||
$sb->wipe_clean($master_dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
||||
|
Reference in New Issue
Block a user