#!/usr/bin/perl -w use strict; use Data::Dumper; my $debug = 0; $ENV{PATH} .= ':/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd:/usr/openv/netbackup/bin/goodies:/usr/openv/volmgr/bin:/usr/openv/volmgr/bin/goodies:/usr/openv/java'; my %robots; foreach (qx{tpconfig -l}) { if ($_ =~ m/^robot/) { # have to use a hash; there can be gaps in robnum depending on # how NBU was configured / robots removed / etc $robots{(split())[1]} = (split())[3]; } } print "robots by number:\n", Dumper(%robots), "\n" if $debug; chomp(my $scratch_pool = qx{vmpool -listscratch | tail -1}); my %scratch_tapes; foreach my $robot (sort keys %robots) { my @lines = qx{vmquery -pn $scratch_pool -b | grep "$robots{$robot} ${robot}"}; my %type_lists; foreach my $line (@lines) { my ($volser, $type) = (split(' ', $line))[0,1]; push @{$scratch_tapes{$robots{$robot} . $robot}->{$type}}, $volser; } } print "volsers by media type by robot:\n", Dumper(%scratch_tapes), "\n" if $debug; foreach my $robot (sort keys %scratch_tapes) { print "$robot\n" if $debug; foreach my $types ($scratch_tapes{$robot}) { print Dumper(%{$types}), "\n" if $debug; foreach my $type (sort keys %{$types}) { print Dumper(@{${$types}{$type}}), "\n" if $debug; printf "%4s has %4d %-7s media in the pool $scratch_pool.\n", $robot, $#{${$types}{$type}} + 1, $type; } } }