Home arrow Sticky Business arrow Information Security arrow Availability arrow NBU Trick #1 - Where Did All My Tapes Go?
Apr 27 2003
NBU Trick #1 - Where Did All My Tapes Go? Print E-mail
Written by Paul Winkeler   
Sunday, 27 April 2003
Whenever you find yourself knee deep in NetBackup error code 96 messages, you wonder where all those you bought justa few months ago tapes went. Have your washer and dryer passed their sock disappearing genes on to your tape library?
Below is the listing for a short NBU Module based Perl script included in the distribution called vu.pl, which breaks down tape usage by retention period and volume type (a.k.a. density):
#!/usr/local/bin/perl -w
use strict;
#
# Always use strict mode and let the warnings flood your screen; It is either that
# or suffer through the support calls later...!
# 
# Then start off by pulling in the NBU modules and pre-populating the internal
# representation of ALL the images in the NetBackup image database and
# placing them into the array 'l;.  Initialze a few counter arrays and scalars and
# we're ready to go.
use NBU;

NBU::Image->populate;
my @l = NBU::Image->list;
print "There are $#l images\n";

my %retentionTotal;
my %retentionVolumes;
my %inUse;
my $total = 0;

#
# Now it is a simple matter of investigating each image in the catalog and
# adding its size to the total for that tape density and retention level, and, if
# this is the first time encountering the volume, incrementing the volume
# count for that density and retention level combination.
for my $image (@l) {
  next if (!defined($image->size));
  # Scale image size down from KBytes to MBytes
  my $size = $image->size / 1024;
  $retentionTotal{$image->density.":".$image->retention->level} += $size;
  if (!exists($inUse{$image->volume->id})) {
    $retentionVolumes{$image->density.":".$image->retention->level} += 1;
    $inUse{$image->volume->id} = +1;
  }
  $total += $size;
}

#
# With the totals in our hash array ready to go, it is time to run the reporting
# loop.  One interesting thing to add perhaps is the average compression
# factor you're getting.  This could be done if you knew the native capacity
# of each density in your environment, something that is usually a well-known
# number
for my $l (sort (keys %retentionTotal)) {
  # Display totals in GBytes:
  my $rlt = sprintf("%10.2f", $retentionTotal{$l}/1024);
  my $rlc = $retentionVolumes{$l};
  my ($density, $rl) = split(':', $l);
  # Retention levels as returned by the images in the loop above can be
  # used to instantiate Retention objects.  Those can then be queried for their
  # description, making for a more useful report.
  my $r = NBU::Retention->byLevel($rl);
  print $rlt."Gb at ".$r->description." on $rlc ".$density." volumes\n";
}

$total = sprintf("%.2f", $total/1024);
print "Total size is ${total}Gb\n";
If this is at all useful to you, let me know. Improvements, enhancements and of course bug-fixes are also always welcome too.
Last Updated ( Monday, 27 August 2007 )
 
< Prev