Skip to content

Instantly share code, notes, and snippets.

@bigpresh
Created November 22, 2013 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigpresh/7602185 to your computer and use it in GitHub Desktop.
Save bigpresh/7602185 to your computer and use it in GitHub Desktop.
#!/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