added date, time and average items per second
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 19 Aug 2005 14:57:30 +0000 (14:57 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 19 Aug 2005 14:57:30 +0000 (14:57 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@37 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_updatedb

index 2becf32..47f6975 100755 (executable)
@@ -7,11 +7,15 @@ use BackupPC::Lib;
 use BackupPC::View;
 use Data::Dumper;
 use Getopt::Std;
+use Time::HiRes qw/time/;
+use POSIX qw/strftime/;
 use constant BPC_FTYPE_DIR => 5;
 
 my $debug = 0;
 $|=1;
 
+my $t_fmt = '%Y-%m-%d %H:%M:%S';
+
 my $hosts;
 my $bpc = BackupPC::Lib->new || die;
 my %Conf = $bpc->Conf();
@@ -192,7 +196,7 @@ foreach my $host_key (keys %{$hosts}) {
                my $backupNum = $backup->{'num'};
                my @backupShares = ();
 
-               print $hosts->{$host_key}->{'host'},"\t#$backupNum\n";
+               print $hosts->{$host_key}->{'host'}, "\t#$backupNum\n";
 
                $sth->{backups_broj}->execute($hostID, $backupNum);
                my ($broj) = $sth->{backups_broj}->fetchrow_array();
@@ -201,11 +205,16 @@ foreach my $host_key (keys %{$hosts}) {
                my $files = BackupPC::View->new($bpc, $hostname, \@backups, 1);
                foreach my $share ($files->shareList($backupNum)) {
 
-                       print "\t$share";
+                       my $t = time();
+
+                       print strftime($t_fmt,localtime())," ", $share;
                        $shareID = getShareID($share, $hostID, $hostname);
                
                        my ($f, $nf, $d, $nd) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID);
-                       print " $nf/$f files $nd/$d dirs\n";
+                       printf(" %d/%d files %d/%d dirs [%.2f/s]\n",
+                               $nf, $f, $nd, $d,
+                               ( ($f+$d) / ((time() - $t) || 1) )
+                       );
                        $dbh->commit();
                }