sub usage {
my ($msg) = @_;
print STDERR <<EOF;
-Usage: amdump <conf> [--no-taper] [-o configoption]* [host/disk]*
+Usage: amdump <conf> [--no-taper] [--from-client] [-o configoption]* [host/disk]*
EOF
print STDERR "$msg\n" if $msg;
exit 1;
my @config_overrides_opts;
my $opt_no_taper = 0;
+my $opt_from_client = 0;
+
+debug("Arguments: " . join(' ', @ARGV));
Getopt::Long::Configure(qw(bundling));
GetOptions(
+ 'version' => \&Amanda::Util::version_opt,
'help|usage|?' => \&usage,
'no-taper' => \$opt_no_taper,
+ 'from-client' => \$opt_from_client,
'o=s' => sub {
push @config_overrides_opts, "-o" . $_[1];
add_config_override_opt($config_overrides, $_[1]);
or die("cannot open a fake log to send an report - situation is dire");
print $fakelog <<EOF;
INFO amdump amdump pid $$
+START planner date $timestamp
START driver date $timestamp
ERROR amdump $msg
EOF
- run_subprocess("$sbindir/amreport", $config_name, '--from-amdump', '-l', $fakelogfile);
+ run_subprocess("$sbindir/amreport", $config_name, '--from-amdump', '-l', $fakelogfile, @config_overrides_opts);
unlink($fakelogfile);
# and we're done here
# logfiles are still around. First, try an amcleanup -p to see if
# the actual processes are already dead
debug("runing amcleanup -p");
- run_subprocess("$sbindir/amcleanup", '-p', $config_name);
+ run_subprocess("$sbindir/amcleanup", '-p', $config_name, @config_overrides_opts);
# and check again
return unless -f $amdump_log_filename || -f $trace_log_filename;
# undef first.. stupid perl.
debug("beginning amdump log");
$amdump_log = undef;
- open($amdump_log, ">", $amdump_log_filename)
+ # Must be opened in append so that all subprocess can write to it.
+ open($amdump_log, ">>", $amdump_log_filename)
or die("could not open amdump log file '$amdump_log_filename': $!");
}
my $planner = "$amlibexecdir/planner";
my $driver = "$amlibexecdir/driver";
my @no_taper = $opt_no_taper? ('--no-taper'):();
+ my @from_client = $opt_from_client? ('--from-client'):();
check_exec($planner);
check_exec($driver);
close($amdump_log);
exec $planner,
# note that @no_taper must follow --starttime
- $config_name, '--starttime', $timestamp, @no_taper, @config_overrides_opts, @hostdisk;
+ $config_name, '--starttime', $timestamp, @no_taper, @from_client, @config_overrides_opts, @hostdisk;
die "Could not exec $planner: $!";
}
debug(" planner: $pl_pid");
POSIX::dup2(fileno($amdump_log), 2);
close($amdump_log);
exec $driver,
- $config_name, @no_taper, @config_overrides_opts;
+ $config_name, @no_taper, @from_client, @config_overrides_opts;
die "Could not exec $driver: $!";
}
debug(" driver: $dr_pid");
sub do_amreport {
debug("running amreport");
- run_subprocess("$sbindir/amreport", $config_name, '--from-amdump');
+ run_subprocess("$sbindir/amreport", $config_name, '--from-amdump', @config_overrides_opts);
}
sub roll_trace_logs {
sub trim_trace_logs {
debug("trimming old trace logs");
- run_subprocess("$amlibexecdir/amtrmlog", $config_name);
+ run_subprocess("$amlibexecdir/amtrmlog", $config_name, @config_overrides_opts);
}
sub trim_indexes {
debug("trimming old indexes");
- run_subprocess("$amlibexecdir/amtrmidx", $config_name);
+ run_subprocess("$amlibexecdir/amtrmidx", $config_name, @config_overrides_opts);
}
sub roll_amdump_logs {
# bail out
do_amcleanup();
+my $crtl_c = 0;
+$SIG{INT} = \&interrupt;
+
+sub interrupt {
+ $crtl_c = 1;
+}
+
# start up the log file
start_logfiles();
# run the planner and driver, the one piped to the other
planner_driver_pipeline();
+if ($crtl_c == 1) {
+ print "Caught a ctrl-c\n";
+ log_add($L_FATAL, "amdump killed by ctrl-c");
+ debug("Caught a ctrl-c");
+ $exit_code = 1;
+}
+$SIG{INT} = 'DEFAULT';
+
my $end_longdate = strftime "%a %b %e %H:%M:%S %Z %Y", localtime;
amdump_log("end at $end_longdate");