Created
November 22, 2013 15:56
-
-
Save bigpresh/7602185 to your computer and use it in GitHub Desktop.
Test case for https://github.com/bigpresh/misc-scripts/issues/2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $arrayinfo = <<'ARRAYINFO'; | |
Copyright (c) 2010 LSI | |
LSI/3ware CLI (version 2.00.11.016) | |
//monitor> info c0 | |
Unit UnitType Status %RCmpl %V/I/M Stripe Size(GB) Cache AVrfy | |
------------------------------------------------------------------------------ | |
u0 RAID-1 OK - - - 232.82 OFF ON | |
Port Status Unit Size Blocks Serial | |
--------------------------------------------------------------- | |
p0 NOT-PRESENT - - - - | |
p1 NOT-PRESENT - - - - | |
p2 OK u0 232.88 GB 488397168 5ND2AL5B | |
p3 OK u0 232.88 GB 488397168 5ND2AL5V | |
ARRAYINFO | |
for my $line (split /\n/, $arrayinfo) { | |
if (my ($unit, $type, $status, $completion, $completion2, $size) = | |
$line =~ m{^ | |
(u\d+) \s+ # Logical unit (array) | |
(RAID-\d+) \s+ # RAID type | |
(\S+) \s+ # Status | |
(\S+) \s+ # Completion percentage or - | |
(\S+) \s+ # Completion percentage or - | |
\S+ \s+ # Stripe (don't care) | |
(\S+) # Size | |
}x) | |
{ | |
printf "%s is %s GB (%s GB rounded)\n", | |
$unit, $size, int $size; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment