]> git.michaelhowe.org Git - packages/a/afs-monitor.git/commitdiff
Remove reliance on pubsw perl for both
authorQuanah Gibson-Mount <quanah@stanford.edu>
Thu, 11 Dec 2003 23:45:27 +0000 (23:45 +0000)
committerQuanah Gibson-Mount <quanah@stanford.edu>
Thu, 11 Dec 2003 23:45:27 +0000 (23:45 +0000)
use local vos for afsspace

check_afsspace [new file with mode: 0755]

diff --git a/check_afsspace b/check_afsspace
new file mode 100755 (executable)
index 0000000..7b361ad
--- /dev/null
@@ -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;