Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
########################################### # Audit script to get a good estimate # # of total disk space used by each client # ########################################### print "\n\nEnter the path of the directory to check: (i.e. e:\\\\web, note the double-backslashes - these are necessary)\n\ +n\n"; $path=<STDIN>; #parent of the directories to get sizes of chomp($path); print "\n\nEnter the minimum in megs:\n\n\n"; $minsize=<STDIN>; #disk space usage to check against print "\n\n\n"; chomp($minsize); $minsize=$minsize*1048576; #converted to bytes $sdbpath1="m:/"; #SQL Database paths $sdbpath2="n:/"; $adbpath="d:/dbase"; #Access Database path chdir($path); @files=`dir /b`; #uses the 'bare' switch of the 'dir' command #to get a list of directories to size open (OUTFILE, ">c:/audit.txt"); print OUTFILE "Folder\t\t\tLogs (Megs)\t\tDatabases (Megs)\t\tTotal (M +egs)\n\n"; foreach $file (@files){ chomp($file); ############################################## # This loop recursively sizes one directory # # at a time from the list in @files, using # # the DOS command 'dir /s'. # # It then uses some array manipulation # # and substitution to get the total in bytes # ############################################## if (-d $file){ @temparray=`dir /s "$file"`; pop(@temparray); $tempout=pop(@temparray); $tempout =~ s/ //g; $tempout =~ s/,//g; $tempout =~ s/bytes//; $tempout =~ s/.{0,8}File\(s\)//; chdir($file); ######################################### # After changing to the client's # # directory, use 'dir /s' again # # to get the size of the logs directory # ######################################### @logarray=`dir /s Logs`; pop(@logarray); $logtemp=pop(@logarray); $logtemp =~ s/ //g; $logtemp =~ s/,//g; $logtemp =~ s/bytes//; $logtemp =~ s/.{0,8}File\(s\)//; chdir($sdbpath1); ################################### # Same story for the SQL database # # directories # ################################### if (-d $file){ @sdbarray1=`dir /s "$file"`; pop(@sdbarray1); $sdbtemp1=pop(@sdbarray1); $sdbtemp1 =~ s/ //g; $sdbtemp1 =~ s/,//g; $sdbtemp1 =~ s/bytes//; $sdbtemp1 =~ s/.{0,8}File\(s\)//; } else{ $sdbtemp1=0; } chdir($sdbpath2); if (-d $file){ @sdbarray2=`dir /s "$file"`; pop(@sdbarray2); $sdbtemp2=pop(@sdbarray2); $sdbtemp2 =~ s/ //g; $sdbtemp2 =~ s/,//g; $sdbtemp2 =~ s/bytes//; $sdbtemp2 =~ s/.{0,8}File\(s\)//; } else{ $sdbtemp2=0; } chdir($adbpath); ############################### # ...And the Access Databases # ############################### if (-d $file){ @adbarray=`dir /s "$file"`; pop(@adbarray); $adbtemp=pop(@adbarray); $adbtemp =~ s/ //g; $adbtemp =~ s/,//g; $adbtemp =~ s/bytes//; $adbtemp =~ s/.{0,8}File\(s\)//; } else{ $adbtemp=0; } $dbtemp=$sdbtemp1+$sdbtemp2+$adbtemp; #add database totals $tempout=$tempout-$logtemp; #subtract uncompressed log #size from total $logtemp=$logtemp/4; #guesstimate for compressed #log files $tempout=$tempout+$logtemp; #add compressed log size #back to total $tempout=$tempout+$dbtemp; #add database size if ($tempout > $minsize){ $logtemp=$logtemp/1048576; #convert to megabytes $tempout=$tempout/1048576; $dbtemp=$dbtemp/1048576; printf OUTFILE ("$file\t\t%.2f\t\t\t%.2f\t\t\t\t%.2f\n", $ +logtemp, $dbtemp, $tempout); } chdir($path); } } close OUTFILE;

In reply to audit.pl by Arcanum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found