]> git.michaelhowe.org Git - packages/a/afs-monitor.git/commitdiff
Update coding style, version method, documentation
authorRuss Allbery <rra@stanford.edu>
Fri, 15 Oct 2010 20:21:05 +0000 (13:21 -0700)
committerRuss Allbery <rra@stanford.edu>
Fri, 15 Oct 2010 20:21:05 +0000 (13:21 -0700)
Update the coding style in a few places where my Perl style has changed
and clean up the scripts a bit.  Switch the versioning system from the
CVS $Id$ tags to a variable that will be replaced during make dist (not
yet in place).  Proofread the documentation and update it as necessary.
Refer to the new afs-monitor distribution, which these scripts will now
be part of.

check_afsspace
check_bos
check_rxdebug
check_udebug

index 0e9fbcebcdb6a491ac1eae929f5f1dca8b353076..60d82e99b2cec67e4ef9b37fc8ab7bce79bd37b9 100755 (executable)
@@ -1,17 +1,17 @@
 #!/usr/bin/perl -w
-# $ID = q$Id$;
+our $VERSION = '@VERSION@ @DATE@';
 #
 # check_afsspace -- Monitor AFS disk space usage under Nagios.
 #
 # Written by Susan Feng <sfeng@stanford.edu>
 # Updated by Russ Allbery <rra@stanford.edu>
-# Copyright 2003, 2004 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr. University
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the same terms as Perl itself.
 #
-# Expects a host with the -H option and checks the partition usage with
-# vos partinfo.  Exits with status 1 if the free space is below a warning
+# Expects a host with the -H option and checks the partition usage with vos
+# partinfo.  Exits with status 1 if the free space is below a warning
 # percentage and with status 2 if the free space is above a critical
 # percentage (this works with the Nagios check architecture).
 
 # Modules and declarations
 ##############################################################################
 
-require 5.003;
+require 5.006;
 
 use strict;
-use vars qw($CRITICAL $ID $TIMEOUT $VOS $WARNINGS);
 
 use Getopt::Long qw(GetOptions);
+
 ##############################################################################
 # Site configuration
 ##############################################################################
 
 # The default percentage full at which to warn and at which to send a critical
 # alert.  These can be overridden with the -w and -c command-line options.
-$WARNINGS = 85;
-$CRITICAL = 90;
+our $WARNINGS = 85;
+our $CRITICAL = 90;
 
 # The default timeout in seconds (implemented by alarm) for vos partinfo.
-$TIMEOUT = 300;
+our $TIMEOUT = 300;
 
 # The full path to vos.  Make sure that this is on local disk so that
 # monitoring doesn't have an AFS dependency.
-($VOS) = grep { -x $_ } qw(/usr/bin/vos /usr/local/bin/vos);
+our ($VOS) = grep { -x $_ } qw(/usr/bin/vos /usr/local/bin/vos);
 $VOS ||= '/usr/bin/vos';
 
-
 ##############################################################################
 # Implementation
 ##############################################################################
@@ -50,21 +49,19 @@ $VOS ||= '/usr/bin/vos';
 # Parse command line options.
 my ($help, $host, $version);
 Getopt::Long::config ('bundling', 'no_ignore_case');
-GetOptions ('critical|c=i' => \$CRITICAL,
-            'hostname|H=s' => \$host,
-            'help|h'       => \$help,
-            'timeout|t=i'  => \$TIMEOUT,
-            'version|V'    => \$version,
-            'warning|w=i'  => \$WARNINGS) or exit 3;
+GetOptions ('c|critical=i' => \$CRITICAL,
+            'H|hostname=s' => \$host,
+            'h|help'       => \$help,
+            't|timeout=i'  => \$TIMEOUT,
+            'V|version'    => \$version,
+            'w|warning=i'  => \$WARNINGS) or exit 3;
 if ($help) {
     print "Feeding myself to perldoc, please wait....\n";
     exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
 } elsif ($version) {
-    my $version = join (' ', (split (' ', $ID))[1..3]);
-    $version =~ s/,v\b//;
+    my $version = $VERSION;
     $version =~ s/(\S+)$/($1)/;
-    $version =~ tr%/%-%;
-    print $version, "\n";
+    print "check_afsspace $version\n";
     exit 0;
 }
 if (@ARGV) {
@@ -125,21 +122,26 @@ check_afsspace - Monitor AFS disk space usage under Nagios
 
 =head1 SYNOPSIS
 
-check_afsspace [B<-hV>] [B<-c> I<threshold>] [B<-w> I<threshold>]
-[B<-t> I<timeout>] B<-H> I<host>
+B<check_afsspace> [B<-hV>] [B<-c> I<threshold>] [B<-w> I<threshold>]
+    [B<-t> I<timeout>] B<-H> I<host>
 
 =head1 DESCRIPTION
 
 B<check_afsspace> is a Nagios plugin for checking free space on AFS server
 partitions.  It uses C<vos partinfo> to obtain the free space on the
 partitions on an AFS server and will return an alert if the percentage of
-used space exceeds a threshold.  By default, it returns a critical error if
-the used space is over 90% and a warning if it is over 85% (changable with
-the B<-c> and B<-w> options).
+used space exceeds a threshold.  By default, it returns a critical error
+if the used space is over 90% and a warning if it is over 85% (changaable
+with the B<-c> and B<-w> options).
+
+If C<vos partinfo> doesn't return within the timeout, B<check_afsspace>
+will return a critical error.  The default timeout is 300 seconds,
+changeable with the B<-t> option.
 
-B<check_afsspace> will always print out a single line of output, giving the
-critical errors if any, otherwise giving the warnings if any, otherwise
-listing in an abbreviated form the percentage free space for all partitions.
+B<check_afsspace> will always print out a single line of output, giving
+the critical errors if any, otherwise giving the warnings if any,
+otherwise listing in an abbreviated form the percentage free space for all
+partitions.
 
 =head1 OPTIONS
 
@@ -147,8 +149,8 @@ listing in an abbreviated form the percentage free space for all partitions.
 
 =item B<-c> I<threshold>, B<--critical>=I<threshold>
 
-Change the critical percentage threshold to I<threshold>, which should be an
-integer percentage.  The default is 90.
+Change the critical percentage threshold to I<threshold>, which should be
+an integer percentage.  The default is 90.
 
 =item B<-H> I<host>, B<--hostname>=I<host>
 
@@ -162,8 +164,8 @@ to C<perldoc -t>).
 
 =item B<-t> I<timeout>, B<--timeout>=I<timeout>
 
-Change the timeout for the C<vos partinfo> command.  The default timeout is
-10 seconds.
+Change the timeout for the C<vos partinfo> command.  The default timeout
+is 300 seconds.
 
 =item B<-V>, B<--version>
 
@@ -171,8 +173,8 @@ Print out the version of B<check_afsspace> and quit.
 
 =item B<-w> I<threshold>, B<--warning>=I<threshold>
 
-Change the warning percentage threshold to I<threshold>, which should be an
-integer percentage.  The default is 85.
+Change the warning percentage threshold to I<threshold>, which should be
+an integer percentage.  The default is 85.
 
 =back
 
@@ -182,32 +184,33 @@ B<check_afsspace> follows the standard Nagios exit status requirements.
 This means that it will exit with status 0 if there are no problems, with
 status 2 if there is at least one critical partition for that server, and
 with status 1 if there are no critical partitions but at least one warning
-partition.  For other errors, such as invalid syntax, B<check_afsspace> will
-exit with status 3.
+partition.  For other errors, such as invalid syntax, B<check_afsspace>
+will exit with status 3.
 
 =head1 BUGS
 
-The standard B<-v> verbose Nagios plugin option is not supported and should
-be.  (For example, under B<-vv> we would want to show the actual total,
-free, and used byte counts, not just the percentages.)
+The standard B<-v> verbose Nagios plugin option is not supported and
+should be.  (For example, under B<-vv> we would want to show the actual
+total, free, and used byte counts, not just the percentages.)
 
 The usage message for invalid options and for the B<-h> option doesn't
 conform to Nagios standards.
 
 =head1 CAVEATS
 
-This script does not use the Nagios util library or any of the defaults that
-it provides, which makes it somewhat deficient as a Nagios plugin.  This is
-intentional, though, since this script can be used with other monitoring
-systems as well.  It's not clear what a good solution to this would be.
+This script does not use the Nagios util library or any of the defaults
+that it provides, which makes it somewhat deficient as a Nagios plugin.
+This is intentional, though, since this script can be used with other
+monitoring systems as well.  It's not clear what a good solution to this
+would be.
 
 =head1 SEE ALSO
 
 vos(1)
 
-The current version of this and other AFS monitoring plugins for Nagios are
-available from the AFS monitoring tools page at
-L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
+This script is part of the afs-monitor package, which includes various AFS
+monitoring plugins for Nagios.  It is available from the AFS monitoring
+tools page at L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
 
 =head1 AUTHORS
 
@@ -218,7 +221,8 @@ uniform coding style.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2003, 2004 Board of Trustees, Leland Stanford Jr. University.
+Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr.
+University.
 
 This program is free software; you may redistribute it and/or modify it
 under the same terms as Perl itself.
index 428cd1b4dd7b38b5c893214da4bf121ec8f96b1f..6098e18a7823a95852dc30c3431c3dd47337ee88 100755 (executable)
--- a/check_bos
+++ b/check_bos
@@ -1,11 +1,11 @@
 #!/usr/bin/perl -w
-# $ID = q$Id$;
+our $VERSION = '@VERSION@ @DATE@';
 #
 # check_bos -- Monitor AFS bos output for problems in Nagios.
 #
 # Written by Russ Allbery <rra@stanford.edu>
 # Based on an earlier script by Neil Crellin <neilc@stanford.edu>
-# Copyright 2003, 2004 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr. University
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the same terms as Perl itself.
 # Modules and declarations
 ##############################################################################
 
-require 5.005;
+require 5.006;
 
 use strict;
-use vars qw($BOS $ID @OKAY $TIMEOUT);
 
 use Getopt::Long qw(GetOptions);
+
 ##############################################################################
 # Site configuration
 ##############################################################################
 
 # The full path to bos.  Make sure that this is on local disk so that
 # monitoring doesn't have an AFS dependency.
-($BOS) = grep { -x $_ } qw(/usr/bin/bos /usr/local/bin/bos);
+our ($BOS) = grep { -x $_ } qw(/usr/bin/bos /usr/local/bin/bos);
 $BOS ||= '/usr/bin/bos';
 
 # The default timeout in seconds (implemented by alarm) for rxdebug.
-$TIMEOUT = 10;
+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.
-@OKAY = (
+our @OKAY = (
     qr/^\s*$/,
     qr/^Instance\ \S+,\ \(type\ is\ \S+\)(\ has\ core\ file,)?
          \ currently\ running\ normally\.$/x,
@@ -53,7 +53,6 @@ $TIMEOUT = 10;
     qr/^\s*Command \d+ is /
 );
 
-
 ##############################################################################
 # Implementation
 ##############################################################################
@@ -61,19 +60,17 @@ $TIMEOUT = 10;
 # Parse command line options.
 my ($help, $host, $version);
 Getopt::Long::config ('bundling', 'no_ignore_case');
-GetOptions ('hostname|H=s' => \$host,
-            'help|h'       => \$help,
-            'timeout|t=i'  => \$TIMEOUT,
-            'version|V'    => \$version) or exit 3;
+GetOptions ('H|hostname=s' => \$host,
+            'h|help'       => \$help,
+            't|timeout=i'  => \$TIMEOUT,
+            'V|version'    => \$version) or exit 3;
 if ($help) {
     print "Feeding myself to perldoc, please wait....\n";
     exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
 } elsif ($version) {
-    my $version = join (' ', (split (' ', $ID))[1..3]);
-    $version =~ s/,v\b//;
+    my $version = $VERSION;
     $version =~ s/(\S+)$/($1)/;
-    $version =~ tr%/%-%;
-    print $version, "\n";
+    print "check_bos $version\n";
     exit 0;
 }
 if (@ARGV) {
@@ -134,7 +131,7 @@ check_bos - Monitor AFS bos output for problems in Nagios
 
 =head1 SYNOPSIS
 
-check_bos [B<-hV>] [B<-t> I<timeout>] B<-H> I<host>
+B<check_bos> [B<-hV>] [B<-t> I<timeout>] B<-H> I<host>
 
 =head1 DESCRIPTION
 
@@ -145,15 +142,15 @@ top of this script; they should be generally suitable for most sites, but
 may require some customization.
 
 B<check_bos> 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<BOS CRITICAL>.  Otherwise,
-it will output B<BOS OK>.  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<bos> output and makes sure the auxilliary status is also "running
-normally" for a file server process.
+line that isn't matched by any regexes identifying acceptable lines, it
+will output the first non-matching line prefixed by C<BOS CRITICAL>.
+Otherwise, it will output B<BOS OK>.  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<bos> output and makes sure the auxilliary status
+is also "running normally" for a file server process.
 
 =head1 OPTIONS
 
@@ -184,29 +181,30 @@ Print out the version of B<check_bos> and quit.
 
 B<check_bos> follows the standard Nagios exit status requirements.  This
 means that it will exit with status 0 if there are no problems or with
-status 2 if there is a problem detected.  For other errors, such as invalid
-syntax, B<check_bos> will exit with status 3.
+status 2 if there is a problem detected.  For other errors, such as
+invalid syntax, B<check_bos> will exit with status 3.
 
 =head1 BUGS
 
-The standard B<-v> verbose Nagios plugin option is not supported.  It should
-display the complete bos status output.
+The standard B<-v> verbose Nagios plugin option is not supported.  It
+should display the complete bos status output.
 
 The usage message for invalid options and for the B<-h> option doesn't
 conform to Nagios standards.
 
 =head1 CAVEATS
 
-This script does not use the Nagios util library or any of the defaults that
-it provides, which makes it somewhat deficient as a Nagios plugin.  This is
-intentional, though, since this script can be used with other monitoring
-systems as well.  It's not clear what a good solution to this would be.
+This script does not use the Nagios util library or any of the defaults
+that it provides, which makes it somewhat deficient as a Nagios plugin.
+This is intentional, though, since this script can be used with other
+monitoring systems as well.  It's not clear what a good solution to this
+would be.
 
 =head1 SEE ALSO
 
-The current version of this and other AFS monitoring plugins for Nagios are
-available from the AFS monitoring tools page at
-L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
+This script is part of the afs-monitor package, which includes various AFS
+monitoring plugins for Nagios.  It is available from the AFS monitoring
+tools page at L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
 
 =head1 AUTHORS
 
@@ -217,7 +215,8 @@ output, instead just scanning it for acceptable lines.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2003, 2004 Board of Trustees, Leland Stanford Jr. University.
+Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr.
+University.
 
 This program is free software; you may redistribute it and/or modify it
 under the same terms as Perl itself.
index d09b4b2e0093426b3013b250d5e924bf532102ac..295ac3256f663ebcee65f2c953194951acb30646 100755 (executable)
@@ -1,11 +1,12 @@
 #!/usr/bin/perl -w
-# $ID = q$Id$;
+our $VERSION = '@VERSION@ @DATE@';
 #
 # check_rxdebug -- Nagios AFS server check for waiting connections.
 #
 # Written by Quanah Gibson-Mount based on work by Neil Crellin
 # Updated by Russ Allbery <rra@stanford.edu>
-# Copyright 2003, 2004, 2005 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2003, 2004, 2005, 2010
+#     Board of Trustees, Leland Stanford Jr. University
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the same terms as Perl itself.
 # Modules and declarations
 ##############################################################################
 
-require 5.003;
+require 5.006;
 
 use strict;
-use vars qw($CRITICAL $ID $RXDEBUG $TIMEOUT $WARNINGS);
 
 use Getopt::Long qw(GetOptions);
+
 ##############################################################################
 # Site configuration
 ##############################################################################
 
 # The default count of blocked connections at which to warn or send a critical
 # alert.  These can be overridden with the -w and -c command-line options.
-$WARNINGS = 2;
-$CRITICAL = 8;
+our $WARNINGS = 2;
+our $CRITICAL = 8;
 
 # The default timeout in seconds (implemented by alarm) for rxdebug.
-$TIMEOUT = 60;
+our $TIMEOUT = 60;
 
 # The full path to rxdebug.  Make sure that this is on local disk so that
 # monitoring doesn't have an AFS dependency.
-($RXDEBUG) = grep { -x $_ } qw(/usr/bin/rxdebug /usr/local/bin/rxdebug);
+our ($RXDEBUG) = grep { -x $_ } qw(/usr/bin/rxdebug /usr/local/bin/rxdebug);
 $RXDEBUG ||= '/usr/bin/rxdebug';
 
-
 ##############################################################################
 # Implementation
 ##############################################################################
@@ -51,21 +51,19 @@ $RXDEBUG ||= '/usr/bin/rxdebug';
 # Parse command line options.
 my ($help, $host, $version);
 Getopt::Long::config ('bundling', 'no_ignore_case');
-GetOptions ('critical|c=i' => \$CRITICAL,
-            'hostname|H=s' => \$host,
-            'help|h'       => \$help,
-            'timeout|t=i'  => \$TIMEOUT,
-            'version|V'    => \$version,
-            'warning|w=i'  => \$WARNINGS) or exit 3;
+GetOptions ('c|critical=i' => \$CRITICAL,
+            'H|hostname=s' => \$host,
+            'h|help'       => \$help,
+            't|timeout=i'  => \$TIMEOUT,
+            'V|version'    => \$version,
+            'w|warning=i'  => \$WARNINGS) or exit 3;
 if ($help) {
     print "Feeding myself to perldoc, please wait....\n";
     exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
 } elsif ($version) {
-    my $version = join (' ', (split (' ', $ID))[1..3]);
-    $version =~ s/,v\b//;
+    my $version = $VERSION;
     $version =~ s/(\S+)$/($1)/;
-    $version =~ tr%/%-%;
-    print $version, "\n";
+    print "check_bos $version\n";
     exit 0;
 }
 if (@ARGV) {
@@ -84,8 +82,8 @@ $SIG{ALRM} = sub {
 };
 alarm ($TIMEOUT);
 
-# Run rxdebug and parse the output, counting the number of waiting for process
-# connections that we have.
+# Run rxdebug and parse the output to find the number of calls waiting for a
+# thread.
 unless (open (RXDEBUG, "$RXDEBUG $host -noconn |")) {
     warn "$0: cannot run rxdebug\n";
     exit 3;
@@ -129,21 +127,21 @@ check_rxdebug - Check AFS servers for blocked connections in Nagios
 
 =head1 SYNOPSIS
 
-check_rxdebug [B<-hV>] [B<-c> I<threshold>] [B<-w> I<threshold>]
-[B<-t> I<timeout>] B<-H> I<host>
+B<check_rxdebug> [B<-hV>] [B<-c> I<threshold>] [B<-w> I<threshold>]
+    [B<-t> I<timeout>] B<-H> I<host>
 
 =head1 DESCRIPTION
 
-B<check_rxdebug> is a Nagios plugin for checking AFS file servers to see if
-there are client connections waiting for a free thread.  If there are more
-than a few of these, AFS performance tends to be very slow; this is a fairly
-reliable way to catch overloaded file servers.  By default, B<check_rxdebug>
-returns a critical error if there are more than eight connections waiting
-for a free thread and a warning if there are more than two.  These
-thresholds can be changed with the B<-c> and B<-w> options.
+B<check_rxdebug> is a Nagios plugin for checking AFS file servers to see
+if there are client connections waiting for a free thread.  If there are
+more than a few of these, AFS performance tends to be very slow; this is a
+fairly reliable way to catch overloaded file servers.  By default,
+B<check_rxdebug> returns a critical error if there are more than eight
+connections waiting for a free thread and a warning if there are more than
+two.  These thresholds can be changed with the B<-c> and B<-w> options.
 
-B<check_rxdebug> will always print out a single line of output including the
-number of blocked connections, displaying whether this is critical, a
+B<check_rxdebug> will always print out a single line of output including
+the number of blocked connections, displaying whether this is critical, a
 warning, or okay.
 
 =head1 OPTIONS
@@ -183,11 +181,11 @@ should be an integer.  The default is 2.
 
 =head1 EXIT STATUS
 
-B<check_rxdebug> follows the standard Nagios exit status requirements.  This
-means that it will exit with status 0 if there are no problems, with status
-1 if there is a warning, and with status 2 if there is a critical problem.
-For other errors, such as invalid syntax, B<check_rxdebug> will exit with
-status 3.
+B<check_rxdebug> follows the standard Nagios exit status requirements.
+This means that it will exit with status 0 if there are no problems, with
+status 1 if there is a warning, and with status 2 if there is a critical
+problem.  For other errors, such as invalid syntax, B<check_rxdebug> will
+exit with status 3.
 
 =head1 BUGS
 
@@ -199,27 +197,29 @@ conform to Nagios standards.
 
 =head1 CAVEATS
 
-This script does not use the Nagios util library or any of the defaults that
-it provides, which makes it somewhat deficient as a Nagios plugin.  This is
-intentional, though, since this script can be used with other monitoring
-systems as well.  It's not clear what a good solution to this would be.
+This script does not use the Nagios util library or any of the defaults
+that it provides, which makes it somewhat deficient as a Nagios plugin.
+This is intentional, though, since this script can be used with other
+monitoring systems as well.  It's not clear what a good solution to this
+would be.
 
 =head1 SEE ALSO
 
-The current version of this and other AFS monitoring plugins for Nagios are
-available from the AFS monitoring tools page at
-L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
+This script is part of the afs-monitor package, which includes various AFS
+monitoring plugins for Nagios.  It is available from the AFS monitoring
+tools page at L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
 
 =head1 AUTHORS
 
-The original idea behind this script was from Neil Crellin.  It was updated
-by Quanah Gibson-Mount to work with Nagios, and then further updated by Russ
-Allbery <rra@stanford.edu> to support more standard options and to use a
-more uniform coding style.
+The original idea behind this script was from Neil Crellin.  It was
+updated by Quanah Gibson-Mount to work with Nagios, and then further
+updated by Russ Allbery <rra@stanford.edu> to support more standard
+options and to use a more uniform coding style.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2003, 2004, 2005 Board of Trustees, Leland Stanford Jr. University.
+Copyright 2003, 2004, 2005, 2010 Board of Trustees, Leland Stanford
+Jr. University.
 
 This program is free software; you may redistribute it and/or modify it
 under the same terms as Perl itself.
index e3d0d30105050cfba355ec0c5ee207d7b51bbeba..b63ca0d94da6a3aca2f562e1cebaa1652124d353 100755 (executable)
@@ -1,10 +1,10 @@
 #!/usr/bin/perl -w
-# $ID = q$Id$;
+our $VERSION = '@VERSION@ @DATE@';
 #
 # check_udebug -- Check AFS database servers using udebug for Nagios.
 #
 # Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2004 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2004, 2010 Board of Trustees, Leland Stanford Jr. University
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the same terms as Perl itself.
 # Modules and declarations
 ##############################################################################
 
-require 5.003;
+require 5.006;
 
 use strict;
-use vars qw($ID $TIMEOUT $UDEBUG);
 
 use Getopt::Long qw(GetOptions);
 
@@ -30,14 +29,13 @@ use Getopt::Long qw(GetOptions);
 ##############################################################################
 
 # The default timeout in seconds (implemented by alarm) for udebug.
-$TIMEOUT = 10;
+our $TIMEOUT = 10;
 
 # The full path to udebug.  Make sure that this is on local disk so that
 # monitoring doesn't have an AFS dependency.
-($UDEBUG) = grep { -x $_ } qw(/usr/bin/udebug /usr/local/bin/udebug);
+our ($UDEBUG) = grep { -x $_ } qw(/usr/bin/udebug /usr/local/bin/udebug);
 $UDEBUG ||= '/usr/bin/udebug';
 
-
 ##############################################################################
 # Implementation
 ##############################################################################
@@ -45,20 +43,18 @@ $UDEBUG ||= '/usr/bin/udebug';
 # Parse command line options.
 my ($help, $host, $port, $version);
 Getopt::Long::config ('bundling', 'no_ignore_case');
-GetOptions ('hostname|H=s' => \$host,
-            'help|h'       => \$help,
-            'port|p=i'     => \$port,
-            'timeout|t=i'  => \$TIMEOUT,
-            'version|V'    => \$version) or exit 3;
+GetOptions ('H|hostname=s' => \$host,
+            'h|help'       => \$help,
+            'p|port=i'     => \$port,
+            't|timeout=i'  => \$TIMEOUT,
+            'V|version'    => \$version) or exit 3;
 if ($help) {
     print "Feeding myself to perldoc, please wait....\n";
     exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n";
 } elsif ($version) {
-    my $version = join (' ', (split (' ', $ID))[1..3]);
-    $version =~ s/,v\b//;
+    my $version = $VERSION;
     $version =~ s/(\S+)$/($1)/;
-    $version =~ tr%/%-%;
-    print $version, "\n";
+    print "check_bos $version\n";
     exit 0;
 }
 if (@ARGV || !(defined ($host) && defined ($port))) {
@@ -73,7 +69,7 @@ $SIG{ALRM} = sub {
 };
 alarm ($TIMEOUT);
 
-# Run udebug and parse the output.  We're looking for three things:  first,
+# Run udebug and parse the output.  We're looking for three things: first,
 # we're looking to see if this host claims to be the sync site.  If so, check
 # that recovery state is 1f.  Otherwise, make sure that there's a defined sync
 # host.
@@ -115,21 +111,22 @@ check_udebug - Check AFS servers for blocked connections in Nagios
 
 =head1 SYNOPSIS
 
-check_udebug [B<-hV>] [B<-t> I<timeout>] B<-H> I<host> B<-p> I<port>
+B<check_udebug> [B<-hV>] [B<-t> I<timeout>] B<-H> I<host> B<-p> I<port>
 
 =head1 DESCRIPTION
 
-B<check_udebug> is a Nagios plugin for checking AFS database servers to make
-sure the Ubik replication between the database servers is running correctly.
-B<udebug> is used to connect to the specified port, which should generally
-be one of 7002 (ptserver), 7003 (vlserver), or 7004 (kaserver), on the
-specified server.  The resulting output is checked to make sure that the
-recovery state is 1f if that server is the sync site, or that a sync site is
-known if that server doesn't claim to be the sync site.
+B<check_udebug> is a Nagios plugin for checking AFS database servers to
+make sure the Ubik replication between the database servers is running
+correctly.  B<udebug> is used to connect to the specified port on the
+specified server.  The port should generally be one of 7002 (ptserver),
+7003 (vlserver), or 7004 (kaserver).  The resulting output is checked to
+make sure that the recovery state is 1f if that server is the sync site,
+or that a sync site is known if that server doesn't claim to be the sync
+site.
 
 B<check_udebug> will always print out a single line of output.  That line
-will be C<UBIK OK> if everything is fine, or C<UBIK CRITICAL - > followed by
-an error message otherwise.
+will be C<UBIK OK> if everything is fine, or C<UBIK CRITICAL - > followed
+by an error message otherwise.
 
 =head1 OPTIONS
 
@@ -147,9 +144,9 @@ to C<perldoc -t>).
 
 =item B<-p> I<port>, B<--port>=I<port>
 
-The port to connect to on the AFS database server.  This should generally be
-one of 7002 (ptserver), 7003 (vlserver), or 7004 (kaserver).  This option is
-required.
+The port to connect to on the AFS database server.  This should generally
+be one of 7002 (ptserver), 7003 (vlserver), or 7004 (kaserver).  This
+option is required.
 
 =item B<-t> I<timeout>, B<--timeout>=I<timeout>
 
@@ -164,31 +161,32 @@ Print out the version of B<check_udebug> and quit.
 
 =head1 EXIT STATUS
 
-B<check_udebug> follows the standard Nagios exit status requirements.  This
-means that it will exit with status 0 if there are no problems or with
-status 2 if there are critical problems.  For other errors, such as invalid
-syntax, B<check_udebug> will exit with status 3.
+B<check_udebug> follows the standard Nagios exit status requirements.
+This means that it will exit with status 0 if there are no problems or
+with status 2 if there are critical problems.  For other errors, such as
+invalid syntax, B<check_udebug> will exit with status 3.
 
 =head1 BUGS
 
-The standard B<-v> verbose Nagios plugin option is not supported.  It should
-print out the full B<udebug> output.
+The standard B<-v> verbose Nagios plugin option is not supported.  It
+should print out the full B<udebug> output.
 
 The usage message for invalid options and for the B<-h> option doesn't
 conform to Nagios standards.
 
 =head1 CAVEATS
 
-This script does not use the Nagios util library or any of the defaults that
-it provides, which makes it somewhat deficient as a Nagios plugin.  This is
-intentional, though, since this script can be used with other monitoring
-systems as well.  It's not clear what a good solution to this would be.
+This script does not use the Nagios util library or any of the defaults
+that it provides, which makes it somewhat deficient as a Nagios plugin.
+This is intentional, though, since this script can be used with other
+monitoring systems as well.  It's not clear what a good solution to this
+would be.
 
 =head1 SEE ALSO
 
-The current version of this and other AFS monitoring plugins for Nagios are
-available from the AFS monitoring tools page at
-L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
+This script is part of the afs-monitor package, which includes various AFS
+monitoring plugins for Nagios.  It is available from the AFS monitoring
+tools page at L<http://www.eyrie.org/~eagle/software/afs-monitor/>.
 
 =head1 AUTHORS
 
@@ -196,7 +194,7 @@ Russ Allbery <rra@stanford.edu>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2004 Board of Trustees, Leland Stanford Jr. University.
+Copyright 2004, 2010 Board of Trustees, Leland Stanford Jr. University.
 
 This program is free software; you may redistribute it and/or modify it
 under the same terms as Perl itself.