Re: Optimize the script



On 7/4/08, John W. Krahn <jwkrahn@xxxxxxx> wrote:

jet speed wrote:

Hi All,


Hello,

I put togather a piece of code with some help, to capture the output as
below from a file "cxout1" as below. I am sure this can be written in few
lines or even differnt way of getting the same out put with use of hash
etc.
Kindly help me to optimize the code. Any help would be much appericated.

output from the script
---------------------------------

The Clarion Array Serial Number is CK200061101100

LUN INFO POLICY-TYPE OWNER PSEUDO DEVICE
LUN 415 policy=CLAROpt current=SP A
emcpower3a
LUN 815 policy=CLAROpt current=SP B
emcpower4a

file contents cxout1

-----------------------------

Pseudo name=emcpower3a
CLARiiON ID=CK200061101100 [JAZZ]
Logical device ID=600601601496160012288D48703EDB11 [LUN 415]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP A, current=SP A

==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats
---
### HW Path I/O Paths Interf. Mode State Q-IOs
Errors

==============================================================================
2310 pci@1c/pci@1/lpfc@4 c3t20d0s0 SP A0 active alive 0
1
2310 pci@1c/pci@1/lpfc@4 c3t21d0s0 SP A1 active alive 0
1

Pseudo name=emcpower4a
CLARiiON ID=CK200061101100 [JAZZ]
Logical device ID=6006016014961600625987643E38DB11 [LUN 815]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP B, current=SP B

==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats
---
### HW Path I/O Paths Interf. Mode State Q-IOs
Errors

==============================================================================
2310 pci@1c/pci@1/lpfc@4 c3t20d1s0 SP A0 active alive 0
1
2310 pci@1c/pci@1/lpfc@4 c3t21d1s0 SP A1 active alive 0
1



my code


[ snip code ]


This appears to work:

#!/usr/bin/perl
use warnings;
use strict;

$/ = ''; # set paragraph mode
my $filename = 'cxout1';

open FILE, '<', $filename or die "Could not open $filename: $!";

my ( @IDS, @data, %seen );
while ( <FILE> ) {
my ( $ID ) = /ID=(CK\d+)/;
push @IDS, $ID unless $seen{ $ID }++;
push @data, [ /\[(LUN\s+\d+)]/, /(policy=[^;]+);/, /\b(current=.*\S)/,
/Pseudo name=(.*\S)/ ];
}

print "\nThe Clariion Array Serial Number is @IDS\n\n";
print "LUN INFO\t POLICY-TYPE\t\t OWNER\t\t PSEUDO DEVICE\n";
for ( @data ) {
print join( "\t\t ", @$_ ), "\n";
}

__END__


So you are still running Data General hardware?


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/





Hi John,

Excellent ! Thanks, tested work's perfect.

Yes, the Hardware used to be DG, its EMC now.

Thanks again
Js


Relevant Pages

  • Re: Optimize the script
    ... below from a file "cxout1" as below. ... CLARiiON ID=CK200061101100 ... Logical device ID=600601601496160012288D48703EDB11 [LUN 415] ... Owner: default=SP B, current=SP B ...
    (perl.beginners)
  • EMC Clariion CX-400 and Solaris - critical, advice needed...
    ... We have an EMC Clariion CX-400 connected to two ... SUN-Fire 480R boxes - one runs Oracle server and uses LUN 0 on EMC, ... Tgt 1 Lun 1 to APM00023700476 is dead. ...
    (SunManagers)
  • Re: Rules of the Road for Fibre Channel Interop
    ... > identified as a DGC (Data General, creator of Clariion). ... Do you have a switch between the host and the Clarion? ... when you run a read/analyze on the LUN through format? ...
    (comp.sys.sun.hardware)
  • Re: Rules of the Road for Fibre Channel Interop
    ... > identified as a DGC (Data General, creator of Clariion). ... Do you have a switch between the host and the Clarion? ... when you run a read/analyze on the LUN through format? ...
    (comp.sys.sun.admin)