Module: check_mk
Branch: master
Commit: 44a0be946cb85e8ed822bcc609491506db062e37
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=44a0be946cb85e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 27 12:52:19 2017 +0200
Fix pylint netifaces related issues
Change-Id: I0384fb880964433533347fbf677a61fa3307f8bf
---
tests/pylint/pylintrc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 83b69a0..dadd73e 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -36,7 +36,9 @@ enable=unreachable,dangerous-default-value,duplicate-key,using-constant-test,dup
# ldap
# The Python ldap module gets a lot of constants from the C API which can not be found by pylint.
# This results in a lot of these errors: "Module 'ldap' has no 'OPT_REFERRALS' member".
-ignored-modules = rrdtool,ldap
+# netifaces
+# Can not check methods / attributes of the netifaces C module
+ignored-modules = rrdtool,ldap,netifaces
[REPORTS]
output-format=cmk_colorized
Module: check_mk
Branch: master
Commit: fb90a21079f7f48e77562e2bae6646f5a2f842e1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fb90a21079f7f4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 27 12:46:26 2017 +0200
5045 FIX Custom icons and actions: Add macros for getting URL encoded values
The macros $HOSTNAME_URL_ENCODED$, $SERVICEDESC_URL_ENCODED$ and $HOSTADDRESS_URL_ENCODED$
have been added to get the values of the existing macros in URL encoded format.
Change-Id: I3981f9f41e2b85003c073fe7235d3037aa83d8fc
---
.werks/5045 | 12 ++++++++++++
web/htdocs/htmllib.py | 18 ++++++++++++++++++
web/plugins/views/painters.py | 14 ++++++++++++--
web/plugins/wato/check_mk_configuration.py | 9 +++++++--
4 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/.werks/5045 b/.werks/5045
new file mode 100644
index 0000000..f41e3b7
--- /dev/null
+++ b/.werks/5045
@@ -0,0 +1,12 @@
+Title: Custom icons and actions: Add macros for getting URL encoded values
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1501150437
+
+The macros $HOSTNAME_URL_ENCODED$, $SERVICEDESC_URL_ENCODED$ and $HOSTADDRESS_URL_ENCODED$
+have been added to get the values of the existing macros in URL encoded format.
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 482610e..34483cb 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -174,6 +174,11 @@ class Encoder(object):
# Changing from the self coded urlencode to urllib.quote
# is saving more then 90% of the total HTML generating time
# on more complex pages!
+ #
+ # TODO: Cleanup self.urlencode_vars, self.urlencode and self.urlencode_plus.
+ # urlencode_vars() should directly use urlencode or urlencode_vars and
+ # not fallback to self.urlencode on it's own. self.urlencode() should
+ # work for a single value exacly as urlencode_vars() does for multiple
def urlencode_vars(self, vars):
output = []
for varname, value in sorted(vars):
@@ -206,6 +211,16 @@ class Encoder(object):
return ret
+ # Like urllib.quote() but also replaces spaces and /
+ def urlencode_plus(self, value):
+ if type(value) == unicode:
+ value = value.encode("utf-8")
+ elif value == None:
+ return ""
+
+ return urllib.quote_plus(value)
+
+
# Escape a variable name so that it only uses allowed charachters for URL variables
def varencode(self, varname):
if varname == None:
@@ -1454,6 +1469,9 @@ class html(HTMLGenerator, RequestHandler):
def urlencode(self, value):
return self.encoder.urlencode(value)
+ def urlencode_plus(self, value):
+ return self.encoder.urlencode_plus(value)
+
# Escape a variable name so that it only uses allowed charachters for URL variables
def varencode(self, varname):
return self.encoder.varencode(varname)
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 1801e42..3bbdd64 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -387,9 +387,19 @@ def get_icons(what, row, toplevel):
def replace_action_url_macros(url, what, row):
- url = url.replace('$HOSTNAME$', row['host_name']).replace('$HOSTADDRESS$', row['host_address'])
+ macros = {
+ "HOSTNAME" : row['host_name'],
+ "HOSTADDRESS" : row['host_address'],
+ }
if what == 'service':
- url = url.replace('$SERVICEDESC$', row['service_description'])
+ macros.update({
+ "SERVICEDESC": row['service_description'],
+ })
+
+ for key, val in macros.items():
+ url = url.replace("$%s$" % key, val)
+ url = url.replace("$%s_URL_ENCODED$" % key, html.urlencode_plus(val))
+
return url
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 5341bc7..9838a09 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -643,10 +643,15 @@ register_configvar(group,
help = _('This URL is opened when clicking on the action / icon. You '
'can use some macros within the URL which are dynamically '
'replaced for each object. These are:<br>'
- '<ul><li>$HOSTNAME$: Contains the name of the host</li>'
+ '<ul>'
+ '<li>$HOSTNAME$: Contains the name of the host</li>'
+ '<li>$HOSTNAME_URL_ENCODED$: Same as above but URL encoded</li>'
'<li>$SERVICEDESC$: Contains the service description '
'(in case this is a service)</li>'
- '<li>$HOSTADDRESS$: Contains the network address of the host</li></ul>'),
+ '<li>$SERVICEDESC_URL_ENCODED$: Same as above but URL encoded</li>'
+ '<li>$HOSTADDRESS$: Contains the network address of the host</li>'
+ '<li>$HOSTADDRESS_URL_ENCODED$: Same as above but URL encoded</li>'
+ '</ul>'),
size = 80,
),
DropdownChoice(
Module: check_mk
Branch: master
Commit: 91e529a399cd1118031341d8a38eeea3104743a7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=91e529a399cd11…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 25 16:17:48 2017 +0200
5041 FIX Removed NAGVIS_URLS OMD config option
The "omd config" option NAGVIS_URL which could be used to make the NagVis icons
link to different GUIs has been removed because all CMK environments use the CMK
GUI. A hook for this is not needed.
In case you need to customize your NagVis URLs you can still do it with the
NagVis configuration.
Change-Id: I2090b5b2bc2a583ed8ace4591d8eb7c87b598e81
---
.werks/5041 | 15 ++++
omd/packages/nagvis/NAGVIS_URLS.hook | 88 ----------------------
.../nagvis/skel/etc/nagvis/conf.d/omd.ini.php | 10 ++-
3 files changed, 24 insertions(+), 89 deletions(-)
diff --git a/.werks/5041 b/.werks/5041
new file mode 100644
index 0000000..08439aa
--- /dev/null
+++ b/.werks/5041
@@ -0,0 +1,15 @@
+Title: Removed NAGVIS_URLS OMD config option
+Level: 1
+Component: packages
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1500992110
+Class: fix
+
+The "omd config" option NAGVIS_URL which could be used to make the NagVis icons
+link to different GUIs has been removed because all CMK environments use the CMK
+GUI. A hook for this is not needed.
+
+In case you need to customize your NagVis URLs you can still do it with the
+NagVis configuration.
diff --git a/omd/packages/nagvis/NAGVIS_URLS.hook b/omd/packages/nagvis/NAGVIS_URLS.hook
deleted file mode 100755
index c2d8b52..0000000
--- a/omd/packages/nagvis/NAGVIS_URLS.hook
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/bash
-
-# Alias: NagVis linked Web GUI
-# Menu: Addons
-# Description:
-# When clicking on NagVis map icons the user is redirected to another
-# Web-GUI. By default this is the classic Nagios webinterface. With
-# this switch the targeted Web-GUI can be changed.
-
-# Makes it possible to switch all the links from NagVis
-# to the default Web GUI to the choosen GUI or a defined
-# other one.
-
-case "$1" in
- default)
- echo "check_mk"
- ;;
- choices)
- echo "nagios: Classic Nagios webinterface"
- echo "check_mk: The Check_MK's Multisite GUI"
- echo "thruk: Thruk Monitoring Webinterface"
- echo "none: Use NagVis default behaviour"
- ;;
- set)
- # Skip this hook when NagVis configuration directory does not exist
- if [ ! -d $OMD_ROOT/etc/nagvis ]; then
- exit 0
- fi
-
- CFG_FILE=$OMD_ROOT/etc/nagvis/conf.d/urls.ini.php
- GUI=$2
-
- # When a user sets NAGVIS_URL to "none", previous config files are
- # deleted and the hook finishes. NagVis will use it's defaults or the
- # configuration which has been made in the NagVis configuration manually.
- if [ "$GUI" == "none" ]; then
- if [ -f $CFG_FILE ]; then
- rm $CFG_FILE
- fi
- exit 0
- fi
-
- # Previous OMD versions offered the option "auto", which is not possible
- # anymore. Behave like the default value has been selected.
- if [ "$GUI" == "auto" ]; then
- GUI=check_mk
- fi
-
- if [ ! -d $OMD_ROOT/etc/nagvis/conf.d ]; then
- mkdir -p $OMD_ROOT/etc/nagvis/conf.d
- fi
-
- if [ "$GUI" == "check_mk" ]; then
- HTMLCGI="/$OMD_SITE/check_mk"
- HOSTURL="[htmlcgi]/view.py?view_name=host&site=&host=[host_name]"
- SERVICEURL="[htmlcgi]/view.py?view_name=service&site=&host=[host_name]&service=[service_description]"
- HOSTGROUPURL="[htmlcgi]/view.py?view_name=hostgroup&site=&hostgroup=[hostgroup_name]"
- SERVICEGROUPURL="[htmlcgi]/view.py?view_name=servicegroup&site=&servicegroup=[servicegroup_name]"
- ACTION_URLS="host_downtime_url=\"\"\nhost_ack_url=\"\"\nservice_downtime_url=\"\"\nservice_ack_url=\"\"\n"
- else
- HTMLCGI="/$OMD_SITE/$GUI/cgi-bin"
- HOSTURL="[htmlcgi]/status.cgi?host=[host_name]"
- HOSTGROUPURL="[htmlcgi]/status.cgi?hostgroup=[hostgroup_name]"
- SERVICEURL="[htmlcgi]/extinfo.cgi?type=2&host=[host_name]&service=[service_description]"
- SERVICEGROUPURL="[htmlcgi]/status.cgi?servicegroup=[servicegroup_name]&style=detail"
- ACTION_URLS=""
- fi
-
- # Now write the NagVis configuration. This is a dedicated file so we can easily write it out here
- cat > $CFG_FILE <<EOF
-; <?php exit(1); ?>
-; Do not edit this file. Your changes will be overwritten.
-; This file is controlled by the OMD hook NAGVIS_URLS.
-;
-; Written by OMD hook NAGVIS_URLS at $(date).
-[paths]
-htmlcgi="$HTMLCGI"
-
-[defaults]
-hosturl="$HOSTURL"
-hostgroupurl="$HOSTGROUPURL"
-serviceurl="$SERVICEURL"
-servicegroupurl="$SERVICEGROUPURL"
-EOF
- echo -ne "$ACTION_URLS" >> $CFG_FILE
- ;;
-
-esac
diff --git a/omd/packages/nagvis/skel/etc/nagvis/conf.d/omd.ini.php b/omd/packages/nagvis/skel/etc/nagvis/conf.d/omd.ini.php
index 46ee38a..0e82a3b 100644
--- a/omd/packages/nagvis/skel/etc/nagvis/conf.d/omd.ini.php
+++ b/omd/packages/nagvis/skel/etc/nagvis/conf.d/omd.ini.php
@@ -22,10 +22,18 @@ sharedvar="###ROOT###/tmp/nagvis/share/"
profiles="###ROOT###/var/nagvis/profiles/"
htmlbase="/###SITE###/nagvis"
local_htmlbase="/###SITE###/nagvis/local"
-htmlcgi="/###SITE###/nagios/cgi-bin"
+htmlcgi="/###SITE###/check_mk"
[defaults]
backend="###SITE###"
+hosturl="[htmlcgi]/view.py?view_name=host&site=&host=[host_name]"
+hostgroupurl="[htmlcgi]/view.py?view_name=hostgroup&site=&hostgroup=[hostgroup_name]"
+serviceurl="[htmlcgi]/view.py?view_name=service&site=&host=[host_name]&service=[service_description]"
+servicegroupurl="[htmlcgi]/view.py?view_name=servicegroup&site=&servicegroup=[servicegroup_name]"
+host_downtime_url=""
+host_ack_url=""
+service_downtime_url=""
+service_ack_url=""
[backend_###SITE###]
backendtype="mklivestatus"
Module: check_mk
Branch: master
Commit: d1d115f2d626a7276640295fbb0ff0ed2b2dab42
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1d115f2d626a7…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 26 15:27:24 2017 +0200
5044 LDAP: Active Directory connection try to discover the nearest DC now
The LDAP connection of the Check_MK GUI is now using the configured LDAP
server to detect the nearest Domain Controller of the current domain. Speaking
to the nearest domain controller will increase the performance of the LDAP sync.
The discovery is done like this:
<ol>
<li>
A connection is established with the configured server. Normally this is the
DNS name of the AD domain. For this connection a "random DC" is used. In fact
the given name is locally resolved using DNS and one answered IP is picked.
</li>
<li>
The authentication with the default credentials is done.
</li>
<li>
The AD site of the local system is detected.
This is done by gathering the local IP subnets and searching the AD sites for
these subnets.
</li>
<li>
The first DC of the found AD site is used instead of "server".
</li>
</ol>
In case the detection does not work the "server" that has been handed over to this
function is used.
When you experience errors with this enable debug logging for LDAP
(Global Settings > User Interface > Logging > LDAP) and check out
the <tt>var/log/web.log</tt> for details.
Change-Id: I26781557279850f6f569ac61a17e76e1595e928a
---
.werks/5044 | 40 ++++++++++++++
web/htdocs/userdb.py | 1 +
web/htdocs/wato.py | 24 ++++++--
web/plugins/userdb/ldap.py | 133 ++++++++++++++++++++++++++++++++++++++++++---
4 files changed, 184 insertions(+), 14 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=d1d115f2d6…