Module: check_mk
Branch: master
Commit: 4b31985a880a72386c37f5c1ec81ed027372a510
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4b31985a880a72…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 30 15:46:59 2010 +0100
Added OMD apache mode detection
---
web/htdocs/htmllib.py | 6 ++++++
web/htdocs/wato.py | 29 +++++++++++++++++++++++------
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 3408052..5673a09 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -494,3 +494,9 @@ class html:
'<param name="autostart"
value="true"><param name="playcount"
value="1"></object>' % (url, url))
if config.debug:
self.write("Booom (%s)" % url)
+
+ def omd_mode(self):
+ if 'OMD_SITE' in self.req.subprocess_env and 'OMD_MODE' in
self.req.subprocess_env:
+ return (self.req.subprocess_env['OMD_MODE'],
self.req.subprocess_env['OMD_SITE'])
+ else:
+ return (None, None)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 9c8185d..020f7c8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -484,9 +484,26 @@ def parse_audit_log(what):
def check_mk_automation(command, args=[], indata=""):
- commandargs = defaults.check_mk_automation.split()
+ # Gather the command to use for executing --automation calls to check_mk
+ # - First try to use the check_mk_automation option from the defaults
+ # - When not set try to detect the command for OMD or non OMD installations
+ # - OMD 'own' apache mode or non OMD: check_mk --automation
+ # - OMD 'shared' apache mode: Full path to the binary and the defaults
+ commandargs = []
+ if defaults.check_mk_automation:
+ commandargs = defaults.check_mk_automation.split()
+ else:
+ omd_mode, omd_site = html.omd_mode()
+ if not omd_mode or omd_mode == 'own':
+ commandargs = [ 'check_mk', '--automation' ]
+ else:
+ commandargs = [ 'python',
+
'/omd/sites/'+omd_site+'/share/check_mk/modules/check_mk.py',
+ '--defaults',
'/omd/sites/'+omd_site+'/etc/check_mk/defaults',
+ '--automation' ]
+ cmd = commandargs + [ command ] + args
try:
- p = subprocess.Popen(commandargs + [ command ] + args,
+ p = subprocess.Popen(cmd,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except Exception, e:
raise MKGeneralException("Cannot execute <tt>%s</tt>: %s" %
(commandargs[0], e))
@@ -495,13 +512,13 @@ def check_mk_automation(command, args=[], indata=""):
outdata = p.stdout.read()
exitcode = p.wait()
if exitcode != 0:
- raise MKGeneralException("Error running <tt>%s %s %s</tt>:
<pre>%s</pre>" %
- (defaults.check_mk_automation, command, " ".join(args),
outdata))
+ raise MKGeneralException("Error running <tt>%s</tt>:
<pre>%s</pre>" %
+ (" ".join(cmd), outdata))
try:
return eval(outdata)
except Exception, e:
- raise MKGeneralException("Error running <tt>%s %s %s</tt>.
Invalid output from webservice (%s): <pre>%s</pre>" %
- (defaults.check_mk_automation, command, " ".join(args),
e, outdata))
+ raise MKGeneralException("Error running <tt>%s</tt>. Invalid
output from webservice (%s): <pre>%s</pre>" %
+ (" ".join(cmd), e, outdata))
def read_configuration_file():