[omd-commits] OMD Git: omd: nagvis tests: Added code to autodetect NagVis version

git version control git at mathias-kettner.de
Sun Jul 10 03:03:57 CEST 2011


Module:   omd
Branch:   master
Commit:   67f5dc880c1b9723eb5cf1664720ff93b1ccf4bd
URL:      http://omdistro.org/projects/omd/repository/revisions/67f5dc880c1b9723eb5cf1664720ff93b1ccf4bd

Author:   Lars Michelsen <lm at mathias-kettner.de>
Date:     Sun Jul 10 03:02:29 2011 +0200
Commiter: Lars Michelsen <lm at mathias-kettner.de>
Date:     Sun Jul 10 03:02:29 2011 +0200

nagvis tests: Added code to autodetect NagVis version

---

 t/20-package_nagvis.t |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/t/20-package_nagvis.t b/t/20-package_nagvis.t
index 31e5d61..1e5ac41 100644
--- a/t/20-package_nagvis.t
+++ b/t/20-package_nagvis.t
@@ -19,8 +19,7 @@ plan( tests => 232 );
 my $omd_bin = TestUtils::get_omd_bin();
 my $site    = TestUtils::create_test_site() or TestUtils::bail_out_clean("no further testing without site");
 my $auth    = 'OMD Monitoring Site '.$site.':omdadmin:omd';
-# Create code to find this out
-my $version = '1.5.9';
+my $version = site_nagvis_version($site);
 
 #TestUtils::test_command({ cmd => "/d1/nagvis/mache" });
 
@@ -301,3 +300,28 @@ sub site_mtime {
     my $path = shift;
     return (stat '/omd/sites/'.$site.'/'.$path)[9];
 }
+
+=head2 site_nagvis_version
+
+    Returns version string for the sites NagVis version. It takes the
+    local/ path installations into account.
+
+=cut
+sub site_nagvis_version {
+    my $site = shift;
+    my $version = '';
+    my $path;
+    if(-e '/omd/sites/' . $site .  '/local/share/nagvis/htdocs/server/core/defines/global.php') {
+        $path = '/omd/sites/' . $site .  '/local/share/nagvis/htdocs/server/core/defines/global.php';
+    } else {
+        $path = '/omd/sites/' . $site .  '/share/nagvis/htdocs/server/core/defines/global.php';
+    }
+    open FILE, $path or die("Could not open file.");
+    foreach my $line (<FILE>) {
+        if($line =~ m/^define\('CONST_VERSION', '([^']*)'/) {
+            $version = $1;
+        }
+    }
+    close(FILE);
+    return $version;
+}



More information about the omd-commits mailing list