0% found this document useful (0 votes)
524 views9 pages

Netbackup Health Check Windows Unix

I have modified my previously uploaded Healthcheck script in a way that, this script is compatible both on windows and Unix.

Uploaded by

Mahek Arora
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
524 views9 pages

Netbackup Health Check Windows Unix

I have modified my previously uploaded Healthcheck script in a way that, this script is compatible both on windows and Unix.

Uploaded by

Mahek Arora
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

#!

/bin/perl -w
use strict;

use File::Find;
use integer;
use Cwd;

my $NB_Install_Path1="C:/Program Files/VERITAS";
my $NB_Install_Path2="C:/\"Program Files\"/VERITAS";

my $Store="D:/test";
my %NB_cmd_path = (
bperror => "netbackup/bin/admincmd",volmgr => "volmgr/bin"
);

my $hostname;
my $date;
my $i=0;
my $j=0;
my $sum=0;
my $sizegb;
my $frozcnt=0;
my $errcnt=0;
my $err1cnt=0;
my $client_list;
my $client_count;
my $downdr;
my @arr;
my @line;
my @dir_path;
my @policy;
my @client;
my @data;
my @act;
my @ar;

$hostname=`hostname`;
chomp($hostname);
$date=`date`;
$date =~ m/(\d+\/\d+\/\d+)/;
chomp($date);

print "\n************************ Health Check for $hostname on $1 ******************\n";


print "------------------------------------------------------------------------------";

printf "\n";

#get No. of Clients, Active & Deactive Policies

&find(\&wanted,"$NB_Install_Path1/netbackup/db/class");

print "No. of Active Policies : $i\n\n";


print "No. of Inactive Policies : $j\n\n";
for (@policy)
{
$client_list = `$NB_Install_Path2/netbackup/bin/admincmd/bpplclients $_ -allunique`;
@client = split (/\n/,$client_list);
$client_count=@client-2;
}
print "Total Clients : $client_count\n\n";

#Count total Size backedup

foreach(`$NB_Install_Path2/netbackup/bin/admincmd/bpimagelist -l -hoursago 24 2>> $Store/errreport`)


{
chomp;
if(/^FRAG/)
{
@data = split(/ /,$_);
$sum = $sum+$data[3];
}
}
$sizegb=$sum/1048576;
if($sizegb >= 1)
{
print "Data backed up by $hostname (in last 24hrs) : $sizegb GB\n\n";
}
else
{
$sizegb=$sum * 1048576;
print "Data backed up by $hostname (in last 24hrs) : $sizegb KB\n\n";
}

#Count total No. of Frozen tapes

foreach(`$NB_Install_Path2/netbackup/bin/goodies/available_media`)
{
chomp;
if(/frozen$/i)
{
++$frozcnt;
}

}
print "Frozen Media on $hostname : $frozcnt\n\n";

#Find Total No. of Failures

foreach(`$NB_Install_Path2/netbackup/bin/admincmd/bperror -U -backstat -hoursago 24`)


{
chomp;
if(/^\s*[^0]\s+/)
{
++$errcnt;
if (/^\s*1\s+/)
{
++$err1cnt;
}
}

}
print "Total Backup failures : $errcnt\n\n";
print "Incomplete Backups (Status code 1) : $err1cnt\n\n";

#Count total No. of Scratch tapes


my $tldcnt=0;
my @tldarr;

foreach(`$NB_Install_Path2/volmgr/bin/vmquery -pn Scratch -b`)


{
next if($_ =~ /^\n/ || $_ =~ /^--/);
chomp;
@tldarr = split(/\s+/,$_);
if($tldarr[2] =~ /TLD/i)
{
++$tldcnt;
}
}
print "Total Scratch tapes: $tldcnt\n\n";

my @line1;
my @linearr;
my $size;
my $sum2;
my $mins;
my $newlis;
my @clie_lis;
my @line2;
my $b=0;

`$NB_Install_Path2/netbackup/bin/admincmd/bpplclients $policy[1] -allunique > $Store/lis.txt`;


open (NEW,"$Store/lis.txt") or die "$!";
<NEW>;
<NEW>;
foreach(<NEW>)
{
@line2="";
$sum2=0;
next if(/^\#/);
chomp;
@line1 = split(/\s+/,$_);
@line2=`$NB_Install_Path2/netbackup/bin/admincmd/bpimagelist -client $line1[2]
-hoursago 24 2>> $Store/errreport`;
foreach(@line2)
{
if(/^image/i)
{
chomp;
@linearr= split(/\s+/,$_);
$size = $linearr[14];
$sum2= $sum2+$size;
}
}
$mins = $sum2/(60*60);
if($mins > 14)
{
print "Client $line1[2] is taking more than $mins Hours\n\n";
++$b;
}
}
close NEW;
if($b == 0)
{
print "None of the backups ran beyond 14 hours\n\n";
}

#Count the no of Drives down on each Media Server


print "************************** Drive Status **********************\n";
print "-----------------------------------------------------------------\n\n";
open (VMF,"$NB_Install_Path1/volmgr/vm.conf");
foreach(<VMF>)
{
next if (/^\n/);
chomp;
if(/^DEVICE_HOST/i)
{
$downdr=0;
@arr=split(/\s+/,$_);
`$NB_Install_Path2/volmgr/bin/vmoprcmd -d ds -h $arr[2] > $Store/$arr[2].txt`;
open (DRV,"$Store/$arr[2].txt");
foreach(<DRV>)
{
chomp;
if(/^\s*\d+/)
{
@line = split(/\s+/,$_);
if($line[3] =~ /DOWN/i)
{
++$downdr;
}
}
}
if ($downdr > 0)
{
print "for Media server $arr[2], There are $downdr Drives which are
down\n\n";
}
else
{
print "for Media server $arr[2], no Drives are down\n\n";
}

}
}
################################################################3

my @arr2;
my @med;
my $i2=0;
my %medhash;

my @fragar;

# Load on Media Servers

print "\n";

print "******************Load on Media Servers in past 24 Hours*****************\n";


print "--------------------------------------------------------\n\n";

open (VMF,"$NB_Install_Path1/volmgr/vm.conf") or die "$!\n";


foreach(<VMF>)
{
next if (/^\n/);
chomp;
if(/^DEVICE_HOST/i)
{
@arr2=split(/\s+/,$_);
$med[$i2]=$arr2[2];
++$i2;
}
}
close VMF;
foreach(@med)
{
$medhash{$_}=0;
}

`$NB_Install_Path2/netbackup/bin/admincmd/bpimagelist -l -hoursago 24 > $Store/imagelist.txt 2>>


$Store/errreport`;
open (FRAG1,"$Store/imagelist.txt") or die "$!\n";
foreach(<FRAG1>)
{
if(/^FRAG/i)
{
@fragar=split(/\s+/,$_);
if($fragar[2] != -1)
{
$medhash{$fragar[9]} = $medhash{$fragar[9]} + $fragar[3];
}
}
}
close FRAG1;

foreach(@med)
{
$medhash{$_}=$medhash{$_}/1048576;
if($medhash{$_} >= 1)
{
print " $_ : $medhash{$_} GB\n\n";
}
else
{
$medhash{$_}=$medhash{$_} * 1048576;
print " $_ : $medhash{$_} KB\n\n";
}
}

########################################################################

my $flag=0;
my $img_cnt;
my $a;
my %nobackup;
my $count=0;
my @line3;
my @line4;
my $img_cnt2;
my @ver;
my @full;
my @fullmed;
my $i3=0;
my $i4;
my @poltype;
my $i5=0;

open(F1,"$NB_Install_Path1/netbackup/version.txt") or die "$!";


#while(<F1>)
foreach(<F1>)
{
chomp;
if(/^VERSION/i)
{
@ver=split(/\s+/,$_);
if($ver[2] eq "5.1")
{
open (F3,"> $Store/info5.1.txt");
foreach(`$NB_Install_Path2/netbackup/bin/admincmd/bpsyncinfo -L`)
{
if($_ !~ m/^\s*(frequency|options|sequence)/i )
{
print F3 "$_\n";
}
}
close F3;

}
else
{
`$NB_Install_Path2/netbackup/bin/admincmd/bpmedialist -p CatalogBackup > $Store/info6.txt`;
}
}
}
close F1;

foreach(`$NB_Install_Path2/netbackup/bin/goodies/available_media`)
{
chomp;
if(/FULL(|\/MPX)$/i)
{
@full = split(/\s+/,$_);
if($full[3] ne "-")
{
$fullmed[$i3]=$full[0];
++$i3;
}
}
}

# Print tapes which are full and with latest expiry date
print "\n";
print "Please find the following tapes in cap slot to be ejected (Full and with latest expiry date)\n";
print "---------------------------------------------------------------------------------------------------\n";

foreach(`$NB_Install_Path2/netbackup/bin/admincmd/bpmedialist -summary`)
{
for($i4=0;$i4<=$#fullmed;++$i4)
{
if($_ =~ m/$fullmed[$i4]/i)
{
print "$_";
}
}
}

# To check Vault is active or not on the server

foreach(`$NB_Install_Path2/netbackup/bin/admincmd/bppllist -allpolicies -L`)


{
if(/^Policy Type/i)
{
@poltype=split(/\s+/,$_);
if($poltype[2] =~ m/vault/i)
{
++$i5;
}
}
}
if($i5 > 0)
{
print "\nVault is active on $hostname\n";
}
else
{
print "\nVault is not active on $hostname\n";
}

# To List Clients whose backups are not happening from past 36 hours

print "\n";
print "Clients having no backups from past 36 hours on $hostname\n";
print "--------------------------------------------------------------------------\n";

open (NEW2,"$Store/lis.txt") or die "$!";


<NEW2>;
<NEW2>;
foreach(<NEW2>)
{
$img_cnt=0;
next if(/^\#/);
chomp;
@line3 = split(/\s+/,$_);
foreach(`$NB_Install_Path2/netbackup/bin/admincmd/bpimagelist -client $line3[2] -hoursago 36 2>>
$Store/errreport `)
{
if(/^image/i)
{
++$img_cnt;
}
}
if($img_cnt > 0)
{
$a=1;
}
else
{
print "\t$line3[2]\n ";
$flag=1;
}
}
close NEW2;

if($flag == 0)
{
print "All clients have been backed up in last 36 hours";
}

# List Clients having no backups since 10 days on


print "\n";
print "Clients having no backups since 10 days on $hostname\n";
print "----------------------------------------------------------\n";

open (NEW3,"$Store/lis.txt") or die "$!";


<NEW3>;
<NEW3>;
foreach(<NEW3>)
{
@line3="";
$img_cnt2=0;
next if(/^\#/);
chomp;
@line4 = split(/\s+/,$_);
@line3=`$NB_Install_Path2/netbackup/bin/admincmd/bpimagelist -client $line4[2] -hoursago 140 -U
2>> $Store/errreport`
;
my $arrsz = @line3;
if($arrsz == 0)
{
$nobackup{$count}=$line4[2];
print "\t$nobackup{$count}\n";
$count = $count+1;

}
}
close NEW3;
print "\n";
print "Total : $count\n";

##############################################################3

exit;
sub wanted{
if(/info/)
{
open (READ,$_) or die "Can't open $_ : $!\n";
while (<READ>)
{
chomp;
if(/^ACTIVE/i)
{
@ar=split(/\s+/,$_);
if($ar[1] == 0)
{
@dir_path = split(/(\\|\/)/,$File::Find::dir);
$policy[$i] = $dir_path[$#dir_path];
++$i;
# print "$dir_path[$#dir_path]\n";
}

else
{
if($ar[1] == 1)
{
++$j;
}
}

}
}
}
}

You might also like