#!/usr/bin/perl
use warnings;
use strict;
use Cwd 'abs_path';
my @hostnames;
my ($identifier,$nodename);
my $symmid;
#The script will extact the servernames/pWWNs from the symmask list logins output.
while (<>)
{
if ($_=~/^Symmetrix ID/)
{
chomp ($symmid = (split /:\s+/)[1]);
}
next if $_ !~ /fibre/gi;
($identifier,$nodename)= (split /\s+/)[0,2];
if ($nodename eq "NULL")
{
$nodename=$identifier;
push @hostnames, $nodename;
}
else
{
unshift @hostnames, uc $nodename;
}
}
my $filename = "hostlist_${0}_${symmid}.txt";
unlink "$filename" if -e "$filename" && print "\nDeleting existing \"$filename\". A new one will be created.\n";
open(my $hostnamefile_fh, ">" ,"$filename" ) or die "Cannot open file.$!.$^E";
my %repeated;
my @uniqhostlist = grep {! $repeated{$_}++} sort @hostnames;
print $hostnamefile_fh "Host List for Symmetrix ID: $symmid\n";
print $hostnamefile_fh "$_\n"foreach (@uniqhostlist);
print "\n*****************************************************************************************\n";
print "Please Check the file - [ " ,abs_path($filename), " ].\n";
print "NULLs are replaced with corresponding pWWNs.\n";
print "*****************************************************************************************\n";
####
Symmetrix ID : 000190101234
Director Identification : FA-4A
Director Port : 0
User-generated Logged On
Identifier Type Node Name Port Name FCID In Fabric
---------------- ----- --------------------------------- ------ ------ ------
1000000002adf034 Fibre server011 switchport_0316 adcdef Yes Yes
1000000003bd2134 Fibre server054 switchport_0928 adcdea Yes Yes
1000000003bd216c Fibre server022 switchport_0315 adcdeb Yes Yes
1000000003bd3054 Fibre server023 switchport_0319 adcde1 Yes Yes
10000082d5316cd3 Fibre NULL NULL adcde2 No Yes
1000000000805f5d Fibre sol02 switchport_058 adcde3 Yes Yes
10000000009a1c5f Fibre server24 switchport_127 adcde4 Yes Yes
10000000009ac25d Fibre server25 switchport_126 adcde5 Yes Yes
10000000009ac25f Fibre NULL NULL adcde6 No Yes
Director Identification : FA-4A
Director Port : 1
User-generated Logged On
Identifier Type Node Name Port Name FCID In Fabric
---------------- ----- --------------------------------- ------ ------ ------
1000000002adf034 Fibre server011 switchport_0316 adcdef Yes Yes
1000000003bd2134 Fibre server054 switchport_0928 adcdea Yes Yes
1000000003bd2168 Fibre server055 switchport_0215 bd00dc Yes Yes
1000000003bd3059 Fibre server056 switchport_0219 bd00ed Yes Yes
10000082d5316cda Fibre NULL NULL 050022 No Yes
1000000000805f5b Fibre sol02 switchport_059 110a00 Yes Yes
10000000009a1c5c Fibre server57 switchport_128 110700 Yes Yes
10000000009ac251 Fibre server58 switchport_122 110800 Yes Yes
10000000009ac25f Fibre NULL NULL adcde6 No Yes
Director Identification : FA-4A
Director Port : 0
User-generated Logged On
Identifier Type Node Name Port Name FCID In Fabric
---------------- ----- --------------------------------- ------ ------ ------
1000000002adf034 Fibre server011 switchport_0316 adcdef Yes Yes
1000000003bd2134 Fibre server054 switchport_0928 adcdea Yes Yes
1000000003bd216c Fibre server087 switchport_0315 adcdeb Yes Yes
1000000003bd3054 Fibre server088 switchport_0319 adcde1 Yes Yes
10000082d5316cd3 Fibre NULL NULL adcde2 No Yes
1000000000805f5d Fibre sol02 switchport_058 adcde3 Yes Yes
10000000009a1c5f Fibre server89 switchport_127 adcde4 Yes Yes
10000000009ac25d Fibre server90 switchport_126 adcde5 Yes Yes
10000000009ac25f Fibre NULL NULL adcde6 No Yes
Director Identification : FA-4B
Director Port : 0
User-generated Logged On
Identifier Type Node Name Port Name FCID In Fabric
---------------- ----- --------------------------------- ------ ------ ------
1000000002adf034 Fibre server011 switchport_0316 adcdef Yes Yes
1000000003bd2134 Fibre server054 switchport_0928 adcdea Yes Yes
1000000003bd214a Fibre server001 switchport_0215 bd00dc Yes Yes
1000000003bd304a Fibre server012 switchport_0219 bd00ed Yes Yes
10000082d5316c4a Fibre NULL NULL 050022 No Yes
1000000000805f4a Fibre sol02 switchport_059 110a00 Yes Yes
10000000009a1c4a Fibre server13 switchport_128 110700 Yes Yes
10000000009ac24a Fibre server14 switchport_122 110800 Yes Yes
10000000009ac25f Fibre NULL NULL adcde6 No Yes
Director Identification : FA-4B
Director Port : 1
User-generated Logged On
Identifier Type Node Name Port Name FCID In Fabric
---------------- ----- --------------------------------- ------ ------ ------
1000000002adf034 Fibre server121 switchport_0316 adcdef Yes Yes
1000000003bd2134 Fibre server154 switchport_0928 adcdea Yes Yes
100000000abcd14a Fibre server101 switchport_0215 bd00dc Yes Yes
100000000abcd04a Fibre server112 switchport_0219 bd00ed Yes Yes
10000082dabcdc4a Fibre NULL NULL 050022 No Yes
100000000abcdf4a Fibre server187 switchport_059 110a00 Yes Yes
100000000abcdc4a Fibre server188 switchport_128 110700 Yes Yes
100000000abcd24a Fibre server189 switchport_122 110800 Yes Yes
10000000009ac25f Fibre NULL NULL adcde6 No Yes
##
##
C:\Users\pmu\Documents\perl\work>perl hostnames.pl test_list_logins.txt
Deleting existing "hostlist_hostnames.pl_000190101234.txt". A new one will be created.
*****************************************************************************************
Please Check the file - [ C:\Users\pmu\Documents\perl\work\hostlist_hostnames.pl_000190101234.txt ].
NULLs are replaced with corresponding pWWNs.
*****************************************************************************************
C:\Users\pmu\Documents\perl\work
##
##
C:\Users\pmu\Documents\perl\work>more hostlist_hostnames.pl_000190101234.txt
Host List for Symmetrix ID: 000190101234
10000000009ac25f
10000082d5316c4a
10000082d5316cd3
10000082d5316cda
10000082dabcdc4a
SERVER001
SERVER011
SERVER012
SERVER022
SERVER023
SERVER054
SERVER055
SERVER056
SERVER087
SERVER088
SERVER101
SERVER112
SERVER121
SERVER13
SERVER14
SERVER154
SERVER187
SERVER188
SERVER189
SERVER24
SERVER25
SERVER57
SERVER58
SERVER89
SERVER90
SOL02
C:\Users\pmu\Documents\perl\work>