[OpenAFS] script
Michael Robokoff
mrobo@ahpcrc.org
Thu, 18 Jul 2002 09:26:19 -0500
This is a multi-part message in MIME format.
--------------000006020602060802020506
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
I created a perl script that I use to monitor disk space on all my afs
servers.
I thought maybe there are others that could make use of it so I have
attached
it. Let me know if you think is was worth me submitting.
I call the script afsdf.
--Mike
--------------000006020602060802020506
Content-Type: text/plain;
name="afsdf"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="afsdf"
#! /usr/bin/perl -w
#
# This is version 2 of afsdf. released December 3, 2001
# Written by Michael Robokoff
#
# Shell commands I will call.
use Shell qw(vos);
# Servers will contain a sorted list of all the afs servers
my @servers;
# unordered_servers contains the unsorted list of servers
my @unordered_servers;
# $listpartitionsout will contain all of the output from the
# list partitions command. Then just the partition names
# will be extracted and put into @partitions.
my $listpartitionsout;
# The list of partitions on a server will be extracted from
# the server itself and put into the @partitions hash.
my @partitions;
# $used_space will cantain the number of used bytes for a particular partition.
my $used_space;
# @partinfo will contain the informaition returned by the "vos partinfo command.
my @partinfo;
# main program area
# First obtain a list of servers supporting AFS
&getservers;
print "\nGetting disk usage for the following servers....\n";
print "@servers\n\n";
foreach $server (@servers) {
# This is a temporary patch to keep from getting hung while
# waiting for a server to respond that does not exist.
if ($server eq "yourserver.your.org" || $server eq "another.server.your.org") {
print "\n--Skipping $server because it is not currently serving files.\n";
next;
}
# End of patch.
&getpartitions ($server);
print "\n$server\n\n";
printf(" %-9s %-9s %-9s %-9s %-10s\n\n", Used,Free,Total,'%Used',Partition);
foreach $partition (@partitions) {
open (IN, "vos partinfo $server $partition |");
while (<IN>)
{
@partinfo = split(/\s+/, $_);
$used_space = (($partinfo[11]) - ($partinfo[5]));
printf("%9d %9d %9d %6d %13s\n", $used_space,$partinfo[5],$partinfo[11],(($used_space/$partinfo[11])*100),$partinfo[4]);
}
}
}
print "\n\n";
# The &getservers sub routine is used to create a list of AFS servers
# that will be queried.
sub getservers {
$listaddrsout=`vos listaddrs`;
@unordered_servers=$listaddrsout=~m#(fs\S+)#g;
@servers=sort @unordered_servers;
return;
}
# The &getpartitions sub routine is used to extract the list of
# partitions that the given server is supporting.
sub getpartitions {
$listpartitionsout=`vos listpart $server`;
@partitions=$listpartitionsout=~m#(/vice\S+)#g;
return;
}
exit 0;
--------------000006020602060802020506--