All,
> I wrote a
> script recently to list the most recent instance of every save set in the
> media DB.
This is my version of much the same thing:
#######################################################
#!/usr/local/bin/perl -w
# last_full - Generate a list of all active full save sets
#
# Output format is (fields are tab separated):
# <savetime> <megabytes> <number_files> <client> <name>
#
# This can be sorted to good effect with: "sort +0n +3".
#
# The algorithm used seems to be more complicated than you would first
# imagine. The first thing we do is get a list of all active save sets,
# where "active" is "seen in the last 3 weeks". It is only these save
# sets that we are interested in. This gets rid of those cients that
# died years ago, but still have save sets on tape. It also lets us see
# those clients that still exist, but have not done a full for a very
# long time (we are particularly interested in these...).
# May 2001, written by George Scott, Monash University
# (converted from a previous shell script)
# Aug 2002, modified to work with NSR 6
# (slight change to mminfo output format)
############################
# Get a list of all active save sets
############################
$q = 'pssid=0';
$r = 'client,name';
$t = '3 weeks ago';
# Would be quicker to use unsorted here, but that is not an option...
$r =~ s/,/,newline,/g;
push @cmd1, "mminfo -t '$t' -q '$q' -r '$r'";
open CMD, "@cmd1|" or die "Can't run @cmd1: $!\n";;
$field=0;
$skip_header = 1;
while (<CMD>) {
chomp;
$_ =~ s/^\s+//; # strip leading spaces
$field++;
$client = $_ if $field==1;
$name = $_ if $field==2;
next if $field < 2;
$field = 0;
if( $skip_header ) {
$skip_header = 0;
next;
}
$i = $client . ':' . $name;
$active{$i} = 1;
}
close CMD;
############################
# Gather information about the latest full of each save set
############################
$q = '!incomplete,!ssrecycle,!recoverable,level=full';
$r = 'ssid,pssid,savetime,client,totalsize,nfiles,name';
$r =~ s/,/,newline,/g;
push @cmd2, "mminfo -q '$q' -r '$r' -ot";
open CMD, "@cmd2|" or die "Can't run @cmd2: $!\n";;
$field=0;
$skip_header = 1;
while (<CMD>) {
chomp;
$_ =~ s/^\s+//; # strip leading spaces
$field++;
$ssid = $_ if $field==1;
$pssid = $_ if $field==2;
$savetime = $_ if $field==3;
$client = $_ if $field==4;
$totalsize = $_ if $field==5;
$nfiles = $_ if $field==6;
$name = $_ if $field==7;
next if $field < 7;
$field = 0;
if( $skip_header ) {
$skip_header = 0;
next;
}
if ($pssid == 0) {
$p = $ssid;
$n = (@d = split("/", $savetime, 9999));
if ($n == 3) {
$da = $d[1];
$mo = $d[0];
$ye = $d[2] + 1900;
if ($ye < 1970) {
$ye += 100;
}
}
else {
$da = '**';
$mo = '**';
$ye = '****';
}
$st{$p} = $ye . $mo . $da;
$cl{$p} = $client;
$ts{$p} = $totalsize;
$nf{$p} = $nfiles;
$na{$p} = $name;
$i = $client . ':' . $name;
$idx{$i} = $p;
}
else {
$p = $hof{$pssid};
$ts{$p} += $totalsize;
$nf{$p} += $nfiles;
}
$hof{$ssid} = $p; # hof - head of family
}
close CMD;
############################
# Output information about active save sets
############################
foreach $i (keys %active) {
if (!$idx{$i}) {
next; # this should never happen?
}
$ssid = $idx{$i};
$mb = int($ts{$ssid} / 1024 / 1024 + 0.5); # convert to rounded MB
printf "%s %s %s %s %s\n", $st{$ssid}, $mb,
$nf{$ssid}, $cl{$ssid}, $na{$ssid};
}
#######################################################
George.
--
George Scott George.Scott AT its.monash DOT edu
Systems Programmer, IT Services, Monash University
--
Note: To sign off this list, send a "signoff" command via email
to listserv AT listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
|