Getting information from the Netapp is easy with the web interface and the command line interface. However sometimes I want information in a Excel format and I want it delivered to me in a automated easily readable format.
This was the case when I created the following Perl based script that gathers all the volume/aggregate usage information from a Netapp filer or group of Netapp filers and sends that information via SMTP in a easy to read Excel format.
The link to the script is here:
http://home.comcast.net/~schmaustech/source/netapp-aggr.zip
Sunday, February 14, 2010
Netapp Coverage Report for Symantec Netbackup
Anyone who has used Symantec Netbackup should be familiar with the coverage report script provided in the goodies directory. The script provides the ability to see what filesystems are being backed up on the clients in your Netbackup policies. The problem with the script is that it relies on accessing clients that have the Netbackup client installed on them. This works great except when it comes to NDMP backup policies for Netapps.
The reality is that the coverage report supplied does not provide details on what volume paths are being covered and which ones are being missed when using Netbackup to backup a Netapp filer. However, after being approached to write a solution to the issue, I came up with a script that provides that missing coverage information.
The script I wrote is Perl based and at this point needs to be run from a Unix/Linux master server (may work on Windows but was never tested). The script, when edited and provided with the proper parameters, will go out and gather the path information from one or more Netapp filers and then compare those hosts and paths to what you have in your Netbackup polices for NDMP backups. The results are then emailed off in an Excel formatted spreadsheet.
The script is here:
The reality is that the coverage report supplied does not provide details on what volume paths are being covered and which ones are being missed when using Netbackup to backup a Netapp filer. However, after being approached to write a solution to the issue, I came up with a script that provides that missing coverage information.
The script I wrote is Perl based and at this point needs to be run from a Unix/Linux master server (may work on Windows but was never tested). The script, when edited and provided with the proper parameters, will go out and gather the path information from one or more Netapp filers and then compare those hosts and paths to what you have in your Netbackup polices for NDMP backups. The results are then emailed off in an Excel formatted spreadsheet.
The script is here:
#!/usr/bin/perl ######################################################### # Netapp Netbackup Coverage Report # ######################################################### use strict; use Net::SSH::Perl; use Spreadsheet::WriteExcel; my @hosts = ("netapp1","netapp2"); my (@output);my $hcount = 0;my $user="root";my $password="password"; my (@netpaths,@tmpnetpaths,$host,$tmparray,$output,$name,$path,$comment,$coverage); my $subject = "Netapp_Backup_Coverage_Report"; my @emails = ('benjamin.schmaus\@schmaustech.com'); my (%saw,$scon,$errors,$exit,$netpaths,@tmparray); my ($include,$policyname,$junk,@ppaths,$ppaths,$loop); my ($emails,$mailit,$message); my $num="2"; ### Setup Excel Worksheet ### my $workbook = Spreadsheet::WriteExcel->new('/tmp/ncoverage.xls'); my $worksheet = $workbook->add_worksheet(); my $format = $workbook->add_format(); my $header = $workbook->add_format(); create_excel(); foreach $host (@hosts) { print "Gathering paths from $host...\n"; $scon = Net::SSH::Perl->new ("$host",protocol => 2); $scon->login("$user","$password"); ($output[$hcount],$errors,$exit) = $scon->cmd("cifs shares;logout telnet"); $hcount++; } foreach $output (@output) { @tmparray = split(/\n/,$output); foreach $tmparray (@tmparray) { if ($tmparray =~ /\/vol/) { ($name,$path,$comment) = split(' ',$tmparray); $path =~ tr/[A-Z]/[a-z]/; push(@tmpnetpaths,$path); } } } print "Sorting paths from Netapps...\n"; undef %saw; @saw{@tmpnetpaths} = (); @netpaths = sort keys %saw; foreach $host (@hosts) { print "Gathering backup selections from Netbackup for $host...\n"; open DATA, "/usr/openv/netbackup/bin/admincmd/bppllist -allpolicies -U -byclient $host|"; while () { chomp(); $_ =~ s/\s//g; if ($_ =~ /PolicyName/) { ($junk,$policyname) = split(/:/); } if ($_ =~ /\/vol\//) { $_ =~ s/\s//g; $_ =~ s/Include://g; $_ =~ s/\/*$//g; $_ =~ tr/[A-Z]/[a-z]/; push (@ppaths,"$policyname:$_"); } } close (DATA); } #### Reconcile time #### print "Reconcile paths...\n"; foreach $netpaths (@netpaths) { $path = $netpaths; $loop ="0"; foreach $ppaths (@ppaths) { ($policyname,$include) = split(/:/,$ppaths); if ($netpaths =~ /$include/) { $coverage="COVERED"; cell(); $loop ="1"; } } if ($loop eq "0") { $coverage="UNCOVERED"; $policyname="NONE"; cell(); } } $workbook->close(); ### Mail Off Results ### print "Mailing off results.\n"; mailit(); exit; ### Setup Excel Format Subroutine ### sub create_excel { $format->set_bold(); $format->set_size(16); $format->set_align('center'); $header->set_bold(); $header->set_align('center'); $worksheet->set_column(0, 0, 40); $worksheet->set_column(1, 1, 20); $worksheet->set_column(2, 2, 20); $worksheet->write(1, 0, 'Netapp Path', $header); $worksheet->write(1, 1, 'Netbackup Policy', $header); $worksheet->write(1, 2, 'Status', $header); $worksheet->merge_range('A1:F1','Netapp Backup Coverage Report',$format); } ### Mail Subroutine ### sub mailit { $message = `echo "'Netapp Backup Coverage Report">/tmp/ncr-body.txt`; $message = `echo "">>/tmp/ncr-body.txt`; $message = `/usr/bin/uuencode /tmp/ncoverage.xls ncoverage.xls > /tmp/ncr-attachment.txt`; $message = `cat /tmp/ncr-body.txt /tmp/ncr-attachment.txt > /tmp/ncr.txt`; foreach $emails (@emails) { $mailit = `/usr/bin/mailx -s $subject $emails < /tmp/ncr.txt`; } } sub cell { #print "NETPATH: $path\n"; $worksheet->write($num,0,$path); $worksheet->write($num,1,$policyname); $worksheet->write($num,2,$coverage); $num = $num + 1; }
Subscribe to:
Posts (Atom)