From 0a2160155adf4115dbc4ad3c6ff700b52f60d957 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 8 Feb 2016 10:03:23 +0100 Subject: [PATCH] Make dsa-check-raid-3ware work with newer perls (stricter -T), and use a more modern open variant of open --- dsa-nagios-checks/checks/dsa-check-raid-3ware | 18 ++++++++++++++---- dsa-nagios-checks/debian/changelog | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dsa-nagios-checks/checks/dsa-check-raid-3ware b/dsa-nagios-checks/checks/dsa-check-raid-3ware index ccecf30..1dea2e8 100755 --- a/dsa-nagios-checks/checks/dsa-check-raid-3ware +++ b/dsa-nagios-checks/checks/dsa-check-raid-3ware @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw -# Copyright (C) 2006,2008,2009 Peter Palfrader +# Copyright (C) 2006,2008,2009,2016 Peter Palfrader # # 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=; close TW; if ($CHILD_ERROR) { # program failed diff --git a/dsa-nagios-checks/debian/changelog b/dsa-nagios-checks/debian/changelog index 0582478..c293c65 100644 --- a/dsa-nagios-checks/debian/changelog +++ b/dsa-nagios-checks/debian/changelog @@ -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 Tue, 02 Feb 2016 07:58:55 +0100 + -- Peter Palfrader Mon, 08 Feb 2016 10:03:28 +0100 dsa-nagios-checks (108) unstable; urgency=medium -- 2.20.1