mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-17 17:27:57 +00:00
Update pt-agent to run tasks not runs.
This commit is contained in:
28
bin/pt-agent
28
bin/pt-agent
@@ -4941,16 +4941,17 @@ sub run_service {
|
|||||||
my @output_files;
|
my @output_files;
|
||||||
my $final_exit_status = 0;
|
my $final_exit_status = 0;
|
||||||
my $spool_file = "$spool_dir/" . $service->name;
|
my $spool_file = "$spool_dir/" . $service->name;
|
||||||
my $runs = $service->runs;
|
my $tasks = $service->tasks;
|
||||||
my $runno = 0;
|
my $taskno = 0;
|
||||||
foreach my $run ( @$runs ) {
|
foreach my $task ( @$tasks ) {
|
||||||
|
PTDEBUG && _d("Task $taskno:", $task->name);
|
||||||
|
|
||||||
# Set up the output file, i.e. where this run puts its results.
|
# Set up the output file, i.e. where this run puts its results.
|
||||||
# Runs can access each other's output files. E.g. run0 may
|
# Runs can access each other's output files. E.g. run0 may
|
||||||
# write to fileX, then subsequent runs can access that file
|
# write to fileX, then subsequent tasks can access that file
|
||||||
# with the special var __RUN_N_OUTPUT__ where N=0.
|
# with the special var __RUN_N_OUTPUT__ where N=0.
|
||||||
my $output_file;
|
my $output_file;
|
||||||
my $output = $run->output;
|
my $output = $task->output || '';
|
||||||
if ( $output eq 'spool' ) {
|
if ( $output eq 'spool' ) {
|
||||||
$output_file = $spool_file;
|
$output_file = $spool_file;
|
||||||
push @output_files, $spool_file;
|
push @output_files, $spool_file;
|
||||||
@@ -4962,19 +4963,18 @@ sub run_service {
|
|||||||
$output_file = $file;
|
$output_file = $file;
|
||||||
push @output_files, $file;
|
push @output_files, $file;
|
||||||
}
|
}
|
||||||
elsif ( $output eq 'none' ) {
|
else {
|
||||||
$output_file = '/dev/null';
|
$output_file = '/dev/null';
|
||||||
push @output_files, undef;
|
push @output_files, undef;
|
||||||
}
|
}
|
||||||
else {
|
PTDEBUG && _d("Task $taskno output:", Dumper(\@output_files));
|
||||||
die "Invalid output: $output\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the full command line to execute, replacing any
|
# Create the full command line to execute, replacing any
|
||||||
# special vars like __RUN_N_OUTPUT__, __TMPDIR__, etc.
|
# special vars like __RUN_N_OUTPUT__, __TMPDIR__, etc.
|
||||||
|
# TODO: handle query tasks
|
||||||
my $cmd = join(' ',
|
my $cmd = join(' ',
|
||||||
$run->program,
|
$task->program,
|
||||||
$run->options,
|
$task->options,
|
||||||
'>',
|
'>',
|
||||||
$output_file,
|
$output_file,
|
||||||
);
|
);
|
||||||
@@ -4983,15 +4983,15 @@ sub run_service {
|
|||||||
service => $service,
|
service => $service,
|
||||||
output_files => \@output_files,
|
output_files => \@output_files,
|
||||||
);
|
);
|
||||||
_info("Run $runno: $cmd");
|
_info("Task $taskno command: $cmd");
|
||||||
|
|
||||||
# Execute this run.
|
# Execute this run.
|
||||||
system($cmd);
|
system($cmd);
|
||||||
my $exit_status = $CHILD_ERROR >> 8;
|
my $exit_status = $CHILD_ERROR >> 8;
|
||||||
_info("Run $runno: exit $exit_status");
|
_info("Run $taskno: exit $exit_status");
|
||||||
|
|
||||||
$final_exit_status |= $exit_status;
|
$final_exit_status |= $exit_status;
|
||||||
$runno++;
|
$taskno++;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove temp output files.
|
# Remove temp output files.
|
||||||
|
@@ -4,13 +4,14 @@
|
|||||||
},
|
},
|
||||||
"name" : "query-monitor",
|
"name" : "query-monitor",
|
||||||
"run_schedule" : "1 * * * *",
|
"run_schedule" : "1 * * * *",
|
||||||
"runs" : [
|
"spool_schedule" : "2 * * * *",
|
||||||
|
"tasks" : [
|
||||||
{
|
{
|
||||||
|
"name" : "query-history",
|
||||||
"number" : "0",
|
"number" : "0",
|
||||||
"options" : "--report-format profile slow008.txt",
|
"options" : "--report-format profile slow008.txt",
|
||||||
"output" : "spool",
|
"output" : "spool",
|
||||||
"program" : "pt-query-digest"
|
"program" : "pt-query-digest"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"spool_schedule" : "2 * * * *"
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user