From 779403eba5a4a72684b9455105bae6170b7c7a7d Mon Sep 17 00:00:00 2001 From: fredricj Date: Wed, 18 Jan 2017 17:17:38 +0100 Subject: [PATCH] - Add ssacli as an alias to hpssacli in new naming scheme - Rewrite check of executable to not hardcode each combination --- plugins-scripts/HP/Proliant.pm | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/plugins-scripts/HP/Proliant.pm b/plugins-scripts/HP/Proliant.pm index 95a7a34..d5c6270 100755 --- a/plugins-scripts/HP/Proliant.pm +++ b/plugins-scripts/HP/Proliant.pm @@ -341,19 +341,16 @@ EOEO if ($self->{runtime}->{options}->{hpacucli}) { #1 oder 0. pfad selber finden my $hpacucli = undef; - if (-e '/usr/sbin/hpssacli') { - $hpacucli = '/usr/sbin/hpssacli'; - } elsif (-e '/usr/local/sbin/hpssacli') { - $hpacucli = '/usr/local/sbin/hpssacli'; - } elsif (-e '/usr/sbin/hpacucli') { - $hpacucli = '/usr/sbin/hpacucli'; - } elsif (-e '/usr/local/sbin/hpacucli') { - $hpacucli = '/usr/local/sbin/hpacucli'; - } elsif (-e '/usr/sbin/hpssacli') { - $hpacucli = '/usr/sbin/hpssacli'; - } elsif (-e '/usr/local/sbin/hpssacli') { - $hpacucli = '/usr/local/sbin/hpssacli'; - } else { + CLIEXECTEST: + foreach my $cliexec (qw(ssacli hpssacli hpacucli)) { + foreach my $clipaths (qw(/usr/sbin/ /usr/local/sbin/ /sbin/)) { + if (-e $clipaths . $cliexec) { + $hpacucli = $clipaths . $cliexec; + last CLIEXECTEST; + } + } + } + if (! defined $hpacucli) { $hpacucli = $hpasmcli; $hpacucli =~ s/^sudo\s*//; $hpacucli =~ s/hpasmcli/hpacucli/;