Merge pull request #626 from ClusterLabs/striker-data-collection-fixes

Striker data collection fixes
main
Fabio M. Di Nitto 9 months ago committed by GitHub
commit fcdfbbd486
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      man/striker-collect-debug.8
  2. 40
      tools/striker-collect-debug

@ -35,6 +35,10 @@ This restricts the data to be collected to the Striker dashboards and the specif
.TP
This can be used to specify which specific hosts data is collected from. Note that this can be used in conjuction with \fB\-\-anvil\fR to add additional hosts to collect data from, like DR hosts.
.TP
\fB\-\-with\-screenshots\fR
.TP
This collects VMs screenshots together with debug log. Disabled by default.
.TP
\fB\-\-output\-file\fR </path/to/file.tar.bz2>
.TP
This allows you to specify the output compressed tarball that the files will be saved in. By default, the output file is \fB/root/anvil-debug_<timestamp>.tar.bz2\fR. If this is a directory (ending in \fB/\fR), the normal file name is created, just in a different directory. If the path ends in a file that doesn't have the \fB.tar.bz2\fR suffix, that suffix will be added automatically. The output file will always be a bzip2's tarball.

@ -36,6 +36,7 @@ my $anvil = Anvil::Tools->new();
$anvil->Get->switches({list => [
"anvil",
"hosts",
"with-screenshots",
"output-file"], man => $THIS_FILE});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
@ -77,8 +78,7 @@ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list
"sys::compile_directory" => $anvil->data->{sys}{compile_directory},
}});
print "Data collection has begun.\n";
print "Depending on how many systems we're collecting from, this could take a while.\n";
print "Data collection has begun. This will take a while!\n\n";
# Get the directory portion of the output path and make sure it exists.
my $tarball = process_output($anvil);
@ -89,7 +89,8 @@ process_switches($anvil);
collect_data($anvil);
# Create the tarball now.
print "Data collection complete, creating the tarball now... ";
print "\nData collection complete\n";
print "- Creating the tarball now. PLEASE BE PATIENT!... ";
my $shell_call = $anvil->data->{path}{exe}{tar}." -cvjf ".$tarball." ".$anvil->data->{sys}{compile_directory};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:tarball' => $tarball,
@ -103,10 +104,22 @@ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list
}});
print "Done!\n";
print "\n[ Complete ] - The debug data is here: [".$tarball."]\n";
print "[ Warning ] - The collected logs likely include sensitive information! Share it carefully!\n";
print "- Removing temporary data dir [".$anvil->data->{sys}{compile_directory}."]... ";
$shell_call = "rm -rf ".$anvil->data->{sys}{compile_directory};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:tempdir' => $anvil->data->{sys}{compile_directory},
's2:shell_call' => $shell_call,
}});
($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
print "Done!\n";
print "\n[ Complete ] - The debug data collected here: [".$tarball."]\n";
print "[ Warning ] - The collected data and logs likely include sensitive information! Share it carefully!\n";
$anvil->nice_exit({exit_code => 0});
@ -158,6 +171,8 @@ sub process_output
if ($output_directory ne "/")
{
print "Preparing local machine\n";
if (! -d $output_directory) {
print "- Creating the output directory: [".$output_directory."]... ";
my $failed = $anvil->Storage->make_directory({directory => $output_directory});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { failed => $failed }});
@ -166,6 +181,12 @@ sub process_output
print "Failed!\nUnable to create the directory: [".$anvil->data->{sys}{compile_directory}."]. The error should be logged.\n";
$anvil->nice_exit({exit_code => 1});
}
print "Done!\n";
}
else
{
print "- Output directory [".$output_directory."] already exists.\n";
}
}
$tarball = $output_directory."/".$output_file;
@ -178,6 +199,7 @@ sub collect_data
{
my ($anvil) = @_;
print "- Creating temporary data dir [".$anvil->data->{sys}{compile_directory}."]... ";
my $failed = $anvil->Storage->make_directory({directory => $anvil->data->{sys}{compile_directory}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { failed => $failed }});
if ($failed)
@ -185,6 +207,7 @@ sub collect_data
print "Failed to create the directory: [".$anvil->data->{sys}{compile_directory}."]. The error should be logged.\n";
$anvil->nice_exit({exit_code => 1});
}
print "Done!\n";
my $hosts = @{$anvil->data->{collect_from}};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { hosts => $hosts }});
@ -675,6 +698,8 @@ sub collect_local_data
}
print "Done!\n";
if ($anvil->data->{switches}{'with-screenshots'})
{
# Grab screenshots.
print "- Collecting server screenshots... ";
if (-d $anvil->data->{path}{directories}{screenshots})
@ -704,6 +729,11 @@ sub collect_local_data
print "Failed!\nScreenshot directory: [".$anvil->data->{path}{directories}{screenshots}."] doesn't exist, skipping.\n";
}
}
else
{
print "- Screehshots collection disabled.\n";
}
}
print "- Grabbing hosts file... ";
$shell_call = $anvil->data->{path}{exe}{cp}." /etc/hosts ".$target_directory."/";

Loading…
Cancel
Save