#!/usr/athena/bin/perl
# $Header: /afs/athena.mit.edu/user/s/e/seph/src/scripts/RCS/volume-quota-crypto.pl,v 1.1 2000/08/18 17:51:02 seph Exp $

# something to list quota fs style, by volume.
# basicly does a vox ex, then greps and pieces back together.


# check quotas on the crypto locker volumes

my @VOLUMES=(
    "contrib.crypto",
    "contrib.crypto.sun",
    "contrib.crypto.sgi",
    "contrib.crypto.i386",
    "contrib.crypto.other",
	     );



# print the first line of output, the key
printf "%-25s%-10s%-10s%8s\n",
    "Volume Name","     Quota", "      Used", " %Used";


foreach $volume (@VOLUMES) {
    &quota($volume);
}





sub quota {
    my $volume = shift;
    my $vos="/bin/athena/vos";

    my @vos_out = `$vos ex $volume`;
    # FIXME: deal with error conditions
    
    # figure out how much is in use (in k)
    my $used_k = (split(' ', $vos_out[0]))[3];

    # and determine the max quota (also k)
    my $max_k = (split(' ', $vos_out[3]))[1];

    # calulate the percentage used
    my $percentage = ($used_k/$max_k)*100;

    # display stuff
    printf "%-25s%10s%10s%7.0f%%\n",
    "$volume","$max_k", "$used_k", "$percentage";
}

