[LON-CAPA-cvs] cvs: modules /matthew/disk_usage tally.pl

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 22 Aug 2006 21:19:03 -0000


albertel		Tue Aug 22 17:19:03 2006 EDT

  Modified files:              
    /modules/matthew/disk_usage	tally.pl 
  Log:
  - adding more summarizations
  
  
Index: modules/matthew/disk_usage/tally.pl
diff -u modules/matthew/disk_usage/tally.pl:1.1 modules/matthew/disk_usage/tally.pl:1.2
--- modules/matthew/disk_usage/tally.pl:1.1	Wed Nov  3 16:17:44 2004
+++ modules/matthew/disk_usage/tally.pl	Tue Aug 22 17:19:00 2006
@@ -2,6 +2,10 @@
 #
 use strict;
 
+my @dir_patterns = ( '/userfiles/',
+		     '/userfiles/portfolio/',
+                     );
+
 my @file_patterns = ('^activity.log$',
                      '_spreadsheets.db$',
                      '^chatroom.log$',
@@ -25,12 +29,17 @@
                      '^nohist*',
                      '^calendar.db*',
                      '.',
+                     '\.db$',
+                     '\.db\.gz$',
+		     '\.hist\.gz$',
+		     '\.(?:db|hist)\.gz$',
                      );
 
 # The results of ls -lR  /home/httpd/lonUsers/msu > /tmp/s10_files.txt
-my $inputfile = 's10_files.txt';
-#my $inputfile = 'testfiles.txt';
-my $lines = 627969;
+#my $inputfile = 's10_files.txt';
+my $inputfile = 'data_files.txt';
+my $lines = `wc -l $inputfile`;
+chomp($lines);
 
 open(IN,$inputfile) || die "Unable to open $inputfile\n";
 my %sum;
@@ -38,6 +47,7 @@
 my %class_hist;
 my %class_count;
 my $count;
+my $current_dir;
 while(<IN>) {
     if (++$count % 10000 == 0) {
         print $count.' / '.$lines.$/;
@@ -48,10 +58,11 @@
     if ($_ =~m|^/|) {
         # in a directory
         # print $_.$/;
+	$current_dir = $_;
         next;
     }
     if ($_=~/^d/ || $_=~/^total \d+$/) {
-        # skip directories and 'total ' lines.
+        # skip 'total ' lines.
         next;
     }
     my $processed = $_;
@@ -64,6 +75,12 @@
             $match++;
         }
     }
+    foreach my $pattern (@dir_patterns) {
+        if ($current_dir =~ /$pattern/) {
+            $sum{$pattern} += $size;
+            $match++;
+        }
+    }
     #
     if ($filename =~ /^msu_(.*).db$/) {
         $class_sum{$1}+= $size;
@@ -82,7 +99,7 @@
 
 print $/."    pattern                                 size".$/;
 print "------------------------------------------------".$/;
-foreach $pattern (@file_patterns) {
+foreach $pattern (@file_patterns,@dir_patterns) {
     if (! exists($sum{$pattern})) {
         $sum{$pattern}=0;
     }