Module: check_mk
Branch: master
Commit: e61d685f87f5019d5ae1fd7a7379b5fdff35800b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e61d685f87f501…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Nov 3 16:37:48 2010 +0100
MKP's under OMD also honor multisite extensions
---
web/.f12 | 4 +---
web/htdocs/.f12 | 1 +
web/htdocs/config.py | 7 +++++++
web/htdocs/index.py | 9 ++++++++-
web/htdocs/sidebar.py | 6 ++++++
web/htdocs/views.py | 7 +++++++
web/plugins/views/perfometer.py | 6 ++++++
7 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/web/.f12 b/web/.f12
index 70026e4..27c68e1 100644
--- a/web/.f12
+++ b/web/.f12
@@ -1,4 +1,2 @@
-sudo rsync -varx --delete --exclude=defaults.py htdocs plugins /usr/share/check_mk/web/
-sudo /etc/init.d/apache2 restart
-#sudo /etc/init.d/apache2 reload
+sudo cp -prv * /omd/versions/default/share/check_mk/web/
diff --git a/web/htdocs/.f12 b/web/htdocs/.f12
new file mode 100644
index 0000000..6c63611
--- /dev/null
+++ b/web/htdocs/.f12
@@ -0,0 +1 @@
+sudo cp -v *.py /omd/versions/default/share/check_mk/web/htdocs
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 89eb3cc..76057d7 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -38,6 +38,13 @@ except NameError:
# Base directory of dynamic configuration
config_dir = defaults.var_dir + "/web"
+# Detect if we are running on OMD
+try:
+ defaults.omd_site
+except:
+ defaults.omd_site = None
+ defaults.omd_root = None
+
def load_config():
# reset settings which can be changed at runtime to
# default values. Otherwise they stick to their changed
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index 15c56cd..27c781b 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -25,7 +25,7 @@
# Boston, MA 02110-1301 USA.
from mod_python import apache,util
-import os, livestatus
+import os, sys, livestatus
from lib import *
import config, htmllib, defaults
@@ -35,6 +35,13 @@ pagehandlers_dir = defaults.web_dir + "/plugins/pages"
for fn in os.listdir(pagehandlers_dir):
if fn.endswith(".py"):
execfile(pagehandlers_dir + "/" + fn)
+if defaults.omd_root:
+ sys.path.append(defaults.omd_root + "/local/share/check_mk/web/htdocs")
+ local_pagehandlers_dir = defaults.omd_root +
"/local/share/check_mk/web/plugins/pages"
+ if os.path.exists(local_pagehandlers_dir):
+ for fn in os.listdir(local_pagehandlers_dir):
+ if fn.endswith(".py"):
+ execfile(local_pagehandlers_dir + "/" + fn)
def read_get_vars(req):
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 8dec507..7a3b348 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -37,6 +37,12 @@ snapins_dir = defaults.web_dir + "/plugins/sidebar"
for fn in os.listdir(snapins_dir):
if fn.endswith(".py"):
execfile(snapins_dir + "/" + fn)
+if defaults.omd_root:
+ local_snapins_dir = defaults.omd_root +
"/local/share/check_mk/web/plugins/sidebar"
+ if os.path.exists(local_snapins_dir):
+ for fn in os.listdir(local_snapins_dir):
+ if fn.endswith(".py"):
+ execfile(local_snapins_dir + "/" + fn)
# Declare permissions: each snapin creates one permission
config.declare_permission_section("sidesnap", "Sidebar snapins")
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 37a7be0..c3f147b 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -172,6 +172,12 @@ plugins_path = defaults.web_dir + "/plugins/views"
for fn in os.listdir(plugins_path):
if fn.endswith(".py"):
execfile(plugins_path + "/" + fn)
+if defaults.omd_root:
+ local_plugins_path = defaults.omd_root +
"/local/share/check_mk/web/plugins/views"
+ if os.path.exists(local_plugins_path):
+ for fn in os.listdir(local_plugins_path):
+ if fn.endswith(".py"):
+ execfile(local_plugins_path + "/" + fn)
# Declare permissions for builtin views
config.declare_permission_section("view", "Builtin views")
@@ -816,6 +822,7 @@ def create_view():
def page_view(h):
global html
html = h
+
load_views()
view_name = html.var("view_name")
view = html.available_views.get(view_name)
diff --git a/web/plugins/views/perfometer.py b/web/plugins/views/perfometer.py
index 9bfd5f3..99564e7 100644
--- a/web/plugins/views/perfometer.py
+++ b/web/plugins/views/perfometer.py
@@ -65,6 +65,12 @@ perfometer_plugins_dir = defaults.web_dir +
"/plugins/perfometer"
for fn in os.listdir(perfometer_plugins_dir):
if fn.endswith(".py"):
execfile(perfometer_plugins_dir + "/" + fn)
+if defaults.omd_root:
+ local_perfometer_plugins_dir = defaults.omd_root +
"/local/share/check_mk/web/plugins/perfometer"
+ if os.path.exists(local_perfometer_plugins_dir):
+ for fn in os.listdir(local_perfometer_plugins_dir):
+ if fn.endswith(".py"):
+ execfile(local_perfometer_plugins_dir + "/" + fn)
def paint_perfometer(row):