]> git.michaelhowe.org Git - packages/a/afs-monitor.git/commitdiff
Coding style and NEWS for the volume regular expression filter
authorRuss Allbery <rra@stanford.edu>
Sun, 13 Jan 2013 03:39:13 +0000 (19:39 -0800)
committerRuss Allbery <rra@stanford.edu>
Sun, 13 Jan 2013 03:39:13 +0000 (19:39 -0800)
NEWS
check_afs_quotas

diff --git a/NEWS b/NEWS
index 66cedee24ae8dc5776f0478ae84241a81d3bcce7..f3976acc28fec970e4be068edd7164b921d80033 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@
 
 afs-monitor 2.4 (unreleased)
 
+    Support filtering the volumes considered on a particular server by a
+    regular expression in check_afs_quotas.  The regular expression is
+    specified with a new -r option.  Patch from Christian Ospelkaus.
+
     Also ignore bos status output from long-running scheduled jobs, such
     as AFS backups.  Patch from Georg Sluyterman.
 
index 7c775ea2e3c8243863cece8a7f1077db745df70d..03ea40a63858a1d437ab214fb800edfc06c2e7f2 100755 (executable)
@@ -91,7 +91,7 @@ sub volinfo {
 # in a hash where the keys are volume names and the values are hashes
 # containing 'size' and 'quota' keys and values in KB.
 sub serverinfo {
-    my ($server, $partition, $volreg) = @_;
+    my ($server, $partition, $regex) = @_;
     my @command = ($VOS, 'listvol', '-server', $server, '-long', '-noauth');
     if (defined ($partition)) {
         push (@command, '-partition', $partition);
@@ -104,16 +104,17 @@ sub serverinfo {
     local $_;
     while (<LVOL>) {
         if (/^(\S+)\s+\d+ RW\s+(\d+) K\s+On-line\s*$/) {
-            $volume=$1;
-            $size=$2;
-            if (!defined($volreg)||($1 =~ m/($volreg)/)) {
+            ($volume, $size) = ($1, $2);
+            if (!defined ($regex) || $volume =~ /$regex/) {
                 $results{$volume}{size} = $size;
             } else {
                 $volume = undef;
             }
-        } elsif (/^\s+MaxQuota\s+(\d+) K\s*$/ && defined($volume)) {
+        } elsif (/^\s+MaxQuota\s+(\d+) K\s*$/ && defined $volume) {
             $results{$volume}{quota} = $1;
             $volume = undef;
+        } elsif (/^\s*$/) { # next volume
+            $volume = undef;
         }
     }
     return %results;
@@ -160,13 +161,13 @@ sub syntax {
 }
 
 # Parse command line options.
-my ($help, $host, $partition, $version, $volume, $volreg);
+my ($help, $host, $partition, $regex, $version, $volume);
 Getopt::Long::config ('bundling', 'no_ignore_case');
 GetOptions ('c|critical=i'  => \$CRITICAL,
             'H|hostname=s'  => \$host,
             'h|help'        => \$help,
             'n|volume=s'    => \$volume,
-            'r|volreg=s'    => \$volreg,
+            'r|regex=s'     => \$regex,
             'p|partition=s' => \$partition,
             't|timeout=i'   => \$TIMEOUT,
             'V|version'     => \$version,
@@ -183,6 +184,8 @@ if ($help) {
 syntax ("extra arguments on command line") if @ARGV;
 syntax ("host or volume to check not specified")
     unless (defined ($host) || defined ($volume));
+syntax ("regex specified without host to check")
+    if (defined ($regex) && !defined ($host));
 if ($WARNINGS > $CRITICAL) {
     syntax ("warning level $WARNINGS greater than critical level $CRITICAL");
 }
@@ -213,7 +216,7 @@ if (defined ($volume)) {
         exit 0;
     }
 } else {
-    my %results = serverinfo ($host, $partition, $volreg);
+    my %results = serverinfo ($host, $partition, $regex);
     my (@ok, @warning, @critical);
     for my $volume (keys %results) {
         my ($percent, $summary)
@@ -269,7 +272,7 @@ a warning if it is over 85% (changeable with the B<-c> and B<-w> options).
 To check a single volume, specify the volume name with B<-n>.  To check a
 whole server, specify the server name with B<-H>.  You can check only a
 single partition on a server by using the B<-p> option to name the
-partition in combination with B<-H>. When checking an entire server, the 
+partition in combination with B<-H>.  When checking an entire server, the
 volumes checked can be filtered by using a regular expression (B<-r>).
 
 If C<vos examine> or C<vos listvol> doesn't return within the timeout,
@@ -312,6 +315,11 @@ particular partition.  The partition can be given in any of the forms
 recognized by the AFS tools (so both the partition letter C<a> and the
 full partition name C</vicepa> will work).
 
+=item B<-r> I<regex>
+
+When processing an entire server (B<-H>), ignore any volumes that don't
+match the specified Perl regular expression.
+
 =item B<-t> I<timeout>, B<--timeout>=I<timeout>
 
 Change the timeout for the C<vos partinfo> command.  The default timeout
@@ -326,11 +334,6 @@ Print out the version of B<check_afs_quotas> and quit.
 Change the warning percentage threshold to I<threshold>, which should be
 an integer percentage.  The default is 85.
 
-=item B<-r> I<regex>
-
-When processing an entire server (B<-H>), filter the volumes considered
-by I<regex>
-
 =back
 
 =head1 EXIT STATUS