3 # downloaded as check_areca from
4 # http://www.nagiosexchange.org/cgi-bin/page.cgi?g=1486.html;d=1
5 # on 20081001 by weasel.
7 # local changes: fix path to areca_cli
9 #####################################################
10 #Program to check the areca RAID controller for the status of the RAID
14 #Revised by: Erinn Looney-Triggs
15 #Author: Erinn Looney-Triggs
17 #1.1: Fixed issue with newer versions of the Areca CLI > 1.72 and
18 #fixed a problem where the RAID name contained spaces
19 #(Reported by Daniel Philipp). Also did a bit of cleanup.
20 #####################################################
23 use English qw( -no_match_vars );
24 use Getopt::Long; #Grab command line switches
26 use strict; #Do it right
29 $ENV{PATH} = '/usr/local/bin:/usr/bin:'; #Safer path
30 my $areca_cli = '/usr/local/sbin/areca-cli';
31 my $timeout = '10'; #Default timeout of 10 seconds
32 my $VERSION = '1.1.0'; #Version number
34 #Nagios plugin return values, in english
40 GetOptions( 'areca_cli|A=s' => \$areca_cli,
41 'man' => sub { pod2usage(3) },
42 'timeout|t=i' => \$timeout,
43 'usage' => sub { pod2usage(1) },
44 'version' => sub { VersionMessage() },
45 'help' => sub { pod2usage(1) },
49 parse_areca( check_areca() );
54 #Timer operation. Times out after $timeout seconds.
57 #Set the alarm and set the timeout
58 local $SIG{ALRM} = sub { die "alarm\n" };
62 @output = `sudo $areca_cli vsf info`;
64 print "Command: cli vsf info failed, "
65 . "$OS_ERROR $CHILD_ERROR, aborting!\n";
69 #Reset the alarm if successful
73 #Test return value and exit if eval caught the alarm
75 if ( $EVAL_ERROR eq "alarm\n" ) {
76 print "Operation timed out after $timeout seconds.\n";
80 print "An unknown error has occured: $EVAL_ERROR \n";
91 my $abnormal; #Holds count of non-normal returns
93 my @pertinent_lines = grep (/\s\d+\s/, @output);
95 for my $line (@pertinent_lines){
96 #Strip of leading spaces
99 #Split the line into discrete parts
100 my ( $number, $level, $capacity, $state, )
101 = (split (/\s+/, "$line"))[0,-4,-3,-1];
103 #If the state is normal continue on in loop
104 if (lc $state eq "normal"){
105 print "|Controller number: $number RAID level: $level "
106 . "Capacity: $capacity State: $state| ";
109 #If state is abnormal continue on in loop but add 1 to $abnormal
111 print "|Controller number: $number RAID level: $level "
112 . "Capacity: $capacity State: $state| ";
117 #If any abnormalities exist ext with a critical error.
125 return; #This should never be reached
129 if (! -e $areca_cli){
130 print "$areca_cli does not exist, aborting!\n";
133 if (! -x $areca_cli){
134 print "$areca_cli is not executable by the running user, aborting!\n";
138 return; #This should never be reached
141 #Version message information displayed in both --version and --help
142 sub main::VersionMessage {
145 This is version $VERSION of check_areca.
147 Copyright (c) 2007-2008 Erinn Looney-Triggs (erinn.looneytriggs\@gmail.com).
150 This module is free software; you can redistribute it and/or
151 modify it under the terms of the GNU General Public License.
152 See http://www.fsf.org/licensing/licenses/gpl.html
154 This program is distributed in the hope that it will be useful,
155 but WITHOUT ANY WARRANTY; without even the implied warranty of
156 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
167 check_areca - Checks the status of an Areca RAID via the Areca CLI utility.
171 This documentation refers to check_areca version 1.1.0
177 =head1 REQUIRED ARGUMENTS
183 --areca_cli (-A) Set the location of the Areca cli executable.
184 --help Display usage information.
185 --man Display the entire POD documentation
186 --timeout (-t) Sets the timeout, defaults to 10 seconds.
187 --usage Display usage information (same as --help)
188 --version Display the version number
193 This is a Nagios plugin that runs the Areca CLI to check the status of the
194 RAID controller. It then parses the resultant exit information and
195 passes the output to NRPE.
199 =head2 Command: cli vsf info failed, aborting!
201 For some reason the command trying to be run failed. Try running it by hand
202 and seeing if it runs properly.
204 =head2 Operation timed out after <timeout> seconds.
206 Running the command failed after a certain amount of time (defaults to 10
207 seconds). Try using the --timeout (-t) switch and increasing the timeout
208 threshold. Also try running the command by hand and see if it is hanging.
210 =head2 An unknown error has occurred:
212 Just what it says, running the cli command threw an unknown error and the
213 process died. Run the CLI command by hand and see if you receive proper
216 =head2 <areca cli> does not exist, aborting!
218 The binary that the script is looking to run does not exist. By default
219 check_areca looks in /usr/local/areca/bin/ for the cli. However, you can
220 change this default by setting the --areca_cli (-A) flag from the command
223 =head2 <areca cli> is not executable by the running user, aborting!
225 The cli program was found but it is not executable by the current user,
226 usually this is the nagios user.
228 =head1 CONFIGURATION AND ENVIRONMENT
230 The Areca cli program should be available on the system. By default
231 check_areca looks in /usr/local/areca/bin/cli for the cli. You can set the
232 location using the --areca_cli (-A) flag from the command line.
234 It is helpful to have an Areca RAID controller on the system being checked.
238 check_areca depends on the following modules:
239 POSIX Standard Perl 5.8 module
240 Getopt::Long Standard Perl 5.8 module
241 Pod::USAGE Standard Perl 5.8 module
243 =head1 INCOMPATIBILITIES
247 =head1 BUGS AND LIMITATIONS
249 Bugs, never heard of 'em ;).
250 If you encounter any bugs let me know. (erinn.looneytriggs@gmail.com)
254 Erinn Looney-Triggs (erinn.looneytriggs@gmail.com)
256 =head1 LICENCE AND COPYRIGHT
258 Copyright (c) 2007-2008 Erinn Looney-Triggs (erinn.looneytriggs@gmail.com).
261 This module is free software; you can redistribute it and/or
262 modify it under the terms of the GNU General Public License.
263 See L<http://www.fsf.org/licensing/licenses/gpl.html>.
265 This program is distributed in the hope that it will be useful,
266 but WITHOUT ANY WARRANTY; without even the implied warranty of
267 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.