[omd-commits] OMD Git: omd: Fixed several problems if some packages are missing

git version control git at mathias-kettner.de
Wed Jun 20 11:03:45 CEST 2012


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

Author:   Mathias Kettner <mk at mathias-kettner.de>
Date:     Wed Jun 20 11:03:17 2012 +0200
Commiter: Mathias Kettner <mk at mathias-kettner.de>
Date:     Wed Jun 20 11:03:17 2012 +0200

Fixed several problems if some packages are missing

---

 packages/omd/CORE.hook        |   41 +++++++++++++++++++++++++++--------------
 packages/omd/DEFAULT_GUI.hook |   10 +++++-----
 packages/omd/index.py         |   16 +++++++++++++---
 3 files changed, 45 insertions(+), 22 deletions(-)

diff --git a/packages/omd/CORE.hook b/packages/omd/CORE.hook
index 29b3ef7..865363a 100755
--- a/packages/omd/CORE.hook
+++ b/packages/omd/CORE.hook
@@ -9,14 +9,27 @@
 #  as Check_MK Multisite or Thruk which can connect to other monitoring
 #  sites via Livestatus.
 
+# Helper function that creates a symlink only if the
+# target of the link exists
+make_link ()
+{
+    if [ -e "$1" ] ; then
+        ln -sfn "$1" "$2"
+    fi
+}
+
 case "$1" in
     default)
-            echo "nagios"
+            if [ -e $OMD_ROOT/bin/nagios ] ; then echo "nagios" 
+            elif [ -e $OMD_ROOT/bin/icinga ] ; then echo "icinga" 
+            elif [ -e $OMD_ROOT/bin/shinken-arbiter ] ; then echo "shinken"
+            else echo "none"
+            fi
     ;;
     choices)
-            echo "nagios: Nagios"
-            echo "icinga: Icinga"
-            echo "shinken: Shinken"
+            [ ! -e $OMD_ROOT/bin/nagios ] || echo "nagios: Nagios"
+            [ ! -e $OMD_ROOT/bin/icinga ] || echo "icinga: Icinga"
+            [ ! -e $OMD_ROOT/bin/shinken-arbiter ] || echo "shinken: Shinken"
             echo "none: No monitoring core"
     ;;
     set)
@@ -36,21 +49,21 @@ case "$1" in
         # now setup the new selection
         if [ "$2" == "nagios" ]
         then
-            ln -sfn ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf 
-            ln -sfn ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf 
-            ln -sfn nagios $OMD_ROOT/etc/init.d/core
+            make_link ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf 
+            make_link ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf 
+            make_link nagios $OMD_ROOT/etc/init.d/core
         elif [ "$2" == "icinga" ]
         then
-            ln -sfn ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf 
-            ln -sfn ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf 
-            ln -sfn icinga $OMD_ROOT/etc/init.d/core
+            make_link ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf 
+            make_link ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf 
+            make_link icinga $OMD_ROOT/etc/init.d/core
         elif [ "$2" == "shinken" ]
         then
             # Thruk is the default interface, but classic is possible
-            ln -sfn ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf
-            ln -sfn ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf 
-            ln -sfn ../../shinken/apache.conf $OMD_ROOT/etc/apache/conf.d/shinken.conf
-            ln -sfn shinken $OMD_ROOT/etc/init.d/core
+            make_link ../../nagios/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf
+            make_link ../../icinga/apache.conf $OMD_ROOT/etc/apache/conf.d/icinga.conf 
+            make_link ../../shinken/apache.conf $OMD_ROOT/etc/apache/conf.d/shinken.conf
+            make_link shinken $OMD_ROOT/etc/init.d/core
         else
             rm -f $OMD_ROOT/etc/apache/conf.d/nagios.conf
             rm -f $OMD_ROOT/etc/apache/conf.d/icinga.conf
diff --git a/packages/omd/DEFAULT_GUI.hook b/packages/omd/DEFAULT_GUI.hook
index 7821941..819bfb0 100755
--- a/packages/omd/DEFAULT_GUI.hook
+++ b/packages/omd/DEFAULT_GUI.hook
@@ -13,11 +13,11 @@ case "$1" in
     ;;
     choices)
             echo "welcome: Welcome page which lists all available GUIs"
-            echo "nagios: Classic Nagios webinterface"
-            echo "icinga: Classic Icinga webinterface"
-            echo "check_mk: The Check_MK's Multisite GUI"
-            echo "thruk: Thruk Monitoring Webinterface"
-            echo "nagvis: NagVis - The visualisation addon for Nagios"
+            [ -e $OMD_ROOT/share/nagios/htdocs ] && echo "nagios: Classic Nagios webinterface"
+            [ -e $OMD_ROOT/share/icinga/htdocs ] && echo "icinga: Classic Icinga webinterface"
+            [ -e $OMD_ROOT/share/check_mk/web ]  && echo "check_mk: The Check_MK's Multisite GUI"
+            [ -e $OMD_ROOT/share/thruk ]         && echo "thruk: Thruk Monitoring Webinterface"
+            [ -e $OMD_ROOT/share/nagvis ]        && echo "nagvis: NagVis - The visualisation addon for Nagios"
             echo "none: No default webinterface"
     ;;
     set)
diff --git a/packages/omd/index.py b/packages/omd/index.py
index 672a952..2cc68f0 100644
--- a/packages/omd/index.py
+++ b/packages/omd/index.py
@@ -102,47 +102,57 @@ def page_welcome(req):
    the default GUI of OMD.</p>
     """ % get_version(site_name(req)))
 
-    for id, title, desc in [ ('nagios', 'Classic Nagios GUI',
+    for id, title, path, desc in [ ('nagios', 'Classic Nagios GUI', 
+                              'share/nagios/htdocs',
                               'The classic Nagios GUI is based on CGI program written '
                               'in C. It retrieves its status information from <tt>status.dat</tt>. '
                               'This interface is not longer actively developed and does not perform '
                               'well in large installations.'),
                              ('check_mk', 'Check_MK Multisite',
+                              'share/check_mk/web',
                               'Check_MK Multisite is a fast and flexibile status GUI written '
                               'in Python. It supports user definable views and is able to '
                               'display the status of several sites in one combined view. It '
                               'uses MK Livestatus for getting the status data from the sites.'),
                              ('thruk', 'Thruk Monitoring Webinterface',
+                              'share/thruk',
                               'Thruk is a complete rework of the classic interface '
                               'in Perl. While maintainig the original look and feel it '
                               'brings lots of improvements and new features. Just as Multisite '
                               'it uses MK Livestatus as backend and supports the visualization '
                               'of multiple sites.'),
                              ('icinga', 'Classic Icinga GUI',
+                              'share/icinga/htdocs',
                               'Icinga\'s "classical" GUI is a derivate of the classical Nagios GUI '
                               'and has been directly evolved from the original '
                               'CGI programs in C. It has its own look and feel and brings useful '
                               'improvements. It is not bound to Icinga and can be used with the '
                               'other monitoring cores as well.'),
                              ('shinken', 'Shinken WebUI',
+                              'share/lib/shinken',
                               'Shinken enhances the ok/non-ok concept of Nagios by adding '
                               'root problems and impacts. Monitored objects also can get a rank '
                               'identifying their importance to the business.'
                               'The Shinken WebUI was designed to visualize these new concepts '
                               'and can not be used with the other monitoring cores.'),
-                             ('nagvis', 'NagVis - The visualization addon',
+                             ('nagvis', 'NagVis - The visualization addon', 
+                              'share/nagvis/htdocs',
                               '<p>NagVis is the leading visualization addon for Nagios.</p>'
                               '<p>NagVis can be used to visualize Nagios status data, e.g.  '
                               'to display IT processes like a mail system or a '
                               'network infrastructure.</p>'),
                              ('pnp4nagios', 'PNP4Nagios',
+                              'share/pnp4nagios/htdocs',
                               'PNP is an addon to Nagios which analyzes performance data '
                               'provided by plugins and stores them automatically into '
                               'RRD-databases (Round Robin Databases, see RRDTool).'),
                              ('wiki', 'DokuWiki',
+                              'share/dokuwiki/htdocs',
                               'DokuWiki is a standards compliant, simple to use Wiki, '
                               'mainly aimed at creating documentation of any kind.') ]:
-        req.write("""
+
+        if os.path.exists("/omd/sites/%s/%s" % (site_name(req), path)):
+            req.write("""
 <a class="gui" href="../%s/">
 <img src="img/%s-small.png" title="%s" />
 <h2>%s</h2>



More information about the omd-commits mailing list