WillMaster Possibillites Logo EzineSeek Award
Master DSU Calculator (disk space used)
by
Mari Bontrager

Permission is granted to reprint this article in its entirety, provided no reprints are sent in conjunction with unsolicited bulk email, provided no fee or other value is exchanged, provided no changes are made to the article, and provided the author's name, signature lines, and copyright line are printed with the article; except you may change the article's title.

Have you ever wondered how much total server disk space your internet files use?

Wonder no more! A CGI program to calculate the server disk space used by your files, and a link to a demonstration of the program, is at http://willmaster.com/a/12/pl.pl?art126

Thinking about moving to another hosting company but don't know how much server space your domain requires? No need to manually add each file size to get a total.

Master DSU Calculator can calculate the disk space used for any directory and its subdirectories, and even your entire domain, automatically. Reports are displayed in your browser as a printer-friendly web page. Each directory and subdirectory is calculated and subtotaled separately for the report. Totals for the entire scan area are displayed at the end.

And it's fast, too. Our server has over 10,000 files in 600 directories. Master DSU Calculator gathers the information and displays the report in less than 15 seconds. (Time will vary depending on server speed and current CPU load.)

The program has a place you can check to print the file name and file size of every file in its scan area.

The heart of the calculation is a subroutine in the program called "Traverse()".

When Traverse() is called, it is called with a directory name. The subroutine reads the name of every file and directory name in the directory it was called with.

  • For each file name it finds in that directory, Traverse() increments the number of files counter by 1 and adds the size of the file to the running file total.

  • For each directory name it finds in that directory, Traverse() calls Traverse() (it calls itself) with the directory name.

For those studying Perl, the source code of subroutine Traverse() is an excellent example of subroutine recursion for a live implementation.

The rest of the program is straight-forward. If you type its URL into your browser, the program gives you a form. If you use the form, the program gives you a report.

Master DSU Calculator is free.

Links to download Master DSU Calculator and a demonstration of the program are at http://willmaster.com/a/12/pl.pl?art126

No more guessing!

By: Will Bontrager

Copyright 2001 Bontrager Connection, LLC
http://willmaster.com/possibilities/
subscribe-possibilities@willmaster.com