diff options
author | Peter Palfrader <peter@palfrader.org> | 2006-02-15 00:06:11 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2006-02-15 00:06:11 +0000 |
commit | 778467a6e7afae14541f0cbdf7fff70f8547de85 (patch) | |
tree | 7ba25682f110afe19af387c79ae7b5534aba1b52 | |
parent | acdc1bd6fa6245ac62b8bb3ca49fbf6c6c049237 (diff) |
Minor updates to raid 3ware
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@58 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-x | nagios-check-raid-3ware | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/nagios-check-raid-3ware b/nagios-check-raid-3ware index 4a37fc0..6073a78 100755 --- a/nagios-check-raid-3ware +++ b/nagios-check-raid-3ware @@ -14,7 +14,7 @@ use Getopt::Long; $ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; -my $TW_CLI = 'sudo /usr/local/bin/tw_cli'; +my $TW_CLI = '/usr/local/bin/tw_cli'; my $VERSION = '0.0.0'; # nagios exit codes @@ -24,29 +24,31 @@ my $WARNING = 1; my $CRITICAL = 2; my $params = { - controller => 0, - unit => 0 + 'no-sudo' => 0, + 'controller' => 0, + 'unit' => 0 }; Getopt::Long::config('bundling'); if (!GetOptions ( - '--help' => \$params->{'help'}, - '--version' => \$params->{'version'}, - '--verbose' => \$params->{'verbose'}, - '--controller' => \$params->{'controller'}, - '--unit' => \$params->{'unit'}, + '--help' => \$params->{'help'}, + '--version' => \$params->{'version'}, + '--verbose' => \$params->{'verbose'}, + '--controller=i' => \$params->{'controller'}, + '--unit=i' => \$params->{'unit'}, + '--no-sudo' => \$params->{'no-sudo'}, )) { - die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose]\n"); + die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose] [--no-sudo] [--controller=<n>] [--unit=<n>]\n"); }; if ($params->{'help'}) { - print "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose]\n"; + print "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose] [--no-sudo] [--controller=<n>] [--unit=<n>]\n"; print "Reports processes that are linked against libraries that no longer exist.\n"; exit (0); }; if ($params->{'version'}) { - print "nagios-check-libs $VERSION\n"; - print "nagios check for availability of debian (security) updates\n"; - print "Copyright (c) 2005 Peter Palfrader <peter\@palfrader.org>\n"; + print "nagios-check-raid-3ware $VERSION\n"; + print "nagios check for 3ware raids\n"; + print "Copyright (c) 2006 Peter Palfrader <peter\@palfrader.org>\n"; exit (0); }; @@ -55,8 +57,13 @@ $SIG{'__DIE__'} = sub { exit $UNKNOWN; }; +unless (-x $TW_CLI) { + print "Cannot find '$TW_CLI'.\n"; + exit $UNKNOWN; +}; -my $command = "$TW_CLI info c$params->{'controller'} u$params->{'unit'} status"; +my $sudo = $params->{'no-sudo'} ? '' : 'sudo '; +my $command = "$sudo $TW_CLI info c$params->{'controller'} u$params->{'unit'} status"; print STDERR "Running $command\n" if $params->{'verbose'}; open (TW, "$command|") or die ("Cannot run $command: $!\n"); my @tw=<TW>; @@ -77,16 +84,16 @@ for my $line (@tw) { exit $UNKNOWN; }; if ($status eq 'OK') { - $msg .= "$device: $status; "; + $msg .= ($msg eq '' ? '' : '; '). "$device: $status"; $exit = $exit > $OK ? $exit : $OK; } elsif ($status eq 'DEGRADED') { - $msg .= "$device: $status; "; + $msg .= ($msg eq '' ? '' : '; '). "$device: $status"; $exit = $exit > $CRITICAL ? $exit : $CRITICAL; } elsif ($status eq 'OFFLINE') { - $msg .= "$device: $status; "; + $msg .= ($msg eq '' ? '' : '; '). "$device: $status"; $exit = $exit > $CRITICAL ? $exit : $CRITICAL; } else { - $msg .= "$device: UKNOWN STATUS '$status'; "; + $msg .= ($msg eq '' ? '' : '; '). "$device: UKNOWN STATUS '$status'"; $exit = $exit > $UNKNOWN ? $exit : $UNKNOWN; }; }; |