Module: check_mk
Branch: master
Commit: c9d80c57de83b69bb49f5c25186a49b3cee58aef
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c9d80c57de83b6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 17 11:15:03 2014 +0100
#1766 FIX Fixed exceptions in Web GUI when host or service groups used non ascii characters in names
It is possible to define host and service groups which contain non ascii characters (e.g. umlauts)
in their names. This is only possible to configure via config files, not via WATO for the moment.
These groups lead to exceptions in the Web GUI, which has been fixed now.
---
.werks/1766 | 12 ++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 4 ++--
web/htdocs/htmllib.py | 17 ++++++++++++-----
web/htdocs/valuespec.py | 7 +++++++
5 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/.werks/1766 b/.werks/1766
new file mode 100644
index 0000000..7b6c1b6
--- /dev/null
+++ b/.werks/1766
@@ -0,0 +1,12 @@
+Title: Fixed exceptions in Web GUI when host or service groups used non ascii characters in names
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1418811123
+
+It is possible to define host and service groups which contain non ascii characters (e.g. umlauts)
+in their names. This is only possible to configure via config files, not via WATO for the moment.
+These groups lead to exceptions in the Web GUI, which has been fixed now.
diff --git a/ChangeLog b/ChangeLog
index cf01f4c..60b0076 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@
* 1758 Improved exception hander: Shows details without additional debug request, added mailto link for error report...
* 1781 FIX: Fix broken grouping by host/service group in availability
* 1783 FIX: Finish the view "History of Scheduled Downtimes"...
+ * 1766 FIX: Fixed exceptions in Web GUI when host or service groups used non ascii characters in names...
WATO:
* 1760 Added search form to manual checks page
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 8c2881e..00f53b8 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4605,8 +4605,8 @@ def dump_host(hostname):
parents_list = parents_of(hostname)
if len(parents_list) > 0:
print tty_yellow + "Parents: " + tty_normal + ", ".join(parents_list)
- print tty_yellow + "Host groups: " + tty_normal + ", ".join(hostgroups_of(hostname))
- print tty_yellow + "Contact groups: " + tty_normal + ", ".join(host_contactgroups_of([hostname]))
+ print tty_yellow + "Host groups: " + tty_normal + make_utf8(", ".join(hostgroups_of(hostname)))
+ print tty_yellow + "Contact groups: " + tty_normal + make_utf8(", ".join(host_contactgroups_of([hostname])))
agenttypes = []
if is_tcp_host(hostname):
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 7f0a305..1bd52a4 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -500,7 +500,7 @@ class html:
self.text_input(varname, default_value, type="password", size = size, **args)
def text_area(self, varname, deflt="", rows=4, cols=30, attrs = {}):
- value = self.vars.get(varname, deflt)
+ value = self.var(varname, deflt)
error = self.user_errors.get(varname)
if error:
self.write("<x class=inputerror>")
@@ -528,7 +528,10 @@ class html:
self.write("<select%s name=\"%s\" id=\"%s\"%s>\n" %
(onchange_code, varname, varname, attributes))
for value, text in options:
- if value == None: value = ""
+ if value == None:
+ value = ""
+ elif type(value) == unicode:
+ value = value.encode('utf-8')
sel = value == current and " selected" or ""
self.write("<option value=\"%s\"%s>%s</option>\n" %
(self.attrencode(value), sel, self.attrencode(text)))
@@ -887,7 +890,7 @@ class html:
if self.myfile == "view":
mode_name = self.var('mode') == "availability" and "availability" or "view"
- encoded_vars = self.attrencode([ (k, v != None and str(v) or '') for k,v in self.page_context.items() ])
+ encoded_vars = self.attrencode([ (k, v != None and v or '') for k,v in self.page_context.items() ])
h += '<div class="visualadd"><a class="visualadd" href="javascript:void(0)" ' \
'onclick="toggle_add_to_visual(event, this, \'%s\', %s, {\'name\': \'%s\'})">' \
'<img class=statusicon src="images/status_add_dashlet.png" title="%s"></a></div>\n' % \
@@ -1256,13 +1259,17 @@ class html:
# From here: Former not class functions
+ # This function returns a str object, never unicode!
# Encode HTML attributes: replace " with ", also replace
# < and >. This code is slow.
def attrencode(self, value):
- if type(value) == int:
+ ty = type(value)
+ if ty == int:
return str(value)
- elif type(value) not in [str, unicode]:
+ elif ty not in [str, unicode]:
value = str(value)
+ elif ty == unicode:
+ value = value.encode("utf-8")
return value.replace('"', """).replace("<", "<").replace(">", ">")
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 57c7b11..5d14de3 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -457,6 +457,13 @@ class ID(TextAscii):
self._regex = re.compile('^[a-zA-Z_][-a-zA-Z0-9_]*$')
self._regex_error = _("An identifier must only consist of letters, digits, dash and underscore and it must start with a letter or underscore.")
+# Same as the ID class, but allowing unicode objects
+class UnicodeID(TextUnicode):
+ def __init__(self, **kwargs):
+ TextAscii.__init__(self, **kwargs)
+ self._regex = re.compile(r'^[\w][-\w0-9_]*$', re.UNICODE)
+ self._regex_error = _("An identifier must only consist of letters, digits, dash and underscore and it must start with a letter or underscore.")
+
class RegExp(TextAscii):
def __init__(self, **kwargs):
TextAscii.__init__(self, attrencode = True, cssclass = 'text regexp', **kwargs)
Module: check_mk
Branch: master
Commit: dad90baa9782224392aafb87707b1959b219bb5d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dad90baa978222…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 17 09:38:01 2014 +0100
Removed needless files
---
bluecat_dhcp | 101 ----------------------------------------------------------
bluecat_dns | 95 ------------------------------------------------------
2 files changed, 196 deletions(-)
diff --git a/bluecat_dhcp b/bluecat_dhcp
deleted file mode 100644
index c24564b..0000000
--- a/bluecat_dhcp
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/python
-# -*- encoding: utf-8; py-indent-offset: 4 -*-
-# +------------------------------------------------------------------+
-# | ____ _ _ __ __ _ __ |
-# | / ___| |__ ___ ___| | __ | \/ | |/ / |
-# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-# | | |___| | | | __/ (__| < | | | | . \ |
-# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-# | |
-# | Copyright Mathias Kettner 2013 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-
-# ails. 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.
-
-factory_settings["bluecat_dhcp"] = {
- "oper_states" : {
- "warning" : [ 2, 3, 4 ],
- "critical" : [ 5 ],
- },
-}
-
-def inventory_bluecat_dhcp(info):
- # Check if DHCP is not stopped on at least one host
- for node, oper_state, leases in info:
- if oper_state != '2':
- return [(None, None)]
-
-def check_bluecat_dhcp(item, params, info):
- oper_states = {
- 1 : "running normally",
- 2 : "not running",
- 3 : "currently starting",
- 4 : "currently stopping",
- 5 : "fault"
- }
-
- ok_on_node = False
- states = {}
- state = 0
-
- # Collect states of nodes
- for node, oper_state, leases in info:
- oper_state, leases_sec = map(int, (oper_state, leases))
- temp_state = 0
- if oper_state in params['oper_states']['warning']:
- state = max(state, 1)
- temp_state = 1
- elif oper_state in params['oper_states']['critical']:
- state = 2
- temp_state = 2
- else:
- # If node one ok, the total check is ok
- ok_on_node = node
- # Only needed in cluster:
- states[node] = {'oper_state' : oper_states[oper_state], 'leases_sec' : leases_sec, 'state' : temp_state }
-
- # Are we in a Cluster?
- if len(info) > 1:
- if ok_on_node:
- node = ok_on_node
- # One Node is OK:
- yield 0, "DHCP is %s on %s" % (states[node]['oper_state'], node)
- yield 0, '%s Leases per second' % (states[node]['leases_sec']), [ ('leases', states[node]['leases_sec']) ]
- else:
- # None of the nodes is ok:
- for node, data in states.items():
- yield data['state'], "%s on %s" % (data['oper_state'], node)
- return
-
- # Default behavior without Cluster
- yield state, "DHCP is %s" % oper_states[oper_state]
- yield 0, '%s Leases per second' % leases_sec, [ ('leases', leases_sec ) ]
-
-
-check_info["bluecat_dhcp"] = {
- "check_function" : check_bluecat_dhcp,
- "inventory_function" : inventory_bluecat_dhcp,
- "node_info" : True,
- "service_description" : "DHCP",
- "has_perfdata" : True,
- "default_levels_variable" : "bluecat_dhcp",
- "group" : "bluecat_dhcp",
- "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.13315.2.1",
- "snmp_info" : (".1.3.6.1.4.1.13315.3.1.1.2.1", [
- 1, # dhcpOperState
- 3, # dhcpLeaseStatsSuccess
- ])
-}
-
diff --git a/bluecat_dns b/bluecat_dns
deleted file mode 100644
index 98d0b0c..0000000
--- a/bluecat_dns
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/python
-# -*- encoding: utf-8; py-indent-offset: 4 -*-
-# +------------------------------------------------------------------+
-# | ____ _ _ __ __ _ __ |
-# | / ___| |__ ___ ___| | __ | \/ | |/ / |
-# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-# | | |___| | | | __/ (__| < | | | | . \ |
-# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-# | |
-# | Copyright Mathias Kettner 2013 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-
-# ails. 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.
-
-factory_settings["bluecat_dns"] = {
- "oper_states" : {
- "warning" : [ 2, 3, 4 ],
- "critical" : [ 5 ],
- },
-}
-
-def inventory_bluecat_dns(info):
- return [(None, None)]
-
-def check_bluecat_dns(item, params, info):
- oper_states = {
- 1 : "running normally",
- 2 : "not running",
- 3 : "currently starting",
- 4 : "currently stopping",
- 5 : "fault"
- }
-
- if not info:
- return
-
- ok_on_node = False
- states = {}
- state = 0
-
- for node, oper_state in info:
- oper_state = int(oper_state)
- temp_state = 0
- if oper_state in params['oper_states']['warning']:
- state = max(1, state)
- temp_state = 1
- elif oper_state in params['oper_states']['critical']:
- state = 2
- temp_state = 2
- else:
- # If node one ok, the total check is ok
- ok_on_node = node
- # Only needed in cluster:
- states[node] = {'oper_state' : oper_states[oper_state], 'state' : temp_state }
-
- # Are we in a Cluster?
- if len(info) > 1:
- if ok_on_node:
- node = ok_on_node
- # One Node is OK:
- yield 0, "DNS is %s on %s" % (states[node]['oper_state'], node)
- else:
- # None of the nodes is ok:
- for node, data in states.items():
- yield data['state'], "%s on %s" % (data['oper_state'], node)
- return
-
- # Default behavior without Cluster
- yield state, "DNS is %s" % oper_states[oper_state]
-
-check_info["bluecat_dns"] = {
- "check_function" : check_bluecat_dns,
- "inventory_function" : inventory_bluecat_dns,
- "node_info" : True,
- "service_description" : "DNS",
- "default_levels_variable" : "bluecat_dns",
- "group" : "bluecat_dns",
- "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.13315.2.1",
- "snmp_info" : (".1.3.6.1.4.1.13315.3.1.2.2.1", [
- 1, # DnsSerOperState
- ])
-}
-
Module: check_mk
Branch: master
Commit: 7e45d27fbe59317db489f77c2eabbace2ce23cf5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7e45d27fbe5931…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Dec 16 16:19:35 2014 +0100
#1666 FIX inventory check esx_vsphere_hostsystem: no longer crashes if information is missing
In certain scenarios (which still need to be investigated) the hostsystem does
not report any information for the node "hardware.cpuPkg", which caused an exception in the
inventory check esx_vsphere_hostsystem.
---
.werks/1666 | 12 ++++++++++++
ChangeLog | 1 +
inventory/esx_vpshere_hostsystem | 7 ++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/.werks/1666 b/.werks/1666
new file mode 100644
index 0000000..b3dc639
--- /dev/null
+++ b/.werks/1666
@@ -0,0 +1,12 @@
+Title: inventory check esx_vsphere_hostsystem: no longer crashes if information is missing
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1418742995
+
+In certain scenarios (which still need to be investigated) the hostsystem does
+not report any information for the node "hardware.cpuPkg", which caused an exception in the
+inventory check esx_vsphere_hostsystem.
diff --git a/ChangeLog b/ChangeLog
index 112a8e1..ec49e3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
* 1764 FIX: mk_sap: Fixed exception when saving status file
* 1663 FIX: winperf_if: fixed incorrect enumeration of interface index...
* 1204 FIX: veeam_client: Not longer throwing an error in case of currenlty running backup
+ * 1666 FIX: inventory check esx_vsphere_hostsystem: no longer crashes if information is missing...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request, added mailto link for error report...
diff --git a/inventory/esx_vpshere_hostsystem b/inventory/esx_vpshere_hostsystem
index 29201d0..9658164 100644
--- a/inventory/esx_vpshere_hostsystem
+++ b/inventory/esx_vpshere_hostsystem
@@ -78,9 +78,10 @@ def inv_esx_vsphere_hostsystem(info):
node["cores_per_cpu"] = node["cores"] / node["cpus"]
node["threads"] = int(data["hardware.cpuInfo"]["numCpuThreads"])
node["threads_per_cpu"] = node["threads"] / node["cpus"]
- node["model"] = data["hardware.cpuPkg"]["0"]["description"]
- node["vendor"] = data["hardware.cpuPkg"]["0"]["vendor"]
- node["bus_speed"] = float(data["hardware.cpuPkg"]["0"]["busHz"])
+ if "hardware.cpuPkg" in data:
+ node["model"] = data["hardware.cpuPkg"]["0"]["description"]
+ node["vendor"] = data["hardware.cpuPkg"]["0"]["vendor"]
+ node["bus_speed"] = float(data["hardware.cpuPkg"]["0"]["busHz"])
node = inv_tree("hardware.bios.")
node["version"] = data["hardware.biosInfo"]["biosVersion"]