I’ve developed a prototype of Perl script using various functions available in the blogs and net. I’ve customized to get total capacity of LUNs allocated allocated to each IG.
Caveats:
- PERL and modules are required to run the script.
- Installation of Perl is not required but need to copy required files and set environment variables
- A text file by name sids.txt having last 4 digits of VMAX SID need to be created and stored in same folder of script file
- How to run the script? “ goto CMD > (cd to source folder) > perl (script_name) > (file_name).csv
- Total capacity is in GB which can be later modified manually according to our need
<Script>
use XML::Simple;
use Data::Dumper;
use Getopt::Std;
use Diagnostics;
sub refToList {
# when we have one item in a list in the XML, it
# gets parsed as a scalar instead of an array. So we sometimes
# want to be able to force that to be one item list to make
# coding easier.
#
# This is complicated, so I’ll break it down:
# @_ is the array of parameters to the function.
# @_[0] is the first parameter, which in this case is a reference
# The ref test then checks to see whether that reference is to a scalar
# or is a reference to an array.
my @list;
my $item;
if ( ref (@_[0]) eq “ARRAY” ) {
# The first parameter is a reference to an array. But what I want
# is the array itself, not the reference to it. So that is what the @{} gets me.
#@list=@{@_[0]};
foreach $item (@{@_[0]}) {
if ($item ne “”) {
push (@list, $item);
};
};
} else {
# the reference is to a scalar, and that is easier to decode. I then turn
# it into an array.
my ($item)=(@_);
@list=($item);
};
# and now I return the array.
return @list;
};
sub getIgList() {
open (IN, “sids.txt”) or die “$!\n”;
my @data = <IN>;
foreach my $line(@data)
{
chomp ($line);
my $sid = $line;
print “Report for VMAX $sid \n”;
print “IG_NAME\tTotalCapacity in GB\n”;
my $xml = new XML::Simple (KeyAttr=>[]);
my $xml1 = new XML::Simple (KeyAttr=>[]);
$verbose && print STDERR “list -type initiator…\n”;
my $cmdout=`symaccess -sid $sid list -type init -output XML 2> c:/temp/temp.txt`;
$cmdout || die “ERROR in getIgList: symaccess list -type init -output XML \n”;
my $sym=$xml->XMLin($cmdout);
my @iglist=refToList ($sym->{Symmetrix}{Initiator_Group});
my $ig;
my %igdb;
my $name;
my $cap;
my $totcap;
my $sumcap=0;
my $i=0;
foreach $ig (@iglist) {
$name=$ig->{Group_Info}{group_name};
$igdb{$name}=””;
print “$name \t”;
my $igout=`symaccess -sid $sid list devinfo -ig $name | find /i “Total Capacity” 2> c:/temp/temp.txt`;
chomp($igout);
$sumcap=substr($igout,40,70);
chomp ($sumcap);
if ($sumcap != 0) {
$totcap=($sumcap/1024);
printf ‘%.2f’,$totcap;
print”\n”;
}
}
print “End of report for VMAX $sid\n”;
}
};
#return %igdb;
getIgList();
</script>
Very gud and useful , can i have your e-mail id and contact number please,
Thanks inadvance
Nagaraj