disk usage monitor

The du_tree.pl perl script was originally created in order to show a directory tree structure like the Linux program tree (that is part of most distributions, e. g. SuSE and Debian), but additional calculate and display the used size of each directory likedu -s. By now it can do much more things, you can read about it in the program help. In 2004 I created a little graphical user interface in Tcl/Tk, below you can see a screenshot of the GUI. It is a wrapper around the perl script. You can select options with that little rodent in your right or left hand and the search results will be presented in the interface. Early in 2008 I managed it to complete the I18N work (english and german).

I tested the script an a SuSE Linux 8.0 / 9.1 and a Debian 3.0 machine with the Perl versions Perl 5.6.1 / 5.8.3. du_tree is licensed under the terms of the GNU General Public License.

Some basic remarks concerning the program's functions: The script walks recursively down the directory tree (either defined by command line option or set implicit) and adds the sizes of regular files and symbolic links to the directory size. Hard links are counted only once, if the -l option is set; per default all occurences are counted. The calculated size is the size of all files found right in this directory. The summary size is calculated with consideration of all subdirectory sizes.

The -o depth sort option (sort by depth in the tree) may be confusing, if you define multiple base directories. Keep in mind that the depth is always the depth related to the base, where the directory was found in. For example, if you call:

  du_tree.pl -o depth /var/lib/apsfilter /var/adm

both /var/lib/apsfilter/bin and /var/adm/packages have a depth of 1.

There are german and english versions for the program help function (du_tree.pl -h), the graphical user interface and the GUI help available. The UTF-8 support should work properly. I checked it with the language settings de_DE.UTF-8, en_GB.UTF-8 und en_US.UTF-8.

The location of the language dependent message catalogues is unclear, because Tcl and Perl use different mechanisms to find them. For convinience (MY convinience ;-) I defined the base pathes for them relative to the program location. This results in an unpleasant side effect: If you call the programs without a path, the messages will not be found. In this case you have to change the program codes (assuming an installation path /usr/local/du_tree):

   # du_tree.pl Zeile 321
   bindtextdomain ("du_tree", "/usr/local/du_tree");
   # du_tree.tcl Zeile 27
   set cmdPath      "/usr/local/du_tree"

If you want to translate modified message catalogue sources:

  # for the perl message catalogues:
  jan@jack:~/Development/du_tree/de> msgfmt -o LC_MESSAGES/du_tree.mo du_tree.po
  # for the german tcl message catalogue:
  jan@jack:~/Development/du_tree> msgfmt --tcl msg.po -l de -d msgs

If you want to read the perldoc documentation of du_tree.pl, you can do it in different ways:

  # 1.: cd into the directory containing the perldoc
  jan@jack:~/Development/du_tree> cd en
  jan@jack:~/Development/du_tree/de> perldoc du_tree
  # 2.: set the environment variable PERLLIB to this directory and then call perldoc
  jan@jack:~/Development> PERLLIB=/home/jan/Development/du_tree/en perldoc du_tree
  # 3.: copy the documentation file to a directory, where Perl searches for docs

The handling is not perfect yet, but I hope you can live with it for a while.

A screenshot of the graphical user interface:

du_tree GUI


Because it's Perl script, an installed Perl with a version not prior to 5.60 is very useful ;-) If you want to use the "old" version (prior to 0.95) of my script, you don't need any additional modules. To use the graphical user interface you need Tcl/Tk, I tested it with version 8.4. For the version 0.95 of the perl script the gettext modules are required.

Up to version 0.94/0.22

The .tgz archive contains all program and documentation files. After downloading it you can extract it in any directory (I recommend /usr/local/bin to give all users access to the programs):

  jan@jack:~/du_tree> tar xzf du_tree.tgz
  # You will find 3 files in the directory:
  du_tree.pl   # the Perl script
  du_tree.tcl  # the GUI
  du_tree.txt  # the GUI help file

Both scripts must be executable. If you only want to use the perl script, you can delete the two other files.

version 0.95/0.23 and later

The du_tree_095.tgz archive now contains some more files (see below) - a strong hint, that I should at last build an installable package ;-)

|-- de                     # german message catalogues for du_tree.pl
|   |-- LC_MESSAGES        # text domain
|   |   `-- du_tree.mo     # the translated german messages
|   |-- du_tree            # german POD documentation
|   `-- du_tree.po         # source of the german messages
|-- du_tree.pl             # the perl script
|-- du_tree.tcl            # the tcl/tk GUI
|-- en                     # english message catalogues for du_tree.pl
|   |-- LC_MESSAGES        # text domain
|   |   `-- du_tree.mo     # the translated english messages
|   |-- du_tree            # english POD documentation
|   `-- du_tree.po         # source of the english messages
|-- msg.po                 # source of de.msg for du_tree.tcl
`-- msgs                   # message folder for du_tree.tcl
    |-- de.msg             # german translation for du_tree.tcl (english: in the tcl source file)
    |-- du_tree_de.txt     # german help file for du_tree.tcl
    `-- du_tree_en.txt     # english help file for du_tree.tcl

all versions

To see a brief description of all available command line options call:
du_tree.pl -h
The GUI provides a help function, alternatively you can read the du_tree_en.txt file in an editor of your choice.

Most of my tools are never finished ;-) Every now and then I have new ideas to make them better, more beautiful or simply different. Here's a list of things I think about for du_tree:

Date Version Content
2008-02-12 0.95/0.23 I18N (german, english)
2008-02-11 0.94/0.22 Bugfixes: The -l option's default did still not match the description. I checked it now again and fixed it.
2004-08-28 0.93/0.21 Bugfixes: The -l option's default did not match the description. The default GUI window size is changed in order to fit into a 1024x768 terminal.
2004-07-17 0.91/0.2 Added the new option -x. Using it you can limit the files to count. The option can occur as often as you need it. If it's set at least once, only files matching the expression(s) are counted. The option has no influence on the directories walked through.
The options "count files" (-c), "exlude directories" (-e) and "file search patterns" (-x) are now available in the graphical user interface. The number of directories to sacn is increased to 10 - mainly due to aesthetic reasons ;-)
2004-05-03 0.9/0.1 Stimulated by a question from Udo Neist I added some new options for du_tree.pl: The -c option displays the number of files in each directory and a summary count including the files in subdirectories. The -e option defines regular expressions to exclude directories (including their subdirectories) from the scan.
2004-02-29 0.8/0.1 I implemented a simple graphical user interface using Tcl/Tk. The du_tree.tcl script allows you to select options, checks them, creates a command line for du_tree.pl and executes it. The results are shown in a simple canvas.
2003-08-17 0.8 I modified the default script behaviour: Now only local file systems are scanned. To scan nfs mounted file systems you have to use the -n | --nfs option.
The script uses the mount command, if you want to run the script on other Unix systems, you perhaps must adjust the path and options (lines 46 and 47). I checked it only on Linux machines, it would be nice to get feedback about other systems.
Bugfix: The default output format was not "tree" as described, but "table".

A directory size larger than 4 GB will produce an error (numeric overflow), if the display unit is "Bytes".
The tcl/tk program will throw a runtime error if the [] operators are used in regular expressions. To work around it you must escape these signs:: \[Hh\]it.

du_tree.tgz (version 0.94/0.22)
du_tree_095.tgz (version 0.95/0.23)