Make dsa-check-raid-3ware work with newer perls (stricter -T), and use a more modern...
authorPeter Palfrader <peter@palfrader.org>
Mon, 8 Feb 2016 09:03:23 +0000 (10:03 +0100)
committerPeter Palfrader <peter@palfrader.org>
Mon, 8 Feb 2016 09:03:35 +0000 (10:03 +0100)
dsa-nagios-checks/checks/dsa-check-raid-3ware
dsa-nagios-checks/debian/changelog

index ccecf30..1dea2e8 100755 (executable)
@@ -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
@@ -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
index 0582478..c293c65 100644 (file)
@@ -16,6 +16,7 @@ dsa-nagios-checks (108+XXXX) UNRELEASED; urgency=medium
   * dsa-check-backuppg: allow specifying which timeline we expect a database
     to be on.
   * dsa-check-cert-expire-dir: add
+  * dsa-check-raid-3ware: modernize
 
   [ Tollef Fog Heen ]
   * dsa-update-unowned-file-status: ignore fdescfs, used for /dev/fd on
@@ -28,7 +29,7 @@ dsa-nagios-checks (108+XXXX) UNRELEASED; urgency=medium
   * Add dsa-check-hpssacli, replaces hpacucli for new hosts.
   * dsa-check-hpssacli: accept 12.0Gbps as transfer speed for SAS
 
- -- Peter Palfrader <weasel@debian.org>  Tue, 02 Feb 2016 07:58:55 +0100
+ -- Peter Palfrader <weasel@debian.org>  Mon, 08 Feb 2016 10:03:28 +0100
 
 dsa-nagios-checks (108) unstable; urgency=medium