If you have ever wondered what all the hidden options were on a Netapp filer, you are not alone. To view all the options both visible and hidden you only need to do the following:
filer>priv set advanced
filer*>registry walk options
filer>priv set advanced
filer*>registry walk options
#!/bin/bash#!/usr/bin/perl ################################################################# # This script maps fiber attached tape drives to persistently # # bind to the same device across reboots. # # (C) 2011 Benjamin Schmaus # ################################################################# use strict; my($junk,$path,$devices,$dev,$file); my(@devices,@file); my $date = `date +%m%d%Y`; $file = `/usr/bin/cp /etc/devlink.tab /etc/devlink.tab.$date`; @file = `cat /etc/devlink.tab`; @file = grep !/type=ddi_byte:tape/, @file; open (FILE,">/etc/devlink.tab.new"); print FILE @file; close (FILE); @devices = `ls -l /dev/rmt/*cbn|awk {'print \$9 \$11'}`; open (FILE,">>/etc/devlink.tab.new"); foreach $devices (@devices) { chomp($devices); ($dev,$path) = split(/\.\.\/\.\./,$devices); $dev =~ s/cbn//g; $dev =~ s/\/dev\/rmt\///g; $path =~ s/:cbn//g; ($junk,$path) = split(/st\@/,$path); print FILE "type=ddi_byte:tape;addr=$path;\trmt/$dev\\M0\n"; } close (FILE); $file = `/usr/bin/mv /etc/devlink.tab.new /etc/devlink.tab`; exit
# zlogin –z (zone)
Find the line in vfstab for the /tmp filesystem:# vi /etc/vfstab
Change the value of size=512mb to the requested value (in MB):swap - /tmp tmpfs - yes size=512mb (this could be any value, 512 is example)
Save the vfstab and exit back to the global zone.swap - /tmp tmpfs - yes size=2048mb
Log back into local zone and confirm changes by reviewing df –h output:# zoneadm –z (zone) halt
# zoneadm –z (zone) boot
# zlogin –z
# df –h|grep /tmp
swap 2.0G 0K 2.0G 0% /tmp
#!/usr/bin/perl $master="hostname of master server"; open DATA, "cat /home/schmaubj/media.list|"; while () { $mediaid = $_; chomp($mediaid); open DATA2, "/usr/openv/netbackup/bin/admincmd/bpmedialist -U -m $mediaid|"; while () { $line = $_; chomp($line); if ($line =~ /Server Host/) { ($junk,$mhost) = split(/=/,$line); chomp($mhost); $mhost =~ s/ *$//; $mhost =~ s/^ *//; } } close (DATA2); print "Media ID: $mediaid\n"; print "Media Server Host: $mhost\n"; print "Expiring now...\n"; $expire=`/usr/openv/netbackup/bin/admincmd/bpexpdate -force -d 0 -m $mediaid -host $mhost -M $master`; } close (DATA);
Usage: autovcb -v (vc server) -u (username) -p (password) -d (datacenter in vc) -os (Windows|Solaris|Linux|Suse|Redhat) -pp (netbackup policy prefix) -m (master server) -dsp (datastore name|ALL) [-pre (datastore match prefix)] [-update]
#!/usr/bin/perl ################################################################################# # Script that autodiscovers VM's and places the client name into prexisting # # policies based on the datastore names discovered # # (C) Benjamin Schmaus May, 2009 # ################################################################################# use strict; use warnings; use Socket; use VMware::VIRuntime; use VMware::VILib; use VMware::VIM25Stub; use Getopt::Long; ### Main Logic ### my $bpplclients = '/usr/openv/netbackup/bin/admincmd/bpplclients'; my ($help,$prefix,$vcserver,$username,$password,$dc,$os,$polpr,$datastorepol,$update,$master); my ($datastorepoltmp,$listds,$esxhost,$vmname,$adhostname,$ipaddress,$toolstat,$guestos,$datastore,$hostname,$junk,$junk2,$junk3,$client,$datastorefix,$polname,$gueststate); my @dslist = (); options(); print "update is set to: $update\n"; my $policy = "$polpr$datastorepol"; my $url = "https://$vcserver/sdk/vimService"; Vim::login(service_url => $url, user_name => $username, password => $password); my $datacenter_views = Vim::find_entity_views(view_type => 'Datacenter',filter => { name => $dc }); my $dcds = Vim::find_entity_view(view_type => "Datacenter", filter => {'name' => "Fridley"} ); my $ds = $dcds->datastore; if ($datastorepol eq "ALL") { getlistds(); print "\n"; } if ($update eq "0") { polrmclients(); print "\n"; } if ($datastorepol eq "ALL") { print "Discovering new clients...\n"; # go through all policies and add new clients for all datastores foreach (@dslist) { $datastorepoltmp = $_; print "\tDatastore: $datastorepoltmp\n"; print "\tPolicy: $polpr$datastorepoltmp\n"; polgetclients(); print "\t\n"; } } else { print "Discovering new clients...\n"; # go through all policies and add new clients for given datastore $datastorepoltmp = $datastorepol; print "\tCurrent Datastore: $datastorepoltmp\n"; print "\tCurrent Policy: $$polpr$datastorepoltmp\n"; polgetclients(); print "\t\n"; } print "\n\n"; Vim::logout(); exit; sub polgetclients { foreach (@$datacenter_views) { my $datacenter = $_->name; my $host_views = Vim::find_entity_views(view_type => 'HostSystem',begin_entity => $_ ); foreach (@$host_views) { $esxhost = $_->name; #print "\tESX Host Server: $esxhost\n"; my $vm_view = Vim::find_entity_views(view_type => 'VirtualMachine',begin_entity => $_ , filter => { 'guest.guestState' => 'running' }); foreach (@$vm_view) { $vmname = $_->name; $adhostname = $_->summary->guest->hostName; $ipaddress = $_->summary->guest->ipAddress; $toolstat = $_->summary->guest->toolsStatus->val; $guestos = $_->summary->guest->guestFullName; $datastore = $_->summary->config->vmPathName; $gueststate = $_->guest->guestState; ($datastorefix,$junk) = split(/\] /,$datastore); $datastorefix =~ s/\[//g; $datastorefix =~ s/ /_/g; if ($ipaddress) { $hostname = gethostbyaddr(inet_aton($ipaddress), AF_INET); #print "$ipaddress $hostname\n"; #if (!$hostname) { $hostname = '---'; } #$hostname =~ s/.asd.udlp.com/.mpls.udlp.com/g; #if (($hostname !~ /.mpls.udlp.com/) && ($hostname !~ /udlp.com/)) { # $hostname = "$hostname.mpls.udlp.com"; #} } if (!$hostname) { $hostname = '---'; } $policy = "$polpr$datastorefix"; if ($datastorefix eq $datastorepoltmp) { if ($toolstat =~ /toolsOk/) { if ($guestos =~ /$os/) { if ($hostname ne "---" && $hostname ne "localhost") { my $addtopolicy = `$bpplclients $policy -M $master -add $hostname VMware Virtual_Machine > /dev/null 2>&1`; if ($? eq "0") { print "\t\tAdded $hostname\n"; } else { print "\t\tSkipped $hostname: Already in policy\n"; } } else { print "\t\tSkipped $vmname: Reverse DNS does not exist\n"; } } else { print "\t\tSkipped $vmname: OS does not match guestos\n"; } } else { print "\t\tSkipped $vmname: Tools not okay - $toolstat\n"; } } } } } } sub polrmclients { if ($datastorepol eq "ALL") { foreach (@dslist) { $policy = "$polpr$_"; print "Removing clients from $policy...\n"; my @polrm = `$bpplclients $policy -noheader`; foreach (@polrm) { ($junk,$junk2,$client) = split(/ /,$_); chomp($client); my $remove = `$bpplclients $policy -M $master -delete $client > /dev/null 2>&1`; if ($? eq "0") { print "\t\tRemoved $client\n"; } else { print "\t\tSkipped $client: Not in policy\n"; } } } } else { $policy = "$polpr$datastorepol"; my @polrm = `$bpplclients $policy -noheader`; print "Removing clients from $policy...\n"; foreach (@polrm) { ($junk,$junk2,$client) = split(/ /,$_); chomp($client); my $remove = `$bpplclients $policy -M $master -delete $client > /dev/null 2>&1`; if ($? eq "0") { print "\t\tRemoved $client\n"; } else { print "\t\tSkipped $client: Not in policy\n"; } } } } sub getlistds { print "Getting list of datastores...\n"; my $counter = 0; foreach(@$ds) { my $ds_ref = Vim::get_view(mo_ref => $_); my $ds = $ds_ref->info->name; if (($ds =~ /$prefix/) && ($prefix ne "---")) { $dslist[$counter] = $ds_ref->info->name; $dslist[$counter] =~ s/ /_/g; $dslist[$counter] =~ s/\(|\)//g; print "\tFound datastore: $dslist[$counter]\n"; ++$counter; } elsif ($prefix eq "---") { $dslist[$counter] = $ds_ref->info->name; $dslist[$counter] =~ s/ /_/g; $dslist[$counter] =~ s/\(|\)//g; print "\tFound datastore: $dslist[$counter]\n"; ++$counter; } } } sub options { $vcserver="";$username="";$password="";$dc="";$os="";$polpr="";$master="";$update="0";$prefix="";$datastorepol=""; GetOptions ('h|help'=>\$help,'v|vcserver=s'=>\$vcserver,'u|username=s'=>\$username,'p|password=s'=>\$password,'d|datacenter=s'=>\$dc,'os=s'=>\$os,'pp|polpr=s'=>\$polpr,'m|master=s'=>\$master,'dsp=s'=>\$datastorepol,'pre|prefix=s'=>\$prefix,'update'=>\$update); if ($help) { print "Usage: autovcb -v-u -p -d -os -pp -m -dsp <(datastore name|ALL)> [-pre ] [-update]\n"; exit; } if (($vcserver eq "") || ($username eq "") || ($password eq "") || ($dc eq "") || ($os eq "") || ($polpr eq "") || ($master eq "") || ($datastorepol eq "")) { print "Missing required parameters - Type -help for options\n"; exit; } if (($prefix) && ($datastorepol ne "ALL")) { print "Cannot use prefix option when datastore is not set to ALL - Type -help for options\n"; exit; } if (($os ne "Windows") && ($os ne "Solaris") && ($os ne "Linux") && ($os ne "Suse") && ($os ne "Redhat")) { print "Incorrect OS specified - Type -help for options\n"; exit; } }
#!/usr/bin/perl ################################################################################# # Script that prints out status of VMware tools for given DataCenter # # (C) Benjamin Schmaus July, 2009 # ################################################################################# use strict; use warnings; use Socket; use VMware::VIRuntime; use VMware::VILib; use VMware::VIM25Stub; use Getopt::Long; ### Main Logic ### my ($help,$prefix,$vcserver,$username,$password,$dc); my ($esxhost,$vmname,$adhostname,$ipaddress,$toolstat,$guestos,$datastore,$gueststate); options(); my $url = "https://$vcserver/sdk/vimService"; Vim::login(service_url => $url, user_name => $username, password => $password); my $datacenter_views = Vim::find_entity_views(view_type => 'Datacenter',filter => { name => $dc }); my $dcds = Vim::find_entity_view(view_type => "Datacenter", filter => {'name' => $dc } ); my $ds = $dcds->datastore; getclients(); print "\n\n"; Vim::logout(); exit; sub getclients { foreach (@$datacenter_views) { my $datacenter = $_->name; my $host_views = Vim::find_entity_views(view_type => 'HostSystem',begin_entity => $_ ); foreach (@$host_views) { $esxhost = $_->name; my $vm_view = Vim::find_entity_views(view_type => 'VirtualMachine',begin_entity => $_ , filter => { 'guest.guestState' => 'running' }); foreach (@$vm_view) { $vmname = $_->name; #print "$vmname\n"; $adhostname = $_->summary->guest->hostName; $ipaddress = $_->summary->guest->ipAddress; $toolstat = $_->summary->guest->toolsStatus->val; $guestos = $_->summary->guest->guestFullName; $datastore = $_->summary->config->vmPathName; $gueststate = $_->guest->guestState; if ($toolstat !~ /toolsOk/) { print "TOOLS STATUS: $toolstat\tVM: $vmname\n"; } } } } } sub options { $vcserver="";$username="";$password="";$dc=""; GetOptions ('h|help'=>\$help,'v|vcserver=s'=>\$vcserver,'u|username=s'=>\$username,'p|password=s'=>\$password,'d|datacenter=s'=>\$dc); if ($help) { print "Usage: vmtoolchk.pl -v-u -p -d \n"; exit; } if (($vcserver eq "") || ($username eq "") || ($password eq "") || ($dc eq "")) { print "Missing required parameters - Type -help for options\n"; exit; } }
#!/usr/bin/perl ################################################################################# # Script that autodiscovers VM's and places the client name into prexisting # # policies based on the datastore names discovered # # (C) Benjamin Schmaus May, 2009 # ################################################################################# use strict; use warnings; use Socket; use VMware::VIRuntime; use VMware::VILib; use VMware::VIM25Stub; use Getopt::Long; my ($help,$vcserver,$username,$password,$dc,$removesnapshot,$children,$snapshotname); $children="0"; options(); my $url = "https://$vcserver/sdk/vimService"; Vim::login(service_url => $url, user_name => $username, password => $password); my $datacenter_views = Vim::find_entity_views(view_type => 'Datacenter',filter => { name => $dc }); list_snapshot(); exit; sub list_snapshot { my $datacenter_views = Vim::find_entity_views(view_type => 'Datacenter',filter => { name => $dc }); foreach (@$datacenter_views) { my $datacenter = $_->name; my $host_views = Vim::find_entity_views(view_type => 'HostSystem',begin_entity => $_ ); foreach (@$host_views) { my $esxhost = $_->name; my $vm_view = Vim::find_entity_views(view_type => 'VirtualMachine',begin_entity => $_ , filter => { 'guest.guestState' => 'running' }); foreach (@$vm_view) { my $mor_host = $_->runtime->host; my $hostname = Vim::get_view(mo_ref => $mor_host)->name; my $ref = undef; my $nRefs = 0; my $count = 0; my $snapshots = $_->snapshot; if(defined $snapshots) { Util::trace(0,"\nSnapshots for Virtual Machine ".$_->name . " under host $hostname\n"); printf "\n%-47s%-16s %s %s\n", "Name", "Date","State", "Quiesced"; print_tree ($_->snapshot->currentSnapshot, " ", $_->snapshot->rootSnapshotList); if(defined $_->snapshot) { ($ref, $nRefs) = find_snapshot_name ($_->snapshot->rootSnapshotList, $snapshotname); } if ($snapshotname =~ /$removesnapshot/) { print "Snapshot name: $snapshotname matches for delete\n"; if (defined $ref && $nRefs == 1) { my $snapshot = Vim::get_view (mo_ref =>$ref->snapshot); eval { $snapshot->RemoveSnapshot (removeChildren => $children); Util::trace(0, "\nRemove Snapshot ". $snapshotname . " For Virtual Machine ". $_->name . " under host $hostname" ." completed sucessfully\n"); }; if ($@) { if (ref($@) eq 'SoapFault') { if(ref($@->detail) eq 'InvalidState') { Util::trace(0,"\nOperation cannot be performed in the current state of the virtual machine"); } elsif(ref($@->detail) eq 'HostNotConnected') { Util::trace(0,"\nhost not connected."); } else { Util::trace(0, "\nFault: " . $@ . "\n\n"); } } else { Util::trace(0, "\nFault: " . $@ . "\n\n"); } } } else { if ($nRefs > 1) { Util::trace(0,"\nMore than one snapshot exits with name" ." $snapshotname in Virtual Machine ". $_->name ." under host ". $hostname ."\n"); } if($nRefs == 0 ) { Util::trace(0,"\nSnapshot Not Found with name" ." $snapshotname in Virtual Machine ". $_->name ." under host ". $hostname ."\n"); } } } #} else { # Util::trace(0,"\nNo Snapshot of Virtual Machine ".$_->name ." exists under host $hostname\n"); } } } } } sub options { $vcserver="";$username="";$password="";$dc="";$removesnapshot=""; GetOptions ('h|help'=>\$help,'v|vcserver=s'=>\$vcserver,'u|username=s'=>\$username,'p|password=s'=>\$password,,'d|datacenter=s'=>\$dc,'sm|snapmatch=s'=>\$removesnapshot); if ($help) { print "Usage: snapper.pl -v-u -p -d -sm \n"; exit; } if (($vcserver eq "") || ($username eq "") || ($password eq "") || ($dc eq "") || ($removesnapshot eq "")) { print "Missing required parameters - Type -help for options\n"; exit; } } sub print_tree { my ($ref, $str, $tree) = @_; my $head = " "; foreach my $node (@$tree) { $head = ($ref->value eq $node->snapshot->value) ? " " : " " if (defined $ref); my $quiesced = ($node->quiesced) ? "Y" : "N"; $snapshotname = $node->name; printf "%s%-48.48s%16.16s %s %s\n", $head, $str.$node->name, $node->createTime, $node->state->val, $quiesced; print_tree ($ref, $str . " ", $node->childSnapshotList); } return; } sub find_snapshot_name { my ($tree, $name) = @_; my $ref = undef; my $count = 0; foreach my $node (@$tree) { if ($node->name eq $name) { $ref = $node; $count++; } my ($subRef, $subCount) = find_snapshot_name($node->childSnapshotList, $name); $count = $count + $subCount; $ref = $subRef if ($subCount); } return ($ref, $count); }
#!/usr/bin/perl ######################################################### # Netapp Aggregate Report in Excel Format # ######################################################### use strict; use Net::SSH::Perl; use Spreadsheet::WriteExcel; ### Variables ### my @hosts = ("netapp1","netapp2","netapp3","netapp4"); my $user="root";my $password="pasword"; my $subject = "Netapp_Space_Utilization_Report"; my @emails = ('bschmaus\@domain.com'); my (%saw,$scon,$exit,$errors,$count,$output,$hosts,$tmparray,$aggr,$state,$value); my ($output2,$host,$flag,$vola,$volu,$volav,$aggrts,$aggrwr,$aggrsr,$aggrus,$aggrbn,$vola,$volu,$volg,$junk1,$junk2); my ($mailit,$volpu,$message,$emails,$format); my $sc1="2";my $sc2="2";my $sc3="2"; my (@output,@tmparray,$tmpaggrs,@tmpaggrs,@aggrs); ### Program Logic ### ### Setup Excel Worksheet ### my $workbook = Spreadsheet::WriteExcel->new('/tmp/netappvsr.xls'); $workbook->compatibility_mode(); my $worksheet = $workbook->add_worksheet('Aggregates'); my $worksheet = $workbook->add_worksheet('Volumes'); my $worksheet = $workbook->add_worksheet('Volume Usage in Aggregate'); my $format = $workbook->add_format(); my $header = $workbook->add_format(); create_excel(); foreach $hosts (@hosts) { print "Gathering aggregates from $hosts...\n"; $scon = Net::SSH::Perl->new ("$hosts",protocol => 2); $scon->login("$user","$password"); ($output[$count],$errors,$exit) = $scon->cmd("aggr status;logout telnet"); #print "$output[$count]\n"; $count++; } $count = 0; foreach $output (@output) { @tmparray = split(/\n/,$output); #shift(@tmparray); #pop(@tmparray); foreach $tmparray (@tmparray) { if ($tmparray =~ /aggr/) { ($aggr,$state) = split(' ',$tmparray); $value="$hosts[$count]:$aggr:$state"; push(@tmpaggrs,$value); } } $count++; } print "Sorting aggregates from Netapps...\n"; undef %saw; @saw{@tmpaggrs} = (); @aggrs = sort keys %saw; foreach (@aggrs) { ($host,$aggr,$state) = split(/:/); #print "HOST: $host AGGR: $aggr STATE: $state\n"; print "Gathering $aggr detail on $host...\n"; $scon = Net::SSH::Perl->new ("$host",protocol => 2); $scon->login("$user","$password"); ($output2,$errors,$exit) = $scon->cmd("aggr show_space -g $aggr;logout telnet"); @tmparray = split(/\n/,$output2); foreach $tmparray (@tmparray) { if (($tmparray =~ /Aggregate/) && ($tmparray =~ /\'/)) { $flag = "1"; } if (($tmparray =~ /GB/) && ( $flag eq "1" )) { ($aggrts,$aggrwr,$aggrsr,$aggrus,$aggrbn) = split(' ',$tmparray); #print "$aggrts,$aggrwr,$aggrsr,$aggrus,$aggrbn\n"; $workbook->sheets(0)->write($sc1,0,$host); $workbook->sheets(0)->write($sc1,1,$aggr); $workbook->sheets(0)->write($sc1,2,$aggrts); $workbook->sheets(0)->write($sc1,3,$aggrwr); $workbook->sheets(0)->write($sc1,4,$aggrsr); $workbook->sheets(0)->write($sc1,5,$aggrus); $sc1++; } if (($tmparray =~ /Volume/) && ($tmparray =~ /Allocated/)) { $flag="2"; } if (($tmparray =~ /vol/) && ($tmparray =~ /GB/) && ( $flag eq "2" )) { ($vola,$volu,$volg) = split(' ',$tmparray); #print "$vola,$volu,$volg\n"; $workbook->sheets(1)->write($sc2,0,$host); $workbook->sheets(1)->write($sc2,1,$vola); $workbook->sheets(1)->write($sc2,2,$volu); $workbook->sheets(1)->write($sc2,3,$volg); if ($volu eq "0GB") { $volpu = "0"; } else { $volpu = int(($volg/$volu)*100) + 1; } $workbook->sheets(1)->write($sc2,4,$volpu); $sc2++; } if (($tmparray =~ /Aggregate/) && ($tmparray =~ /Allocated/)) { $flag="3"; } if ((($tmparray =~ /Total space/) || ($tmparray =~ /Snap reserve/) || ($tmparray =~ /WAFL/)) && ($flag eq "3")) { ($junk1,$junk2,$vola,$volu,$volav) = split(/\s+/,$tmparray); #print "$junk1,$junk2,$vola,$volu,$volav\n"; $workbook->sheets(2)->write($sc3,0,$host); $workbook->sheets(2)->write($sc3,1,$aggr); if ($vola eq "0GB") { $volpu = "0"; } else { $volpu = int(($volu/$vola)*100) + 1; } if ($tmparray =~ /Total space/) { $workbook->sheets(2)->write($sc3,2,$vola); $workbook->sheets(2)->write($sc3,3,$volu); $workbook->sheets(2)->write($sc3,4,$volpu); } if ($tmparray =~ /Snap reserve/) { $workbook->sheets(2)->write($sc3,5,$vola); $workbook->sheets(2)->write($sc3,6,$volu); $workbook->sheets(2)->write($sc3,7,$volpu); } if ($tmparray =~ /WAFL/) { $workbook->sheets(2)->write($sc3,8,$vola); $workbook->sheets(2)->write($sc3,9,$volu); $workbook->sheets(2)->write($sc3,10,$volpu); $sc3++; } } } } $workbook->close(); $workbook->close(); ### Mail Off Results ### 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'); $workbook->sheets(0)->set_column(0, 5, 20); $workbook->sheets(0)->write(1, 0, 'Host', $header); $workbook->sheets(0)->write(1, 1, 'Aggregate', $header); $workbook->sheets(0)->write(1, 2, 'Total Space(GB)', $header); $workbook->sheets(0)->write(1, 3, 'WAFL Reserve(GB)', $header); $workbook->sheets(0)->write(1, 4, 'Snap Reserve(GB)', $header); $workbook->sheets(0)->write(1, 5, 'Usable Space(GB)', $header); $workbook->sheets(1)->set_column(0, 4, 20); $workbook->sheets(1)->write(1, 0, 'Host', $header); $workbook->sheets(1)->write(1, 1, 'Volume', $header); $workbook->sheets(1)->write(1, 2, 'Allocated(GB)', $header); $workbook->sheets(1)->write(1, 3, 'Used(GB)', $header); $workbook->sheets(1)->write(1, 4, '%Used', $header); $workbook->sheets(2)->set_column(0, 10, 25); $workbook->sheets(2)->write(1, 0, 'Host', $header); $workbook->sheets(2)->write(1, 1, 'Aggregate', $header); $workbook->sheets(2)->write(1, 2, 'Total Space Allocated(GB)', $header); $workbook->sheets(2)->write(1, 3, 'Total Space Used(GB)', $header); $workbook->sheets(2)->write(1, 4, '%Total Space Used', $header); $workbook->sheets(2)->write(1, 5, 'Snap Reserve Allocated(GB)', $header); $workbook->sheets(2)->write(1, 6, 'Snap Reserve Used(GB)', $header); $workbook->sheets(2)->write(1, 7, '%Snap Reserve Used', $header); $workbook->sheets(2)->write(1, 8, 'WAFL Reserved Allocated(GB)', $header); $workbook->sheets(2)->write(1, 9, 'WAFL Reserved Used(GB)', $header); $workbook->sheets(2)->write(1, 10, '%WAFL Reserved Used', $header); $workbook->sheets(0)->merge_range('A1:F1','NetApp Storage Report',$format); $workbook->sheets(1)->merge_range('A1:E1','NetApp Storage Report',$format); $workbook->sheets(2)->merge_range('A1:I1','NetApp Storage Report',$format); } ### Mail Subroutine ### sub mailit { $message = `echo "NetApp Storage Report Attached">/tmp/nvsr-body.txt`; $message = `echo "">>/tmp/nvsr-body.txt`; $message = `/usr/bin/uuencode /tmp/netappvsr.xls netappvsr.xls > /tmp/nvsr-attachment.txt`; $message = `cat /tmp/nvsr-body.txt /tmp/nvsr-attachment.txt > /tmp/nvsr.txt`; foreach $emails (@emails) { $mailit = `/usr/bin/mailx -s $subject $emails < /tmp/nvsr.txt`; } }
#!/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;
}
Install the following rpms (http://www-1.ibm.com/servers/aix/products/aixos/linux/download.html) If they are all in the same directory, you can do this by doing the following:installp -qacXgd rpm.rte rpm.rte
Packages Required:rpm -ivh --nodeps *.rpm
Download binutils and gcc binaries: binutils.2.9.1.tar.gz (http://sunsite.lanet.lv/ftp/unix/aix-binaries/uclapub/binutils/RISC/4.2/exec/) gcc.3.3.4.tar.Z (http://aixpdslib.seas.ucla.edu/packages/gcc.html)PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/samba/bin:/usr/local/samba/sbin LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/lib
**Note** Untar the binutils from the / directory so the files are placed into the proper locations. Install gcc:gzip -d binutils.2.9.1.tar.gz cp binutils.2.9.1.tar / tar -xvf binutils.2.9.1.tar rm /binutils.2.9.1.tar
**Note** Untar the binutils from the / directory so the files are placed into the proper locations. Build and install Kerberos:gzip -d gcc.3.3.4.tar.Z cp gcc.3.3.4.tar / tar -xvf gcc.3.3.4.tar rm /gcc.3.3.4.tar
Build and install OpenLDAP:gzip -d krb5-1.3.5.tar.gz tar -xvf krb5-1.3.5.tar cd krb5-1.3.5 ./configure --enable-dns --enable-dns-for-kdc --enable-dns-for-realm make make install
Build and install Samba:gzip -d openldap-2.2.18.tar.gz tar -xvf openldap-2.2.18.tar cd openldap-2.2.18 ./configure --disable-slurpd --disable-bdb --disable-slapd --without-threads make make install
Configure Kerberos:gzip -d samba-3.0.8pre2.tar.gz tar -xvf samba-3.0.8pre2.tar cd samba-3.0.8pre2 ./configure --with-winbind --with-ldap --with-ads --with-krb5=/usr/local make make install
Configure Samba: Edit /usr/local/samba/lib/smb.conf to reflect the following (substitute DOMAIN with your domain): **Note** That the shares are examples and may be different.Edit /etc/krb5.conf to reflect the following (substitute DOMAIN.COM with your domain): [logging] default = FILE:/var/log/krb5/libs.log kdc = FILE:/var/log/krb5/kdc.log admin_server = FILE:/var/log/krb5/admin.log [libdefaults] ticket_lifetime = 24000 default_realm = DOMAIN.COM forwardable = true proxiable = true dns_lookup_realm = false dns_lookup_kdc = false [realms] DOMAIN.COM = { default_domain = domain.com kdc = :88 admin_server = :749 } [domain_realm] .domain.com = DOMAIN.COM domain.com = DOMAIN.COM [kdc] profile = /var/kerberos/krb5kdc/kdc.conf [pam] debug = false ticket_lifetime = 36000 renew_lifetime = 36000 forwardable = true krb4_convert = false
**Note** Do not start Samba yet! Active Directory Integration: Obtain a kerberos ticket from your AD server by issuing the command:[global] workgroup = DOMAIN netbios name = HOSTNAME server string = HOSTNAME security = ADS realm = DOMAIN.COM password server = wins server = client use spnego = yes client signing = yes encrypt passwords = yes printcap name = cups disable spoolss = Yes show add printer wizard = No idmap uid = 15000-20000 idmap gid = 15000-20000 winbind separator = + winbind use default domain = Yes winbind enum users = yes winbind enum groups = yes template homedir = /home/%U template shell = /bin/bash use sendfile = Yes printing = cups ldap suffix = "dc=DOMAIN, dc=com" winbind cache time = 0 #Uncomment to allow these options #log level = 8 #log file = /var/log/samba.log #max log size = 5000000 #debug timestamp = yes browseable = yes obey pam restrictions = yes auth methods = winbind [homes] comment = User Home path = /home/%U force group = %U read only = No browseable = No [alpha] comment = OSCAR Alpha Code (Read/Write) path = /apps/oscar/alpha valid users = @dev, @REDHAT admin users = @dev, @REDHAT read only = No browseable = Yes [beta] comment = OSCAR Beta Code (Read Only) path = /apps/oscar/beta valid users = @dev, @REDHAT admin users = @dev, @REDHAT read only = Yes browseable = Yes [scripts] comment = OSCAR Scripts (Read Only) path = /apps/oscar/scripts valid users = @dev, @REDHAT admin users = @dev, @REDHAT read only = Yes browseable = Yes [logs] comment = OSCAR Logs (Read Only) path = /apps/logs valid users = @dev, @REDHAT admin users = @dev, @REDHAT force user = oscar force group = dev read only = Yes browseable = Yes [archive] comment = OSCAR Archive (Read Only) path = /apps/archive valid users = @dev, @REDHAT admin users = @dev, @REDHAT force user = oscar force group = dev read only = Yes browseable = Yes [apps] comment = OSCAR path = /apps valid users = @dev, @REDHAT admin users = @dev, @REDHAT read only = No browseable = Yes [public] comment = test path = /usr/local/source read only = No browseable = Yes
You will then be asked for a password. Put in the Administrator password for your Domain. To verify the ticket was issued do the following:kinit Administrator
The results should appear as follows:klist
Once you have obtained kerberos ticket you can join the computer to the domain:# klist Ticket cache: FILE:/tmp/krb5cc_0 Default principal: Administrator@DOMAIN.COM Valid starting Expires Service principal 11/03/04 14:26:23 11/04/04 00:26:22 krbtgt/DOMAIN.COM@DOMAIN.COM renew until 11/04/04 14:26:23 Kerberos 4 ticket cache: /tmp/tkt0 klist: You have no tickets cached
Now start the Samba and Winbind:net ads join
Winbind and Active Directory Authentication: First you will need to copy the WINBIND file from where is was created when you compiled Samba to /usr/lib/security:/usr/local/samba/sbin/smbd -D /usr/local/samba/sbin/nmbd -D /usr/local/samba/sbin/winbindd
Next you will need to add a stanza to the file /usr/lib/security/methods.cfg:cp /path/to/samba-3.0.8pre2/nsswitch/WINBIND /usr/lib/security
Finally you will need to edit /etc/security/users and make sure under the default stanza that SYSTEM is set to WINBIND:WINBIND: program = /usr/lib/security/WINBIND options = authonly
Test your authentication by issuing a telnet to the aix box and login using your Active Directory credentials.default: admin = false login = true su = true daemon = true rlogin = true sugroups = ALL admgroups = ttys = ALL auth1 = SYSTEM auth2 = tpath = nosak umask = 022 expires = 0 SYSTEM = "WINBIND" logintimes = pwdwarntime = 0 account_locked = false loginretries = 0 histexpire = 0 histsize = 0 minage = 0 maxage = 0 maxexpired = -1 minalpha = 0 minother = 0 minlen = 0 mindiff = 0 maxrepeats = 8 dictionlist = pwdchecks =