From 85a079e724b3a8aaade45c4640cd800b7200de5c Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Thu, 11 Dec 2003 23:45:27 +0000 Subject: [PATCH 1/1] Remove reliance on pubsw perl for both use local vos for afsspace --- check_afsspace | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 check_afsspace diff --git a/check_afsspace b/check_afsspace new file mode 100755 index 0000000..7b361ad --- /dev/null +++ b/check_afsspace @@ -0,0 +1,45 @@ +#!/usr/local/bin/perl +# $Id$ +# +# Monitor disk space usage. Susan Feng (sfeng@stanford.edu) +# +# Arguments are: +# +# host [host...] +# +# This script will exit with value 1 if the partions on "host" is above 85% +# full. +# +# The first output line is a list of the hosts which failed, and +# how much space is free, in kbytes. +# + +use Getopt::Std; +use English; + +getopts ("l:"); +$LIMIT = $opt_l || 85; + +my $voscmd="/usr/local/bin/vos partinfo"; +my @failures=(); +my ($part, $used, $free, $total, $percent); + +foreach $h (@ARGV) { + @infos=(); + @infos=`$voscmd $h 2> /dev/null`; + foreach $l (@infos) { + ($part,$free,$total) = (split(/\s+/,$l))[4,5,11]; + $used=$total-$free; + $percent=int (($used/$total)*100); + if ($percent >= $LIMIT ) { + push (@failures, "$h: $part $percent% full, free $free\n"); + } + } +} + +if (@failures) { + print @failures; + exit 2; +} +print "Partitions OK\n"; +exit 0; -- 2.39.5