[omd-commits] OMD Git: omd: shinken: integrate the WebUI (/<site>/shinken)

git version control git at mathias-kettner.de
Wed Dec 7 10:36:29 CET 2011


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

Author:   Gerhard Lausser <gerhard.lausser at consol.de>
Date:     Tue Dec  6 13:54:38 2011 +0100
Commiter: Gerhard Lausser <gerhard.lausser at consol.de>
Date:     Wed Dec  7 10:36:10 2011 +0100

shinken: integrate the WebUI  (/<site>/shinken)

shinken: bugfix in 501 for internet explorer

shinken: more bytes for the 512 byte IE bug

shinken: umlaut was not displayed correctly

shinken: add description for the index page

---

 packages/omd/CORE.hook                       |    6 +-
 packages/omd/img/shinken-small.png           |  Bin 0 -> 15197 bytes
 packages/omd/index.py                        |    6 ++
 packages/shinken/SHINKEN_WEBUI_TCP_PORT.hook |   78 ++++++++++++++++++++++++++
 packages/shinken/skel/etc/init.d/shinken     |   11 ++++
 5 files changed, 99 insertions(+), 2 deletions(-)

diff --git a/packages/omd/CORE.hook b/packages/omd/CORE.hook
old mode 100644
new mode 100755
index e60549c..27079a0
--- a/packages/omd/CORE.hook
+++ b/packages/omd/CORE.hook
@@ -28,7 +28,7 @@ case "$1" in
         fi
         if [ "$2" != "shinken" ]
         then
-            rm -f $OMD_ROOT/shinken
+            rm -f $OMD_ROOT/etc/apache/conf.d/shinken.conf
             rm -f $OMD_ROOT/etc/apache/conf.d/nagios.conf
             rm -f $OMD_ROOT/etc/apache/conf.d/icinga.conf
         fi
@@ -47,12 +47,14 @@ case "$1" in
         elif [ "$2" == "shinken" ]
         then
             # Thruk is the default interface, but classic is possible
-            ln -sfn ../../shinken/apache.conf $OMD_ROOT/etc/apache/conf.d/nagios.conf
+            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
         else
             rm -f $OMD_ROOT/etc/apache/conf.d/nagios.conf
             rm -f $OMD_ROOT/etc/apache/conf.d/icinga.conf
+            rm -f $OMD_ROOT/etc/apache/conf.d/shinken.conf
         fi
     ;;
 esac
diff --git a/packages/omd/img/shinken-small.png b/packages/omd/img/shinken-small.png
new file mode 100644
index 0000000..287c445
Binary files /dev/null and b/packages/omd/img/shinken-small.png differ
diff --git a/packages/omd/index.py b/packages/omd/index.py
index 9373951..672a952 100644
--- a/packages/omd/index.py
+++ b/packages/omd/index.py
@@ -124,6 +124,12 @@ def page_welcome(req):
                               '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',
+                              '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',
                               '<p>NagVis is the leading visualization addon for Nagios.</p>'
                               '<p>NagVis can be used to visualize Nagios status data, e.g.  '
diff --git a/packages/shinken/SHINKEN_WEBUI_TCP_PORT.hook b/packages/shinken/SHINKEN_WEBUI_TCP_PORT.hook
new file mode 100755
index 0000000..f65d7f5
--- /dev/null
+++ b/packages/shinken/SHINKEN_WEBUI_TCP_PORT.hook
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+# Alias: TCP port number for Apache
+# Menu: Web GUI
+# Description: 
+#  Configure the TCP port used for the Shinken WebUI
+#  process of this site. This option is only useful if 
+#  the CORE is set to "shinken" and WEBSERVER is set to "own".
+#  
+#  After changing this variable, the site-wide Apache webserver
+#  must be restarted.
+
+
+port_is_used ()
+{
+    local PORT=$1
+    ls /omd/sites/*/etc/omd/site.conf >/dev/null 2>&1 || return 1
+    for conf in /omd/sites/*/etc/omd/site.conf
+    do
+        [ $conf != /omd/sites/$OMD_SITE/etc/omd/site.conf ] || continue
+        if grep -qx "CONFIG_SHINKEN_WEBUI_TCP_PORT='$PORT'" < $conf > /dev/null 2>&1 ; then
+            return 0
+        fi
+    done
+    return 1
+}
+
+
+next_free_hook ()
+{
+    local PORT=$1
+    while port_is_used $PORT
+    do
+        PORT=$((PORT + 1))
+    done
+    echo "$PORT"
+}
+
+
+case "$1" in
+    default)
+        # Scan for a free port number by looking at the
+        # configuration of the other sites...
+        PORT=$(next_free_hook 57767)
+        echo "$PORT"
+    ;;
+    choices)
+        echo "(none)|([1-9][0-9]{0,5})|([a-zA-Z0-9\.\-]*:[1-9][0-9]{0,5})"
+    ;;
+    set)
+        if [ "$2" = "none" ]; then
+            echo 0
+        else
+            PORT=$(next_free_hook $2)
+            if [ "$PORT" != "$2" ] ; then
+                echo "WebUI port $2 is in use. I've choosen $PORT instead." >&2
+                echo "$PORT"
+            fi
+            cat <<EOF > $OMD_ROOT/etc/shinken/apache.conf
+# This file is managed by 'omd config set SHINKEN_WEBUI_TCP_PORT'.
+# Better do not edit manually
+<IfModule mod_alias.c>
+  <Location /$OMD_SITE/shinken>
+    RewriteEngine On
+    RewriteCond %{ENV:REDIRECT_STATUS} !=501
+    RewriteCond $OMD_ROOT/lib/shinken/shinken/modules/webui_broker/__init__.py -f
+    RewriteRule ^/(.*) http://%{HTTP_HOST}:$PORT [last,redirect=301]
+    RewriteRule .* http://127.0.0.1/mi/gibts/ned [last,redirect=501]
+    ErrorDocument 501 "<h1>OMD: Shinken WebUI not available</h1>You are using a distribution where the Shinken WebUI feature has been deactivated because the built-in Python interpreter is too old.<br>In order to be correctly displayed with Internet Explorer, this message must be longer than 512 bytes. <br><br>Mir san vom Woid dahoam, des kennt a jeda glei,<br>wenns von de Berge hallt, dann samma mir dabei.<br>Und wenn as Stutzerl knallt, dann samma mir um d'Weg,<br> Mir san vom Woid dahoam, da Woid is sche.<br>Mir san af Straubing zua als lust'ge Bauernknecht,<br>Weil mir uns eibült ham, des war fir uns des recht.<br>Uns hods ned g'folln do draussd, ham miassn glei hoamgeh,<br>Mir san vom Woid dahoam, da Woid is sche."
+  </Location>
+</IfModule>
+EOF
+        fi
+    ;;
+    depends)
+        [ "$CONFIG_CORE" = shinken ]
+    ;;
+esac
diff --git a/packages/shinken/skel/etc/init.d/shinken b/packages/shinken/skel/etc/init.d/shinken
old mode 100755
new mode 100644
index 4a4e953..a4e92e8
--- a/packages/shinken/skel/etc/init.d/shinken
+++ b/packages/shinken/skel/etc/init.d/shinken
@@ -42,6 +42,7 @@ SHINKEN_SCHEDULER_PORT=${CONFIG_SHINKEN_SCHEDULER_PORT:=localhost:7768}
 SHINKEN_POLLER_PORT=${CONFIG_SHINKEN_POLLER_PORT:=localhost:7771}
 SHINKEN_REACTIONNER_PORT=${CONFIG_SHINKEN_REACTIONNER_PORT:=localhost:7769}
 SHINKEN_BROKER_PORT=${CONFIG_SHINKEN_BROKER_PORT:=localhost:7772}
+SHINKEN_WEBUI_TCP_PORT=${CONFIG_SHINKEN_WEBUI_TCP_PORT:=localhost:7767}
 #
 # If it is just the port number, force localhost to be the address
 #
@@ -60,11 +61,15 @@ fi
 if [ "${SHINKEN_BROKER_PORT##*:}" = "${SHINKEN_BROKER_PORT%%:*}" ]; then
   SHINKEN_BROKER_PORT="localhost:$SHINKEN_BROKER_PORT"
 fi
+if [ "${SHINKEN_WEBUI_TCP_PORT##*:}" = "${SHINKEN_WEBUI_TCP_PORT%%:*}" ]; then
+  SHINKEN_WEBUI_TCP_PORT="localhost:$SHINKEN_WEBUI_TCP_PORT"
+fi
 SHINKEN_ARBITERD_PORT=${CONFIG_SHINKEN_ARBITER_PORT}
 SHINKEN_SCHEDULERD_PORT=${CONFIG_SHINKEN_SCHEDULER_PORT}
 SHINKEN_POLLERD_PORT=${CONFIG_SHINKEN_POLLER_PORT}
 SHINKEN_REACTIONNERD_PORT=${CONFIG_SHINKEN_REACTIONNER_PORT}
 SHINKEN_BROKERD_PORT=${CONFIG_SHINKEN_BROKER_PORT}
+SHINKEN_WEBUI_TCP_PORT=${CONFIG_SHINKEN_WEBUI_TCP_PORT}
 WEB=${CONFIG_DEFAULT_GUI:=nagios}
 LIVESTATUS_TCP=${CONFIG_LIVESTATUS_TCP:=off}
 LIVESTATUS_TCP_PORT=${CONFIG_LIVESTATUS_TCP_PORT:=6557}
@@ -148,6 +153,12 @@ EOTXT
       sed -ri 's/^([[:space:]]*modules[[:space:]]*)(.+)/\1\2,NPCD/' $TARGET_ETC/shinken-specific.d/broker.cfg
     fi
     #
+    if [ "$SHINKEN_WEBUI_TCP_PORT" != "none" ]; then
+      sed -ri 's/^([[:space:]]*modules[[:space:]]*)(.+)/\1\2,WebUI/' $TARGET_ETC/shinken-specific.d/broker.cfg
+      sed -ri 's/^([[:space:]]*host[[:space:]]*)(.+)/\1'0.0.0.0'/' $TARGET_ETC/shinken-specific.d/module_webui.cfg
+      sed -ri 's/^([[:space:]]*port[[:space:]]*)([0-9]+)/\1'${SHINKEN_WEBUI_TCP_PORT}'/' $TARGET_ETC/shinken-specific.d/module_webui.cfg
+    fi
+    #
     # Add the nsca module to the arbiter
     # uncomment this if the arbiter listens
     # leave the comments if an external nsca daemon is used



More information about the omd-commits mailing list