perl514 has asked for the wisdom of the Perl Monks concerning the following question:
Venerated Monks,
I want to count the size and type of devices in my Storage Array. Here is how the output looks:
00C0 Not Visible ???:? 16D:D5 2-Way Mir N/Grp'd R +W 3 00C1 Not Visible ???:? 01A:D5 2-Way Mir N/Grp'd R +W 3 00C2 Not Visible ???:? 16B:D5 2-Way Mir N/Grp'd R +W 3 01D1 Not Visible ???:? 01D:D0 RAID-5 N/Grp'd R +W 8632 01D2 Not Visible ???:? 16D:D1 RAID-5 N/Grp'd R +W 8632 059B Not Visible ???:? 02D:D7 RAID-5 N/Grp'd (M) R +W 34526 0A77 Not Visible ???:? 02C:CB 2-Way Mir N/Grp'd (M) R +W 34526 0A7B Not Visible ???:? 02C:C9 2-Way Mir N/Grp'd (M) R +W 34526 0A7F Not Visible ???:? 02C:CD 2-Way Mir N/Grp'd (M) R +W 69052 0A83 Not Visible ???:? 02C:C5 RAID-5 N/Grp'd (M) R +W 34526 0A87 Not Visible ???:? 02C:C7 RAID-5 N/Grp'd (M) R +W 34526 0A8B Not Visible ???:? 01C:DB RAID-5 N/Grp'd (M) R +W 69052 0A8F Not Visible ???:? 01C:DD RAID-5 N/Grp'd (M) R +W 69052 0DB3 Not Visible ???:? 16D:C12 BCV+R5 N/Grp'd (M) R +W 34526 0DB7 Not Visible ???:? 16D:C16 BCV+R5 N/Grp'd (M) R +W 34526
I need the output so that it tells me something like:
Total Number of 2-Way Mir Devices of 3MB = 3 Total Number of 2-Way Mir Devices of 34GB = 3 Total Number of 2-Way Mir Devices of 69GB = 1 ============================================== Total Number of RAID-5 Devices of 34GB = 4 Total Number of RAID-5 Devices of 8.6GB = 2 Total Number of RAID-5 Devices of 69GB = 2 ============================================= Total Number of BCV+R5 Devices of 34 GB = 2
====================
Update:
The output shown above is obtained by running command:
symdev -sid 1234 list -noport -noreserve|find /I "not visible"So am trying to figure out how to pass the output of this command to a Filehandle so that I can try out stuff given in the node 504596. Is that a good way to go about it?
====================
Now, thing is, in this output, there are 3 things that will vary.
1) The Type of RAID (2 Way Mir, or RAID5, Or BCV+R5, or something else).
2) The Size of Devices: This too will vary and could be different from the sizes given above.
3) the count of such type of devices.
I tried using split function, but I can get it to split on a line or a white space. Once I hold the split items in an array, I cant further split it, because the split function works in a scalar context.
Then I thought of using a hash, but from what I know, a hash can only have one value associated with a key. Is there a way to have multiple values associated with a hash key? I was planning to use 504596 as a reference to do it. Would that be the right way to go about this? Would redirecting the command output to a text file using a filehandle and then reading from it give me any advantages? I browsed through some articles, but nothing seems to make things clear for me.
I am not asking for a ready made code for this, as that will refute the very purpose of me trying to learn Perl. But I would kindly request me to guide to some pointers that will help me do it. Please help.
Perlpetually Indebted To PerlMonks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Counting devices types, device sizes and number of devices.
by Sewi (Friar) on Jan 03, 2012 at 07:12 UTC | |
by perl514 (Pilgrim) on Jan 03, 2012 at 07:36 UTC | |
by Sewi (Friar) on Jan 03, 2012 at 20:03 UTC | |
by Marshall (Canon) on Jan 06, 2012 at 17:26 UTC | |
|
Re: Counting devices types, device sizes and number of devices.
by JavaFan (Canon) on Jan 03, 2012 at 07:23 UTC | |
by Anonymous Monk on Jan 03, 2012 at 07:45 UTC | |
by jaimon (Sexton) on Jan 03, 2012 at 08:36 UTC | |
by perl514 (Pilgrim) on Jan 03, 2012 at 08:49 UTC |