summaryrefslogtreecommitdiff
path: root/nagios-checks/nagios-check-raid-3ware
diff options
context:
space:
mode:
Diffstat (limited to 'nagios-checks/nagios-check-raid-3ware')
-rwxr-xr-xnagios-checks/nagios-check-raid-3ware20
1 files changed, 15 insertions, 5 deletions
diff --git a/nagios-checks/nagios-check-raid-3ware b/nagios-checks/nagios-check-raid-3ware
index 8d767b8..1dea2e8 100755
--- a/nagios-checks/nagios-check-raid-3ware
+++ b/nagios-checks/nagios-check-raid-3ware
@@ -1,6 +1,6 @@
#!/usr/bin/perl -Tw
-# Copyright (C) 2006,2008,2009 Peter Palfrader <peter@palfrader.org>
+# Copyright (C) 2006,2008,2009,2016 Peter Palfrader <peter@palfrader.org>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -35,7 +35,7 @@ $ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
my $TW_CLI = '/usr/local/bin/tw_cli';
-my $SVN_REVISION_STRING = '$Rev$';
+my $SVN_REVISION_STRING = '$Rev: 410 $';
my ($SVN_REVISION) = ($SVN_REVISION_STRING =~ /([0-9]+)/);
$SVN_REVISION = 'unknown' unless defined $SVN_REVISION;
my $VERSION = '0.0.0.'.$SVN_REVISION;
@@ -85,10 +85,20 @@ unless (-e $TW_CLI) {
exit $UNKNOWN;
};
-my $sudo = $params->{'no-sudo'} ? '' : 'sudo ';
-my $command = "$sudo $TW_CLI info c$params->{'controller'} u$params->{'unit'} status";
+for my $thing (qw{controller unit}) {
+ if ($params->{$thing} =~ m/^([0-9]+)$/) {
+ $params->{$thing} = $1;
+ } else {
+ die("Invalid $thing $1.\n");
+ }
+};
+
+my @command;
+push @command, "sudo" if $params->{'no-sudo'};
+push @command, ($TW_CLI, 'info', "c$params->{'controller'}", "u$params->{'unit'}", "status");
+my $command = join(' ', @command);
print STDERR "Running $command\n" if $params->{'verbose'};
-open (TW, "$command|") or die ("Cannot run $command: $!\n");
+open (TW, "-|", @command) or die ("Cannot run $command: $!\n");
my @tw=<TW>;
close TW;
if ($CHILD_ERROR) { # program failed