2 # Nagios plugin that checks LSI controllers RAID status via lsiutil program
3 # lsiutil may be found at ftp://ftp.lsil.com/HostAdapterDrivers/linux/lsiutil/
5 # Copyright (C) 2011 Emmanuel Lacour <elacour@home-dn.net>
7 # This file is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2, or (at your option) any
12 # This file is distributed in the hope that it will be
13 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this file; see the file COPYING. If not, write to the Free
19 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 use lib qw(/usr/local/lib/nagios/plugins /usr/lib/nagios/plugins);
24 use utils qw(%ERRORS);
26 my $lsiutil = '/usr/sbin/lsiutil';
27 my $status = $ERRORS{'OK'};
31 unless ( -x $lsiutil ) {
32 print "$lsiutil not found or not executable\n";
33 exit ($ERRORS{'UNKNOWN'});
37 print "This program must be run as root. You may use wrappers like sudo to do this.\n";
38 exit ($ERRORS{'UNKNOWN'});
41 $output = `$lsiutil -p 0 -a 0`;
42 for (split /^/, $output) {
43 if ( m|^\s*(\d+)\..*/proc/mpt/ioc| ) {
44 push @controllers, $1;
48 unless ( scalar @controllers ) {
49 print "No controller found\n";
50 exit ($ERRORS{'UNKNOWN'});
53 foreach my $controller ( @controllers ) {
55 $output = `$lsiutil -p $controller -a 21,3,0,0`;
56 for (split /^/, $output) {
58 if ( m/^Volume.*State/ ) {
62 unless ( scalar @volumes ) {
63 push @volumes, "No volume found";
65 foreach my $volume_status ( @volumes ) {
66 $status = $ERRORS{'CRITICAL'} unless ( $volume_status =~ /^Volume \d+ State: optimal, enabled$/ );
69 print "Ctrl $controller: ".join (' / ', @volumes)."\n";