]> git.michaelhowe.org Git - packages/a/afs-monitor.git/commitdiff
Fully working nagios style check_afsspace check
authorQuanah Gibson-Mount <quanah@stanford.edu>
Fri, 12 Dec 2003 23:47:30 +0000 (23:47 +0000)
committerQuanah Gibson-Mount <quanah@stanford.edu>
Fri, 12 Dec 2003 23:47:30 +0000 (23:47 +0000)
check_afsspace

index 12cc65e58620c1113d01ca487e7b14653ee634ce..625398868f9ae66a2d292e33256fa1250f72b16a 100755 (executable)
 use Getopt::Std;
 use English;
 
-getopts ("c:");
-getopts ("w:");
-getopts ("H:");
-$WARNING= $opt_c || 85;
-$CRITICAL= $opt_w || 90;
-$h = $opt_H;
+%options=();
+getopts ("c:w:H:", \%options);
+
+$WARNINGS = $options{w} || 85;
+$CRITICAL = $options{c} || 90;
+$h = $options{H};
+
+if ($WARNINGS > $CRITICAL) {
+  print "Warning amount cannot be greater than Critical amount.\n";
+  exit 0;
+}
  
 my $voscmd="/usr/local/bin/vos partinfo";
 my @failures=();
@@ -30,6 +35,7 @@ my ($part, $used, $free, $total, $percent);
 
 @infos=();
 @infos=`$voscmd $h 2> /dev/null`;
+
 foreach $l (@infos) {
     ($part,$free,$total) = (split(/\s+/,$l))[4,5,11];
      $used=$total-$free;
@@ -37,8 +43,8 @@ foreach $l (@infos) {
      if ($percent >= $CRITICAL) {
          push (@critical, "$h: $part $percent% full, free $free\n");
      }
-     elsif ($percent >= $WARNING) {
-         push (@warning, "$h: $part $percent% full, free $free\n");
+     elsif ($percent >= $WARNINGS) {
+         push (@warnings, "$h: $part $percent% full, free $free\n");
      }
 }