#!/usr/bin/perl -w
# Written from scratch by Michael Dosser
# Please adjust this to your amanda holding disk location
# Of course GPL'ed

$dumpdir = "/mnt/amanda/hold/";

# -- Don't change anything below, except you know what you are doing... --

$hold = "0";
print "Please give me a host search key:\nE.g.: dump.amanda.org\n\n";
$machine = <STDIN>;		# Reads the name of the machine
chop($machine);
@tage = `ls $dumpdir`;		# Gets information about the directories
foreach $tag (@tage) {
  chop(@groessefile = `cd $dumpdir$tag && du -sk *`); # cd into each directory
				# and show each file by using the du command
  foreach $groesse (@groessefile) {
    if ($groesse=~/$machine/) { # If the file corresponds the machine name given
				# from <STDIN> show it
    print "$groesse $tag";
       for ($groesse) {		# Split the du output after the first number set
       (my $zahl, my $nix1) = split (/\t/,$_);
       $hold = $hold + $zahl;	# Add each number in each cycle
       }
    }
  }
}
print "\n$machine uses \*$hold\* diskspace on the holding disk!\n\n";
