From 74f881d79a5568e20b424c413951466f002d8934 Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Fri, 12 Dec 2003 23:32:14 +0000 Subject: [PATCH] First pass at making this look like a nagios plugin: -w,-c,-H options all added Print out full parition table if no errors found (like check_disk) --- check_afsspace | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/check_afsspace b/check_afsspace index 7b361ad..12cc65e 100755 --- a/check_afsspace +++ b/check_afsspace @@ -17,29 +17,38 @@ 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; -- 2.39.5