From 38a2d6083519fb286f4cab18da98a8e6c334a3af Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Thu, 3 Mar 2011 17:55:15 -0800 Subject: [PATCH] Imported Upstream version 2.2 --- LICENSE | 8 ++++---- NEWS | 17 +++++++++++++++++ README | 9 +++++---- check_afs_bos | 11 ++++++----- check_afs_quotas | 20 +++++++++++++------- check_afs_rxdebug | 10 +++++----- check_afs_space | 48 ++++++++++++++++++++++++++++++++--------------- check_afs_udebug | 10 ++++++---- 8 files changed, 89 insertions(+), 44 deletions(-) diff --git a/LICENSE b/LICENSE index 839a1e9..441dfda 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,12 @@ The afs-monitor package is: - Copyright 2003, 2004, 2005, 2006, 2010 Board of Trustees, Leland - Stanford Jr. University. + Copyright 2003, 2004, 2005, 2006, 2010, 2011 The Board of Trustees of + the Leland Stanford Junior University. and released under the following license: - This program is free software; you may redistribute it and/or modify it - under the same terms as Perl itself. + These programs are free software; you may redistribute them and/or + modify them under the same terms as Perl itself. This means that you may choose between the two licenses that Perl is released under: the GNU GPL (any version) and the Artistic License. diff --git a/NEWS b/NEWS index 48073dc..81aad38 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,22 @@ User-Visible afs-monitor Changes +afs-monitor 2.2 (2011-03-03) + + Add a -d flag to check_afs_space that prints out Nagios performance + data for the percent usage of each partition checked. Based on a + patch by Breandan Dezendorf. + + Correctly handle partitions containing no read/write volumes in + check_afs_quotas. Thanks, Daniel Scott. + + The vos binary is installed in sbin by the Red Hat packages and the + default upstream installation rules, so check in sbin as well as bin. + Patch from Daniel Scott. Also fall back, for all AFS binaries, to + using PATH if the binary can't be found in known locations. + + Correctly handle checking quota of volumes with unlimited quota + without a division by zero error. Patch from Erik Dalén. + afs-monitor 2.1 (2010-12-08) Fix a bug in check_afs_space introduced in the previous release with diff --git a/README b/README index 34e1617..33718c3 100644 --- a/README +++ b/README @@ -1,11 +1,12 @@ - afs-monitor release 2.1 + afs-monitor release 2.2 (Nagios-compatible probes to monitor AFS servers) Maintained by Russ Allbery - Copyright 2003, 2004, 2005, 2006, 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. + Copyright 2003, 2004, 2005, 2006, 2010, 2011 The Board of Trustees of + the Leland Stanford Junior University. These programs are free + software; you may redistribute them and/or modify them under the same + terms as Perl itself. BLURB diff --git a/check_afs_bos b/check_afs_bos index 2195c75..f05e22c 100755 --- a/check_afs_bos +++ b/check_afs_bos @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -our $VERSION = '2.1 (2010-12-08)'; +our $VERSION = '2.2 (2011-03-03)'; # # check_afs_bos -- Monitor AFS bos output for problems in Nagios. # @@ -11,7 +11,8 @@ our $VERSION = '2.1 (2010-12-08)'; # # Written by Russ Allbery # Based on an earlier script by Neil Crellin -# Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr. University +# Copyright 2003, 2004, 2010 +# The Board of Trustees of the Leland Stanford Junior University # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -33,7 +34,7 @@ use Getopt::Long qw(GetOptions); # The full path to bos. Make sure that this is on local disk so that # monitoring doesn't have an AFS dependency. our ($BOS) = grep { -x $_ } qw(/usr/bin/bos /usr/local/bin/bos); -$BOS ||= '/usr/bin/bos'; +$BOS ||= 'bos'; # The default timeout in seconds (implemented by alarm) for rxdebug. our $TIMEOUT = 10; @@ -258,8 +259,8 @@ output, instead just scanning it for acceptable lines. =head1 COPYRIGHT AND LICENSE -Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr. -University. +Copyright 2003, 2004, 2010 The Board of Trustees of the Leland Stanford +Junior University. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/check_afs_quotas b/check_afs_quotas index 0ef8bfe..c514b9c 100755 --- a/check_afs_quotas +++ b/check_afs_quotas @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -our $VERSION = '2.1 (2010-12-08)'; +our $VERSION = '2.2 (2011-03-03)'; # # check afs_quotas -- Monitor AFS quota usage under Nagios. # @@ -11,7 +11,8 @@ our $VERSION = '2.1 (2010-12-08)'; # # Written by Russ Allbery # Based on a script by Steve Rader -# Copyright 2010 Board of Trustees, Leland Stanford Jr. University +# Copyright 2010 +# The Board of Trustees of the Leland Stanford Junior University # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -50,8 +51,9 @@ 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. -our ($VOS) = grep { -x $_ } qw(/usr/bin/vos /usr/local/bin/vos); -$VOS ||= '/usr/bin/vos'; +our ($VOS) = grep { -x $_ } + qw(/usr/bin/vos /usr/sbin/vos /usr/local/bin/vos /usr/local/sbin/vos); +$VOS ||= 'vos'; ############################################################################## # AFS operations @@ -105,7 +107,7 @@ sub serverinfo { $volume = $1; $results{$volume}{size} = $2; } elsif (/^\s+MaxQuota\s+(\d+) K\s*$/) { - $results{$volume}{quota} = $1; + $results{$volume}{quota} = $1 if defined $volume; } } return %results; @@ -124,7 +126,10 @@ sub summarize_volume { my $used = $$results{size}; my $free = $total - $used; $free = 0 if ($free < 0); - my $percent = int ((($total - $free) / $total) * 100); + my $percent = 0; + if ($total > 0) { + $percent = int ((($total - $free) / $total) * 100); + } if ($FORMAT) { $total = format_bytes ($total, mode => 'iec'); $free = format_bytes ($free, mode => 'iec'); @@ -351,7 +356,8 @@ Written by Russ Allbery based on a similar script by Steve Rader. =head1 COPYRIGHT AND LICENSE -Copyright 2010 Board of Trustees, Leland Stanford Jr. University. +Copyright 2010 The Board of Trustees of the Leland Stanford Junior +University. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/check_afs_rxdebug b/check_afs_rxdebug index d7f333a..3c34486 100755 --- a/check_afs_rxdebug +++ b/check_afs_rxdebug @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -our $VERSION = '2.1 (2010-12-08)'; +our $VERSION = '2.2 (2011-03-03)'; # # check_afs_rxdebug -- Nagios AFS server check for waiting connections. # @@ -12,7 +12,7 @@ our $VERSION = '2.1 (2010-12-08)'; # Written by Quanah Gibson-Mount based on work by Neil Crellin # Updated by Russ Allbery # Copyright 2003, 2004, 2005, 2010 -# Board of Trustees, Leland Stanford Jr. University +# The Board of Trustees of the Leland Stanford Junior University # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -44,7 +44,7 @@ our $TIMEOUT = 60; our ($RXDEBUG) = grep { -x $_ } qw(/usr/bin/rxdebug /usr/sbin/rxdebug /usr/local/bin/rxdebug /usr/local/sbin/rxdebug); -$RXDEBUG ||= '/usr/bin/rxdebug'; +$RXDEBUG ||= 'rxdebug'; ############################################################################## # Implementation @@ -226,8 +226,8 @@ options and to use a more uniform coding style. =head1 COPYRIGHT AND LICENSE -Copyright 2003, 2004, 2005, 2010 Board of Trustees, Leland Stanford -Jr. University. +Copyright 2003, 2004, 2005, 2010 The Board of Trustees of the Leland +Stanford Junior University. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/check_afs_space b/check_afs_space index 091a8ee..695c7bc 100755 --- a/check_afs_space +++ b/check_afs_space @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -our $VERSION = '2.1 (2010-12-08)'; +our $VERSION = '2.2 (2011-03-03)'; # # check_afs_space -- Monitor AFS disk space usage under Nagios. # @@ -10,7 +10,8 @@ our $VERSION = '2.1 (2010-12-08)'; # # Written by Susan Feng # Updated by Russ Allbery -# Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr. University +# Copyright 2003, 2004, 2010 +# The Board of Trustees of the Leland Stanford Junior University # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -49,8 +50,9 @@ 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. -our ($VOS) = grep { -x $_ } qw(/usr/bin/vos /usr/local/bin/vos); -$VOS ||= '/usr/bin/vos'; +our ($VOS) = grep { -x $_ } + qw(/usr/bin/vos /usr/sbin/vos /usr/local/bin/vos /usr/local/sbin/vos); +$VOS ||= 'vos'; ############################################################################## # Implementation @@ -66,9 +68,10 @@ sub syntax { } # Parse command line options. -my ($help, $host, $partition, $version); +my ($help, $host, $partition, $printdata, $version); Getopt::Long::config ('bundling', 'no_ignore_case'); GetOptions ('c|critical=i' => \$CRITICAL, + 'd|perfdata' => \$printdata, 'H|hostname=s' => \$host, 'h|help' => \$help, 'p|partition=s' => \$partition, @@ -80,8 +83,7 @@ if ($help) { print "Feeding myself to perldoc, please wait....\n"; exec ('perldoc', '-t', $0) or die "Cannot fork: $!\n"; } elsif ($version) { - my $version = $VERSION; - print "check_afs_space $version\n"; + print "check_afs_space $VERSION\n"; exit 0; } syntax ("extra arguments on command line") if @ARGV; @@ -103,8 +105,9 @@ alarm ($TIMEOUT); # Get the partinfo information and calculate the percentage free for each # partition. Accumulate critical messages in @critical and warnings in -# @warnings. Accumulate all percentages in @all. -my (@critical, @warnings, @all); +# @warnings. Accumulate all percentages in @all. Accumulate performance data +# in @perfdata. +my (@critical, @warnings, @all, @perfdata); my $command = "$VOS partinfo -server '$host'"; $command .= " -partition $partition" if defined ($partition); my @data = `$command 2> /dev/null`; @@ -123,6 +126,9 @@ for (@data) { $free = format_bytes ($free, mode => 'iec'); $used = format_bytes ($used, mode => 'iec'); } + my $ppart = $part . '_percent'; + $ppart =~ tr%:/%%d; + push (@perfdata, "$ppart=$percent\%;$WARNINGS;$CRITICAL;0;100"); my $summary; if ($partition) { $summary = "$part$percent% used" @@ -147,14 +153,18 @@ unless (@all) { } # Exit with the appropriate error messages. +my $perfdata = ''; +if ($printdata) { + $perfdata = ' | ' . join (' ', @perfdata); +} if (@critical) { - print "AFS CRITICAL - @critical\n"; + print "AFS CRITICAL - @critical$perfdata\n"; exit 2; } elsif (@warnings) { - print "AFS WARNING - @warnings\n"; + print "AFS WARNING - @warnings$perfdata\n"; exit 1; } else { - print "AFS OK - @all\n"; + print "AFS OK - @all$perfdata\n"; exit 0; } @@ -168,7 +178,7 @@ check_afs_space - Monitor AFS disk space usage under Nagios =head1 SYNOPSIS -B [B<-hV>] [B<-c> I] [B<-w> I] +B [B<-dhV>] [B<-c> I] [B<-w> I] [B<-p> I] [B<-t> I] B<-H> I =head1 DESCRIPTION @@ -202,6 +212,14 @@ about the total, used, and free space is given in the one line of output. Change the critical percentage threshold to I, which should be an integer percentage. The default is 90. +=item B<-d>, B<--perfdata> + +Include performance data in the plugin output. This adds an additional +section of the output following a vertical bar (C<|>) following the Nagios +plugin standard for performance data. There will be one variable for each +partition checked, named C_percent>, where I is the +partition without the leading slash. The value will be the usage percentage. + =item B<-H> I, B<--hostname>=I The AFS file server whose free space B should check. This @@ -280,8 +298,8 @@ work by Steve Rader. =head1 COPYRIGHT AND LICENSE -Copyright 2003, 2004, 2010 Board of Trustees, Leland Stanford Jr. -University. +Copyright 2003, 2004, 2010 The Board of Trustees of the Leland Stanford +Junior University. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/check_afs_udebug b/check_afs_udebug index 11928b3..150f290 100755 --- a/check_afs_udebug +++ b/check_afs_udebug @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -our $VERSION = '2.1 (2010-12-08)'; +our $VERSION = '2.2 (2011-03-03)'; # # check_afs_udebug -- Check AFS database servers using udebug for Nagios. # @@ -9,7 +9,8 @@ our $VERSION = '2.1 (2010-12-08)'; # any of the servers don't believe there is a sync site. # # Written by Russ Allbery -# Copyright 2004, 2010 Board of Trustees, Leland Stanford Jr. University +# Copyright 2004, 2010 +# The Board of Trustees of the Leland Stanford Junior University # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -34,7 +35,7 @@ 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. our ($UDEBUG) = grep { -x $_ } qw(/usr/bin/udebug /usr/local/bin/udebug); -$UDEBUG ||= '/usr/bin/udebug'; +$UDEBUG ||= 'udebug'; ############################################################################## # Implementation @@ -205,7 +206,8 @@ Russ Allbery =head1 COPYRIGHT AND LICENSE -Copyright 2004, 2010 Board of Trustees, Leland Stanford Jr. University. +Copyright 2004, 2010 The Board of Trustees of the Leland Stanford Junior +University. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. -- 2.39.5