The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/local/bin/perl

use blib;
use strict;
use warnings;

use AFS::VOS;

my ($vos, $server, $part, $Debugging);

$Debugging = 0;
if ($ARGV[0] eq '-d') { $Debugging = 1; shift; }
die "Usage: $0 server [partition]\n" if $#ARGV < 0;

$server = shift;
$part   = shift;

$part = '' unless $part;

$vos = AFS::VOS->new;
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n";

my $partinfo = $vos->partinfo($server, $part);
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n";

$Debugging && print_debug($partinfo) && exit;

foreach my $part (keys %$partinfo) {
    print "Free space on partition $part: ";
    print "$partinfo->{$part}->{free} K blocks out of total $partinfo->{$part}->{minFree}\n";
}


sub print_debug {
    my $partinfo = shift;

    foreach my $key1 (sort keys %{$partinfo}) {
        foreach my $key2 (sort keys %{$partinfo->{$key1}}) {
            printf("%10s  %10s  %s\n", $key1, $key2, $partinfo->{$key1}->{$key2});
        }
    }
    print "\n\n";
}