Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: faster filesystem stats

by OzzyOsbourne (Chaplain)
on Jul 12, 2001 at 19:07 UTC ( #96058=note: print w/replies, xml ) Need Help??

in reply to faster filesystem stats

I do a file::find here and run a secondary script that reads the logs and stats each file for the file size here:

use strict; my ($type, $server,$out,$in,@input,$total,$kbytes,$mbytes); my @servers=('Server'); my $dir1='//machine/share'; my @types=('swf','asf','avi','mp2','mp3','mpg','mpga','mpe','mpeg','wa +v','mov','qt','mid','midi','ra','ram','rmi','rmj','rmx','zip','exe',' +wm','wma'); foreach $type (@types){ $total=0; my $out="$dir1/sifted/$type\.txt"; my $out2="$dir1/sifted/$type-ok\.txt"; open OUT, ">$out" or die "Cannot open $out for write :$!"; foreach $server (@servers){ $in="$dir1/$server\.txt"; open IN,"$in" or next; @input=<IN>; chomp @input; foreach (@input){ if (/\.$type$/i){ $kbytes = (stat)[7]/1024; $total+=$kbytes; print OUT "$_\t$kbytes KB\n"; } } close IN; } $mbytes=$total/1024; print OUT "\n\nTotal: $mbytes MB\n"; close OUT; if ($mbytes eq 0){ rename $out, $out2; } print "Finished $type...\n"; }

The main script takes 8 hours for for 40 servers with gigs and gigs per server. The second script takes 15 minutes to run through. Defining the types of files actually speeds up the process as the stat is the part that really slows the code down ($kbytes = (stat)[7]/1024; That's the file size portion.) You could combine these into something you can use...


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://96058]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2023-10-04 19:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found