[Veritas-bu] FROZEN tapes script
2005-06-22 08:21:33
Lewick, Taylor wrote:
>Here is the script, I've had a number of requests so I am posting it to
>the list...
>
>
Hope no one minds but i have altered this slightly to suit my
environment and to add an option of -d <days> to go back a few days.
e.g frozen-info.pl -d 2 will search through the logs from 2 days ago.
I am certainly no perl programmer at all so forgive perhaps untidiness.
Not i have taken out the ssh bit as my master server is a media server
and put a check in for bptm directory also.
Cheers
------ script --------
#!/usr/bin/perl
use Getopt::Std;
use Time::Local;
use POSIX qw(strftime);
my %opts;
getopt("d:", \%opts); # d = days
$epoch = timelocal(localtime);
$realtime = localtime($epoch);
if (defined $opts{d}) {
$epochdays = $opts{d} * 86400;
$newepoch = $epoch - $epochdays;
} else {
$newepoch = $epoch;
}
($mon, $mday, $year) = split(' ', strftime("%m %d %y",
localtime($newepoch)));
## Set log date to be -d days old
$log_date="$mon$mday$year";
$rep_date="$mon/$mday/$year";
### Main Script ###
#Check dir exsists
$bptmdir='/usr/openv/netbackup/logs/bptm';
if ( ! -d $bptmdir ) {
print "\nWARNING: Cannot find $bptmdir. Exiting....\n\n";
exit 1;
}
# Add extra media servers in list ("media server", "media server")
@media_servers = ("host");
foreach $server (@media_servers) {
#open (IN, "/usr/local/bin/ssh $server /usr/bin/cat
$bptmdir/log.$log_date |");
open (IN, "/usr/bin/cat $bptmdir/log.$log_date |");
while (<IN>) {
if (/^.*FREEZING media id\s(......),\s(.*)/) {
$mediaID=$1;
$freeze_reason=$2;
$Frozen{$mediaID}{$freeze_reason}++;
#print "$server, $mediaID, $freeze_reason\n";
}
}
close (IN);
}
print "Frozen Media Report for $rep_date";
if (scalar %Frozen) {
foreach $mediaID (sort keys %Frozen) {
foreach $freeze_reason (sort keys %{ $Frozen{$mediaID} }) {
print "$mediaID, $freeze_reason\n";
}
}
}
else {print "\nNo Frozen tapes found.\n";}
|
|
|