Module: check_mk
Branch: master
Commit: d4f837b3d371b2658a95b880a8273a8629b116c3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d4f837b3d371b2…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Nov 8 08:47:17 2018 +0100
moved get_omd_config to cmk_base.config
Change-Id: I283e32a2c2ad74344f6eec03ad0d8fa1a1a2df7a
---
cmk/notification_plugins/mail.py | 19 +++----------------
cmk/site.py | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/cmk/notification_plugins/mail.py b/cmk/notification_plugins/mail.py
index a25a07b..376660b 100644
--- a/cmk/notification_plugins/mail.py
+++ b/cmk/notification_plugins/mail.py
@@ -44,6 +44,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from cmk.notification_plugins import utils
+import cmk.site as site
def tmpl_head_html(html_section):
@@ -711,7 +712,7 @@ def render_cmk_graphs(context):
svc_desc = context["SERVICEDESC"]
url =
"http://localhost:%d/%s/check_mk/ajax_graph_images.py?host=%s&service=%s" %
\
- (get_apache_port(), os.environ["OMD_SITE"],
+ (site.get_apache_port(), os.environ["OMD_SITE"],
urllib.quote(context["HOSTNAME"]),
urllib.quote(svc_desc))
try:
@@ -734,22 +735,8 @@ def render_cmk_graphs(context):
return map(base64.b64decode, base64_strings)
-def get_omd_config(key):
- for l in file(os.environ["OMD_ROOT"] + "/etc/omd/site.conf"):
- if l.startswith(key + "="):
- return l.split("=")[-1].strip("'\n")
- return None
-
-
-def get_apache_port():
- port = get_omd_config("CONFIG_APACHE_TCP_PORT")
- if port is None:
- return 80
- return int(port)
-
-
def use_cmk_graphs():
- return get_omd_config("CONFIG_CORE") == "cmc"
+ return site.get_omd_config("CONFIG_CORE") == "cmc"
def render_performance_graphs(context):
diff --git a/cmk/site.py b/cmk/site.py
new file mode 100644
index 0000000..7a62211
--- /dev/null
+++ b/cmk/site.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+import os
+
+def get_omd_config(key):
+ for l in file(os.environ["OMD_ROOT"] + "/etc/omd/site.conf"):
+ if l.startswith(key + "="):
+ return l.split("=")[-1].strip("'\n")
+ return None
+
+
+def get_apache_port():
+ port = get_omd_config("CONFIG_APACHE_TCP_PORT")
+ if port is None:
+ return 80
+ return int(port)