@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-# $Id: check_emc_clariion.pl 1242 2008-06-06 10:34:50Z mstreb $
+# $Id: check_emc_clariion.pl 1315 2009-01-08 09:16:31Z mstreb $
# ------------------------------------------------------------------------------
# basic requirements
@@ -28,13 +28,14 @@
use Pod::Usage;
# predeclared subs
-use subs qw/print_help check_sp check_disk check_portstate check_hbastate/;
+use subs qw/print_help check_sp check_disk check_portstate check_hbastate check_cache check_faults/;
# predeclared vars
use vars qw (
$PROGNAME
$VERSION
$NAVICLI
+ $NAVISECCLI
%state_names
$state
@@ -44,20 +45,32 @@
$opt_verbose
$opt_help
$opt_checktype
- $opt_port
$opt_pathcount
$opt_node
+ $opt_user
+ $opt_password
$output
+ $secure
+
);
-my $dummy;
+my $output;
+
+### add some declaration in order to manage the --port option for check_portstate();
+my $opt_port;
+$opt_port=-1;
+
+# a variable in order to manage the secure mode of Navicli
+my $secure;
+$secure=0;
# Main values
$PROGNAME = basename($0);
-$VERSION = '0.9';
+$VERSION = '1.0';
$NAVICLI = '/opt/Navisphere/bin/navicli';
+$NAVISECCLI = '/opt/Navisphere/bin/naviseccli';
# Nagios exit states
our %states = (
@@ -83,8 +96,10 @@
'H=s' => \$opt_host,
'node=s' => \$opt_node,
'sp=s' => \$opt_sp,
- 't=s' => \$opt_checktype,
- 'port=s' => \$opt_port,
+ 't=s' => \$opt_checktype,
+ 'u=s' => \$opt_user,
+ 'p=s' => \$opt_password,
+ 'port=s' => \$opt_port,
'paths=s' => \$opt_pathcount
) || print_help(2);
@@ -92,6 +107,12 @@
if ($opt_help) {
print_help(2);
}
+# check if user and password for Naviseccli is given
+# If it is providen, then it passes in secure mode for the command to the array.
+# else we are staying in navicli mode
+if ( $opt_user && $opt_password ) {
+ $secure = 1;
+}
# Check if all needed options present.
if ( $opt_host && $opt_checktype ) {
@@ -102,7 +123,13 @@
if ($opt_checktype eq "disk") {
check_disk();
}
- if ($opt_checktype eq "portstate" && $opt_port ne "") {
+ if ($opt_checktype eq "cache") {
+ check_cache();
+ }
+ if ($opt_checktype eq "faults") {
+ check_faults();
+ }
+ if ($opt_checktype eq "portstate" && $opt_sp ne "") {
check_portstate();
}
if ($opt_checktype eq "hbastate" && $opt_pathcount ne "" && $opt_node ne "") {
@@ -121,7 +148,12 @@
# check_sp();
# check state of the storage processors
sub check_sp {
- open (NAVICLIOUT ,"$NAVICLI -h $opt_host getcrus |");
+ if ($secure eq 0 ) {
+ open (NAVICLIOUT ,"$NAVICLI -h $opt_host getcrus |");
+ }
+ if ($secure eq 1 ) {
+ open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getcrus |");
+ }
my $sp_line = 0;
my $error_count = 0;
while (<NAVICLIOUT>) {
@@ -183,11 +215,18 @@
# check state of the disks
sub check_disk {
my $disk_line = 0;
- my $error_count = 0;
+ my $crit_count = 0;
+ my $warn_count = 0;
+ my $hotspare_count = 0;
+ my $disk_ok_count = 0;
my ($bus,$enclosure,$disk) = 0;
$state = 'UNKNOWN';
-
- open (NAVICLIOUT ,"$NAVICLI -h $opt_host getdisk |");
+ if ($secure eq 0 ) {
+ open (NAVICLIOUT ,"$NAVICLI -h $opt_host getdisk -state |");
+ }
+ if ($secure eq 1 ) {
+ open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getdisk -state |");
+ }
while (<NAVICLIOUT>) {
# check for disk lines
if( $_ =~ m/^Bus\s(\d+)\s\w+\s(\d+)\s+\w+\s+(\d+)/) {
@@ -198,12 +237,20 @@
}
if ($disk_line == 1) {
- # check for SP lines
+ # check for States lines
if( $_ =~ m/^State:\s+(.*)$/) {
my $status = $1;
- if ($status !~ m/Enabled|Hot Spare Ready|Empty|Unbound/) {
- $output .= "Bus $bus, Enclosure $enclosure, Disk $disk,";
- $error_count++;
+ if ($status =~ m/Hot Spare Ready/) {
+ $hotspare_count++;
+ $disk_ok_count++;
+ } elsif ($status =~ m/Binding||Empty|Enabled|Expanding|Unbound|Powering Up|Ready/) {
+ $disk_ok_count++;
+ } elsif ($status =~ m/Equalizing|Rebuilding/) {
+ $warn_count++;
+ $output .= "Bus $bus, Enclosure $enclosure, Disk $disk is replaced or is being rebuilt, ";
+ } else {
+ $crit_count++;
+ $output .= "Bus $bus, Enclosure $enclosure, Disk $disk is critical, ";
}
}
}
@@ -214,13 +261,111 @@
}
}
close (NAVICLIOUT);
- if (!defined($output) && $error_count == 0) {
- $output .= "DAE: all physical disks OK";
- $state='OK';
+ if ($disk_ok_count eq 0) {
+ print "No disk were founded !\n";
+ $state = 'UNKNOWN';
+ } elsif ($crit_count > 0) {
+ $state='CRITICAL';
+ } elsif ($warn_count > 0 || $hotspare_count eq 0) {
+ $state='WARNING';
} else {
+ $state='OK';
+ }
+ $output .= $disk_ok_count." physical disks are OK. ".$hotspare_count." Hotspares are ready.";
+ print $output."\n";
+ exit $states{$state};
+}
+
+# check_cache();
+# check state of the read and write cache
+sub check_cache {
+ my $read_state = 0;
+ my $write_state = 0;
+ my $write_mirrored_state = 0;
+ my $crit_count = 0;
+ my $warn_count = 0;
+ $state = 'UNKNOWN';
+ if ($secure eq 0 ) {
+ open (NAVICLIOUT ,"$NAVICLI -h $opt_host getcache |");
+ }
+ if ($secure eq 1 ) {
+ open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getcache |");
+ }
|