# 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);
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;
}
# 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,
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");
}
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)
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,
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
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