mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-24 02:01:42 +08:00
Fix --install. Support output=append:FILE.
This commit is contained in:
45
bin/pt-agent
45
bin/pt-agent
@@ -6996,6 +6996,7 @@ sub run_service {
|
|||||||
my $task_output_file = "$tmp_dir/$prefix."
|
my $task_output_file = "$tmp_dir/$prefix."
|
||||||
. $service->name
|
. $service->name
|
||||||
. ".output.$taskno";
|
. ".output.$taskno";
|
||||||
|
my $append = 0;
|
||||||
my $output_file;
|
my $output_file;
|
||||||
my $join_char;
|
my $join_char;
|
||||||
my ($store_key, $store_key_value_tuple);
|
my ($store_key, $store_key_value_tuple);
|
||||||
@@ -7031,6 +7032,10 @@ sub run_service {
|
|||||||
$store_key = $taskno;
|
$store_key = $taskno;
|
||||||
$output_file = $task_output_file;
|
$output_file = $task_output_file;
|
||||||
}
|
}
|
||||||
|
elsif ( $output =~ m/append:(\S+)/ ) {
|
||||||
|
$output_file = $1;
|
||||||
|
$append = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !$output_file ) {
|
if ( !$output_file ) {
|
||||||
$output_file = '/dev/null';
|
$output_file = '/dev/null';
|
||||||
@@ -7106,7 +7111,7 @@ sub run_service {
|
|||||||
# special vars like __RUN_N_OUTPUT__, __TMPDIR__, etc.
|
# special vars like __RUN_N_OUTPUT__, __TMPDIR__, etc.
|
||||||
my $cmd = join(' ',
|
my $cmd = join(' ',
|
||||||
$task->program,
|
$task->program,
|
||||||
'>',
|
($append ? '>>' : '>'),
|
||||||
$output_file,
|
$output_file,
|
||||||
);
|
);
|
||||||
$cmd = replace_special_vars(
|
$cmd = replace_special_vars(
|
||||||
@@ -8219,7 +8224,6 @@ sub install {
|
|||||||
$step_result = undef;
|
$step_result = undef;
|
||||||
}
|
}
|
||||||
print "$result\n" if $stepno && !$repeat;
|
print "$result\n" if $stepno && !$repeat;
|
||||||
return if $done;
|
|
||||||
while ( $skip ) {
|
while ( $skip ) {
|
||||||
printf $step_fmt,
|
printf $step_fmt,
|
||||||
$stepno + ($repeat ? 0 : 1),
|
$stepno + ($repeat ? 0 : 1),
|
||||||
@@ -8229,6 +8233,10 @@ sub install {
|
|||||||
print "SKIP\n";
|
print "SKIP\n";
|
||||||
$skip--;
|
$skip--;
|
||||||
}
|
}
|
||||||
|
if ( $done ) {
|
||||||
|
print "INSTALLATION COMPLETE\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
# This step
|
# This step
|
||||||
printf $step_fmt,
|
printf $step_fmt,
|
||||||
$stepno + ($repeat ? 0 : 1),
|
$stepno + ($repeat ? 0 : 1),
|
||||||
@@ -8257,17 +8265,9 @@ sub install {
|
|||||||
if ( !$crontab ) {
|
if ( !$crontab ) {
|
||||||
die "cron is not installed, or crontab is not in your PATH.\n";
|
die "cron is not installed, or crontab is not in your PATH.\n";
|
||||||
}
|
}
|
||||||
$next_step->();
|
|
||||||
|
|
||||||
# Must have a valid API key.
|
# Must have a valid API key.
|
||||||
my $api_key = $o->get('api-key');
|
my $api_key = $o->get('api-key');
|
||||||
my $client;
|
|
||||||
my $entry_links;
|
|
||||||
if ( $flags->{offline} ) {
|
|
||||||
$skip++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$next_step->();
|
|
||||||
if ( !$api_key ) {
|
if ( !$api_key ) {
|
||||||
print "\n";
|
print "\n";
|
||||||
if ( $interactive || -t STDIN ) {
|
if ( $interactive || -t STDIN ) {
|
||||||
@@ -8286,6 +8286,13 @@ sub install {
|
|||||||
die "Please specify your --api-key.\n";
|
die "Please specify your --api-key.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
my $client;
|
||||||
|
my $entry_links;
|
||||||
|
if ( $flags->{offline} ) {
|
||||||
|
$skip++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$next_step->();
|
||||||
eval {
|
eval {
|
||||||
($client, $entry_links) = get_api_client(
|
($client, $entry_links) = get_api_client(
|
||||||
api_key => $api_key,
|
api_key => $api_key,
|
||||||
@@ -8428,14 +8435,20 @@ sub install {
|
|||||||
# ########################################################################
|
# ########################################################################
|
||||||
$next_step->(done => 1);
|
$next_step->(done => 1);
|
||||||
|
|
||||||
if ( $flags->{offline} ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
my $hostname = `hostname`;
|
my $hostname = `hostname`;
|
||||||
chomp($hostname);
|
chomp($hostname);
|
||||||
|
|
||||||
print "\nThe agent has been installed and started, but it is not running any services yet. "
|
if ( $flags->{offline} ) {
|
||||||
. "Go to https://cloud.percona.com/agents#$hostname to enable services for this agent.\n\n";
|
print "The agent has been installed, but it was not started. "
|
||||||
|
. "Run pt-agent --daemonize to start the agent, then go to "
|
||||||
|
. "https://cloud.percona.com/agents#$hostname to enable services "
|
||||||
|
. "for the agent.\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "The agent has been installed and started, but it is not "
|
||||||
|
. "running any services yet. Go to "
|
||||||
|
. "https://cloud.percona.com/agents#$hostname to enable services"
|
||||||
|
. "for the agent.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -8451,7 +8464,7 @@ sub create_mysql_user {
|
|||||||
$cxn->dbh->do($sql);
|
$cxn->dbh->do($sql);
|
||||||
};
|
};
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die "Sorry, an error occurred while creating a MySQL user for pt-agent: "
|
die "Sorry, an error occurred while creating a MySQL user for the agent: "
|
||||||
. $EVAL_ERROR;
|
. $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
$cxn->dbh->disconnect();
|
$cxn->dbh->disconnect();
|
||||||
|
|||||||
Reference in New Issue
Block a user