# 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) = @_;
+ my ($server, $partition, $volreg) = @_;
my @command = ($VOS, 'listvol', '-server', $server, '-long', '-noauth');
if (defined ($partition)) {
push (@command, '-partition', $partition);
print "AFS CRITICAL - cannot contact server\n";
exit 2;
}
- my ($volume, %results);
+ my ($volume, $size, %results);
local $_;
while (<LVOL>) {
if (/^(\S+)\s+\d+ RW\s+(\d+) K\s+On-line\s*$/) {
- $volume = $1;
- $results{$volume}{size} = $2;
- } elsif (/^\s+MaxQuota\s+(\d+) K\s*$/) {
- $results{$volume}{quota} = $1 if defined $volume;
- } elsif (/^\s*$/) { # next volume
+ $volume=$1;
+ $size=$2;
+ if (!defined($volreg)||($1 =~ m/($volreg)/)) {
+ $results{$volume}{size} = $size;
+ } else {
+ $volume = undef;
+ }
+ } elsif (/^\s+MaxQuota\s+(\d+) K\s*$/ && defined($volume)) {
+ $results{$volume}{quota} = $1;
$volume = undef;
}
}
}
# Parse command line options.
-my ($help, $host, $partition, $version, $volume);
+my ($help, $host, $partition, $version, $volume, $volreg);
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,
'p|partition=s' => \$partition,
't|timeout=i' => \$TIMEOUT,
'V|version' => \$version,
exit 0;
}
} else {
- my %results = serverinfo ($host, $partition);
+ my %results = serverinfo ($host, $partition, $volreg);
my (@ok, @warning, @critical);
for my $volume (keys %results) {
my ($percent, $summary)
B<check_afs_quotas> [B<-hV>] [B<-c> I<threshold>] [B<-w> I<threshold>]
[B<-t> I<timeout>] (B<-H> I<host> [B<-p> I<partition>] | B<-n> I<volume>)
+ [B<-r> I<regex>]
=head1 DESCRIPTION
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>.
+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,
B<check_afs_quotas> will return a critical error. The default timeout is
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