From: Quanah Gibson-Mount Date: Fri, 12 Dec 2003 23:47:30 +0000 (+0000) Subject: Fully working nagios style check_afsspace check X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=1edeb66305d96f3f3e2ba8dda20589d08a2d05ce;p=packages%2Fa%2Fafs-monitor.git Fully working nagios style check_afsspace check --- diff --git a/check_afsspace b/check_afsspace index 12cc65e..6253988 100755 --- a/check_afsspace +++ b/check_afsspace @@ -17,12 +17,17 @@ 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"); } }