[700] in Info-AFS_Redistribution

home help back first fref pref prev next nref lref last post

vdu - volume disk usage (was: tapeconfig-values for a Sun-Exabyte combination?)

daemon@ATHENA.MIT.EDU (Hakan Torbjar)
Fri Apr 3 21:46:22 1992

Date: Sat, 4 Apr 92 01:27:25 GMT
From: Hakan Torbjar <torbjar@utc.chalmers.se>
To: Hakan Torbjar <torbjar@utc.chalmers.se>
Cc: info-afs@transarc.com
In-Reply-To: <9204031425.AA23327@utcrt0.utc.chalmers.se>

This is effectively a followup to my own message that reported a
possible problem with the tapeonfig-file for AFS backups.  The problem
was that the backup aborted with an end-of-tape condition.

I have a Perl script that reports the disk usage per volume name
prefix.  This night I "enhanced" it to report the disk usage for
specified volume names, to check what was expected to have been
written to the tape at the time of failure.  The tapeconfig file
specifies the tape capacity to be 1816559616 bytes and the script says
that 1874660 KB is used by the backed up volumes.  Well, I don't
question butc's decision that an end-of-tape occurred, but still
wonder what the actual tape capacity should be reduced by to get the
effective tape capacity.  85% isn't enough; is 80, 75, ...?  Each
trial and error takes about 5 hours, so if anyone knows, I (and
probably others) would appreciate an answer.

The intention of this message, however, is another, namely to present
my `vdu', volume disk usage, Perl script.  The script was created to
produce a summary of disk usage per volume name prefix.  A few new
options was invented this evening to produce summaries including
and/or excluding specific volumes.  For example, to check how much
space is used by user `foo', say `vdu -O foo', or to summarize the
space used by non-user volumes, say `vdu -I ^user'.  The script is
provided "as is"; its state is certainly experimental.  You should
initialize @inputlist to contain your file servers.  Enjoy!

-------------------- vdu Perl script follows --------------------
#!/usr/pd/perl

# vdu - volume disk usage
#
# produce a summary of disk usage for each volume name prefix
#
# Output from vos listvol looks like this:
#
#Total number of volumes on server vice2 partition /vicepa: 12
#disk.vice2.a                      680784014 RW          2 K On-line
#
#Total volumes onLine 12 ; Total volumes offLine 0 ; Total busy 0
#
# TO DO:
# Make it grok vos listvldb output

require "getopts.pl";

$[ = 1;		# first index is one, indeed.
@inputlist = (	"vice1.utc.chalmers.se",
		"vice2.utc.chalmers.se",
		"ibanez.cs.chalmers.se",
		"jorun.phc.chalmers.se",
	     );
$file = '"vos listvol -server $input -c $opt_c |"';
@vtypelist = ("RW", "BK", "RO");

if (&Getopts("fc:I:i:O:o:sdv") == 0) {
    print STDERR "Usage: $0 [-v] [-d] [-o file | -O pattern] [-i file | -I pattern]\n";
    print STDERR "\t[ -f file ... | [ -c cell ] -s server ... ]\n";
    print STDERR " -f   read volume information from file(s)\n";
    print STDERR " -s   obtain fresh volume information directly from fileserver(s)\n";
    print STDERR "      The default server list is:\n";
    foreach (@inputlist) {
	print STDERR "          $_\n";
    }
    print STDERR " -o   only consider volumes listed in file\n";
    print STDERR " -O   only consider volumes matching pattern\n";
    print STDERR " -i   ignore volumes listed in file\n";
    print STDERR " -I   ignore volumes matching pattern\n";
    print STDERR " -c   used with (and *before*) -s to specify the cell name\n";
    print STDERR " -v, -d  print little or much info about what's going on\n";
    exit(1);
}

die "Specify either -o or -O\n" if ($opt_o && $opt_O);
die "Specify either -i or -I\n" if ($opt_i && $opt_I);

if ($#ARGV) {
    if ($opt_f) {
	@inputlist = @ARGV;
	$file = '"$input"';	# eval'ed in open below
    }
    elsif ($opt_s) {
	@inputlist = @ARGV;
    }
}

if ($opt_o) {
    open(ONLY, $opt_o) || die "Couldn't open `" . $opt_o . "': $!.\n";
    while (<ONLY>) {
	split(' ');
	$only{$_[1]} = 1;
	print(STDERR "Only volume `$_[1]'\n") if $opt_d;
    }
    close(ONLY);
}
if ($opt_i) {
    open(IGNORE, $opt_i) || die "Couldn't open `" . $opt_i . "': $!.\n";
    while (<IGNORE>) {
	split(' ');
	$ignore{$_[1]} = 1;
	print(STDERR "Ignore volume `$_[1]'\n") if $opt_d;
    }
    close(IGNORE);
}

foreach $input (@inputlist) {
    print(STDERR "Input $input, file=$file.\n") if $opt_v;
    open(VLIST, eval $file) ||
			die "Couldn't open `" . eval($file) . "': $!.\n";
    while (<VLIST>) {
	chop;
	next if m/^\s*$/;
	split(' ');
	next if $opt_o && ! $only{$_[1]};
	next if $opt_O && $_[1] !~ m/$opt_O/o;
	next if $opt_i && $ignore{$_[1]};
	next if $opt_I && $_[1] =~ m/$opt_I/o;
	next if $_[1] =~ m/^Total|^$/;
	@vname = split(/\./, $_[1]);
	$prefix = $vname[1];
	if (($l = length($prefix)) > $maxprefixlen) {
	    $maxprefixlen = $l;
	}
	if ($vname[$#vname] =~ m/backup/) {
	    $vtype = "BK";
	} elsif ($vname[$#vname] =~ m/readonly/) {
	    $vtype = "RO";
	} else {
	    $vtype = "RW";
	}
	printf(STDERR "prefix=$prefix, vtype=$vtype, vname=@vname.\n") if $opt_d;
	$prefixes{$prefix}++;
	eval "\$${vtype}_sizeof{\$prefix} += \$_[4];";
	eval "\$${vtype}_nvols{\$prefix}++;";
    }
    close(VLIST);
}

#print STDERR "RW:"; foreach $e (keys %RW_nvols) {
#    print STDERR " $e";
#}; print STDERR ".\n";
#print STDERR "BK:"; foreach $e (keys %BK_nvols) {
#    print STDERR " $e";
#}; print STDERR ".\n";
#print STDERR "RO:"; foreach $e (keys %RO_nvols) {
#    print STDERR " $e";
#}; print STDERR ".\n";

exit 0 unless %prefixes;
$prefix = "Prefix";
$maxprefixlen = length $prefix if $maxprefixlen < length $prefix;
printf("%" . $maxprefixlen . "s   RW      Size   BK      Size   RO      Size\n", $prefix);
foreach $prefix (sort keys %prefixes) {	# for all collected prefixes
    printf("%" . $maxprefixlen . "s", $prefix);
    foreach $vtype (@vtypelist) {	# for all volume types (RW, BK, RO)
	printf(" %4d %9d", eval("\$${vtype}_nvols{\$prefix};"),
			   eval("\$${vtype}_sizeof{\$prefix};"));
	eval "\$${vtype}_tnvols += \$${vtype}_nvols{\$prefix};";
	eval "\$${vtype}_tsize  += \$${vtype}_sizeof{\$prefix};";
    }
    print "\n";
    $tnprefix++;
}
printf("%" . $maxprefixlen . "d", $tnprefix);
foreach $vtype (@vtypelist) {
    printf(" %4d %9d", eval("\$${vtype}_tnvols;"),
		       eval("\$${vtype}_tsize;"));
}
print "\n";
------------------------------------------------------------

--
    H}kan Torbj{r           : Dept. of Computer Engineering     : qui me amat,
    torbjar@utc.chalmers.se : Chalmers Univ. of Technology      : amat et
    (+46) 031-72 16 66      : 412 96  G\TEBORG, Sweden.         : canem meam

home help back first fref pref prev next nref lref last post