From: Russ Allbery Date: Wed, 20 Oct 2010 16:34:48 +0000 (-0700) Subject: Add warning support and process counts to check_bos X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=ed296f89d1e6cfea018de70dbdc48c2659c291a7;p=packages%2Fa%2Fafs-monitor.git Add warning support and process counts to check_bos Add support for reporting warnings in check_bos and report a warning if there is inappropriate access on server directories. Patch from Steve Rader. If check_bos is successful, report the number of instances running normally. Patch from Steve Rader. --- diff --git a/NEWS b/NEWS index f5df7c4..6a32c08 100644 --- a/NEWS +++ b/NEWS @@ -17,3 +17,10 @@ afs-monitor 2.0 (unreleased) Ignore "bos: running unauthenticated" in check_bos, since bos status is always run unauthenticated. + + Add support for reporting warnings in check_bos and report a warning + if there is inappropriate access on server directories. Patch from + Steve Rader. + + If check_bos is successful, report the number of instances running + normally. Patch from Steve Rader. diff --git a/check_bos b/check_bos index f7d9c5c..70f4533 100755 --- a/check_bos +++ b/check_bos @@ -40,8 +40,8 @@ our $TIMEOUT = 10; # The list of regular expressions matching expected output. You may need to # customize this for what you're running at your site. Any output from bos -# that doesn't match one of these regular expressions will throw a critical -# error. +# that doesn't match one of these regular expressions or the warning regular +# expressions below will throw a critical error. our @OKAY = ( qr/^\s*$/, qr/^bos: running unauthenticated$/, @@ -54,6 +54,12 @@ our @OKAY = ( qr/^\s*Command \d+ is / ); +# The list of regular expressions that match output that should produce a +# warning. You may need to customize this for what you expect at your site. +our @WARNINGS = ( + qr/^\s*Bosserver reports inappropriate access on server directories/ +); + ############################################################################## # Implementation ############################################################################## @@ -110,16 +116,24 @@ if ($? != 0) { # Scan the output. If we see anything that we don't expect, immediately # report it as a fatal error. +my $count = 0; my $prev_line = ''; for my $line (@bos) { my $okay = 0; + my $warn = 0; for my $regex (@OKAY) { if ($line =~ /$regex/) { $okay = 1; last; } } - unless ($okay) { + for my $regex (@WARNINGS) { + if ($line =~ /$regex/) { + $warn = 1; + last; + } + } + unless ($okay || $warn) { $line =~ s/^\s+//; $line =~ s/\s+$//; if ($prev_line =~ /^Instance salvage,/ && $line =~ /running now/) { @@ -130,8 +144,20 @@ for my $line (@bos) { exit 2; } } + if ($warn) { + $line =~ s/^\s+//; + $line =~ s/\s+$//; + print "BOS WARNING - $line\n"; + exit 1; + } + $count++ if ($line =~ /currently running normally\.$/); + $prev_line = $line; +} +if ($count == 1) { + print "BOS OK - one process running normally\n"; +} else { + print "BOS OK - $count processes running normally\n"; } -print "BOS OK\n"; exit 0; ############################################################################## @@ -157,15 +183,16 @@ may require some customization. B will always print out a single line of output. If there is a line that isn't matched by any regexes identifying acceptable lines, it will output the first non-matching line prefixed by C. If -the salvager is running (such as when started by C, it will -print that out prefixed by C. Otherwise, it will output -B. Note that this monitoring may not catch such things as a -service being constantly restarted if it happens to be up and running -normally each time the probe runs; it doesn't pay any attention to the -last start time, the last error exit status, the presence of core files, -and the like. It mostly just looks for the "running normally" part of the -B output and makes sure the auxilliary status is also "running -normally" for a file server process. +the salvager is running (such as when started by C) or other +warnings are found, it will print that warning information prefixed by +C. Otherwise, it will output C. Note that this +monitoring may not catch such things as a service being constantly +restarted if it happens to be up and running normally each time the probe +runs; it doesn't pay any attention to the last start time, the last error +exit status, the presence of core files, and the like. It mostly just +looks for the "running normally" part of the B output and makes sure +the auxilliary status is also "running normally" for a file server +process. =head1 OPTIONS