+use Amanda::Config;
+use Amanda::Debug;
+
+sub get_current_log_timestamp
+{
+ my $logfile = Amanda::Config::config_dir_relative(
+ Amanda::Config::getconf($Amanda::Config::CNF_LOGDIR)) . "/log";
+ if (! -f $logfile) {
+ Amanda::Debug::warning("no current logfile '$logfile'");
+ return undef;
+ }
+
+ my $logh = open_logfile("$logfile");
+ if (!$logh) {
+ Amanda::Debug::warning("could not open logfile '$logfile'");
+ return undef;
+ }
+ while (my ($type, $prog, $str) = get_logline($logh)) {
+ if ($type == $L_START) {
+ my ($ts) = ($str =~ /date (\d+)/);
+ return $ts if $ts;
+ }
+ }
+
+ # no timestamp, apparently
+ Amanda::Debug::warning("no current timestamp found in logfile");
+ return undef;
+}
+
+sub make_stats {
+ my ($size, $duration, $orig_kb) = @_;
+
+ $duration = 0.1 if $duration <= 0; # prevent division by zero
+ my $kb = $size/1024;
+ my $kps = "$kb.0"/$duration; # Perlish cast from BigInt to float
+
+ if (defined $orig_kb) {
+ return sprintf("[sec %f kb %d kps %f orig-kb %d]", $duration, $kb, $kps, $orig_kb);
+ } else {
+ return sprintf("[sec %f kb %d kps %f]", $duration, $kb, $kps);
+ }
+}
+