]> git.michaelhowe.org Git - packages/a/afs-monitor.git/commitdiff
First pass at making this look like a nagios plugin:
authorQuanah Gibson-Mount <quanah@stanford.edu>
Fri, 12 Dec 2003 23:32:14 +0000 (23:32 +0000)
committerQuanah Gibson-Mount <quanah@stanford.edu>
Fri, 12 Dec 2003 23:32:14 +0000 (23:32 +0000)
-w,-c,-H options all added
Print out full parition table if no errors found (like check_disk)

check_afsspace

index 7b361ad68da17d8e7570804b99da3adfd8473cda..12cc65e58620c1113d01ca487e7b14653ee634ce 100755 (executable)
 use Getopt::Std;
 use English;
 
-getopts ("l:");
-$LIMIT = $opt_l || 85;
+getopts ("c:");
+getopts ("w:");
+getopts ("H:");
+$WARNING= $opt_c || 85;
+$CRITICAL= $opt_w || 90;
+$h = $opt_H;
  
 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");
-        }
-   }
+@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 >= $CRITICAL) {
+         push (@critical, "$h: $part $percent% full, free $free\n");
+     }
+     elsif ($percent >= $WARNING) {
+         push (@warning, "$h: $part $percent% full, free $free\n");
+     }
 }
 
-if (@failures) {
-    print @failures;
+if (@critical) {
+    print @critical;
     exit 2;
 }
-print "Partitions OK\n";
+if (@warning) {
+   print @warning;
+   exit 1;
+}
+print "@infos\n";
 exit 0;