|
|
@ -1,10 +1,11 @@ |
|
|
|
#!/usr/bin/perl -w |
|
|
|
#!/usr/bin/perl -w |
|
|
|
|
|
|
|
|
|
|
|
use strict; |
|
|
|
use strict; |
|
|
|
|
|
|
|
use File::Which; |
|
|
|
use Getopt::Long; |
|
|
|
use Getopt::Long; |
|
|
|
|
|
|
|
|
|
|
|
my $slot = ''; |
|
|
|
my $slot = ''; |
|
|
|
my $hpacucli = '/usr/sbin/hpacucli'; |
|
|
|
my $cli = which('hpacucli') || which('ssacli'); |
|
|
|
my @validchecks = qw/controller array logicaldrive physicaldrive/; |
|
|
|
my @validchecks = qw/controller array logicaldrive physicaldrive/; |
|
|
|
my $check = join ',', @validchecks; |
|
|
|
my $check = join ',', @validchecks; |
|
|
|
|
|
|
|
|
|
|
@ -19,7 +20,7 @@ $0 --slot=<slot number> --check=<what to check> |
|
|
|
|
|
|
|
|
|
|
|
* slot must be a number. You can find on which slot you have controllers with the command: |
|
|
|
* slot must be a number. You can find on which slot you have controllers with the command: |
|
|
|
|
|
|
|
|
|
|
|
$hpacucli controller all show status |
|
|
|
$cli controller all show status |
|
|
|
|
|
|
|
|
|
|
|
* check is a comma separated list of item to check. Default values (without --check option) will check everything |
|
|
|
* check is a comma separated list of item to check. Default values (without --check option) will check everything |
|
|
|
Valid values are: |
|
|
|
Valid values are: |
|
|
@ -34,8 +35,8 @@ if ($slot !~ /^\d+$/){ |
|
|
|
usage(); |
|
|
|
usage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unless (-x $hpacucli){ |
|
|
|
unless (-x $cli){ |
|
|
|
die "Cannot run $hpacucli\n"; |
|
|
|
die "Cannot run $cli\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
my @checks = split /\s?,\s?/, $check; |
|
|
|
my @checks = split /\s?,\s?/, $check; |
|
|
@ -46,9 +47,9 @@ foreach my $check (@checks){ |
|
|
|
foreach my $param (@checks){ |
|
|
|
foreach my $param (@checks){ |
|
|
|
# Global controller checks |
|
|
|
# Global controller checks |
|
|
|
if ($param eq 'controller'){ |
|
|
|
if ($param eq 'controller'){ |
|
|
|
open HPACUCLI, "$hpacucli controller slot=$slot show status|" || |
|
|
|
open CLI, "$cli controller slot=$slot show status|" || |
|
|
|
die "An error occured while running $hpacucli: $!"; |
|
|
|
die "An error occured while running $cli: $!"; |
|
|
|
foreach my $line (<HPACUCLI>){ |
|
|
|
foreach my $line (<CLI>){ |
|
|
|
if ( $line =~ /Status\:\s*([\w\s]+)$/ ) { |
|
|
|
if ( $line =~ /Status\:\s*([\w\s]+)$/ ) { |
|
|
|
my $res = $1; |
|
|
|
my $res = $1; |
|
|
|
chomp($res); |
|
|
|
chomp($res); |
|
|
@ -58,12 +59,12 @@ foreach my $param (@checks){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
close HPACUCLI; |
|
|
|
close CLI; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
open HPACUCLI, "$hpacucli controller slot=$slot $param all show status|" || |
|
|
|
open CLI, "$cli controller slot=$slot $param all show status|" || |
|
|
|
die "An error occured while running $hpacucli: $!"; |
|
|
|
die "An error occured while running $cli: $!"; |
|
|
|
foreach my $line (<HPACUCLI>){ |
|
|
|
foreach my $line (<CLI>){ |
|
|
|
if ( $line =~ /^\s*$param.*:\s*(\w+[\w\s]*)$/i ) { |
|
|
|
if ( $line =~ /^\s*$param.*:\s*(\w+[\w\s]*)$/i ) { |
|
|
|
my $res = $1; |
|
|
|
my $res = $1; |
|
|
|
chomp($res); |
|
|
|
chomp($res); |
|
|
@ -73,7 +74,7 @@ foreach my $param (@checks){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
close HPACUCLI; |
|
|
|
close CLI; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|