[icinga-checkins] icinga.org: icinga-core/fholzer/core: which accepts now a list of binary names

git at icinga.org git at icinga.org
Sat Apr 21 20:23:45 CEST 2012


Module: icinga-core
Branch: fholzer/core
Commit: 52f74c276a491354a38ef1b7f572ddf46059519a
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=52f74c276a491354a38ef1b7f572ddf46059519a

Author: Alexander Wirt <formorer at debian.org>
Date:   Sat Apr 21 10:53:51 2012 +0200

which accepts now a list of binary names

you can now ask for several binaray names to be found.
apache2 for example may be httpd (redhat) or apache2
(debian). Now you can just do:
$bin = which ('httpd', 'apache2') ) ? ( qx($bin -V))[0,2,3,5,6,7,8] : 'apache
binary not found' )

---

 tools/icinga_verification.pl |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/icinga_verification.pl b/tools/icinga_verification.pl
index cbfa792..92421f7 100644
--- a/tools/icinga_verification.pl
+++ b/tools/icinga_verification.pl
@@ -31,7 +31,7 @@ use Getopt::Long;
 
 # sub stubs
 sub get_key_from_ini ($$);
-sub which($);
+sub which(@);
 sub slurp($);
 sub get_distribution;
 
@@ -300,9 +300,11 @@ sub get_key_from_ini ($$) {
 }
 
 
-sub which ($) {
-    my $binary = shift;
-    map { -x "$_/$binary" && return "$_/$binary" } reverse(split(':', $PATH));
+sub which (@) {
+    my @binaries = @_;
+    foreach my $binary (@binaries) {
+        map { -x "$_/$binary" && return "$_/$binary" } reverse(split(':', $PATH));
+    }
     return undef;
 }
 





More information about the icinga-checkins mailing list