[icinga-checkins] icinga.org: icinga-core/fholzer/core: Retrieve icinga version from binary

git at icinga.org git at icinga.org
Mon Apr 23 08:00:06 CEST 2012


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

Author: Alexander Wirt <formorer at debian.org>
Date:   Sun Apr 22 09:43:52 2012 +0200

Retrieve icinga version from binary

---

 tools/icinga_verification.pl |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/tools/icinga_verification.pl b/tools/icinga_verification.pl
index 3751098..bfbe75d 100644
--- a/tools/icinga_verification.pl
+++ b/tools/icinga_verification.pl
@@ -35,6 +35,7 @@ sub which(@);
 sub slurp($);
 sub get_distribution;
 sub find_icinga_dir;
+sub get_icinga_version($);
 
 ################################
 # Option parsing
@@ -133,6 +134,9 @@ my $mysqlver =
 
 # distribution
 my $distribution = get_distribution();
+
+# icinga version
+my $icingaversion = get_icinga_version();
 ################################
 # Icinga Checks
 ################################
@@ -268,6 +272,7 @@ PHP Information: $phpversion
 MySQL Information:
  $mysqlver
 Icinga Informations:
+ icinga version: $icingaversion
  idomod Connections: $idocheck
  Icinga DB-Version: $result_icingadb[0]
  ido2db last Connection Info:
@@ -365,3 +370,18 @@ sub find_icinga_dir {
     }
     return undef;
 }
+
+sub get_icinga_version {
+    if (which('icinga')) {
+        open( my $fh, '-|', "icinga --help" );
+        while (my $line = <$fh>) {
+            if ($line =~ /^Icinga (.*)/) {
+                return $1;
+            }
+        }
+        close($fh);
+    } else {
+        return 'icinga binary not found in PATH';
+    }
+}
+}





More information about the icinga-checkins mailing list