Module: check_mk
Branch: master
Commit: 24165123cfcdaa9f4de02ae1a043e4b237116e3f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=24165123cfcdaa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 28 08:42:35 2017 +0200
Minor cleanups
Change-Id: Ibdf6c063d380047bf00e106efb893bec00df7d61
---
web/htdocs/wato.py | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 776670e..5d076c1 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11003,32 +11003,29 @@ def mode_edit_user(phase):
# Contact groups
forms.header(_("Contact Groups"), isopen=False)
forms.section()
- url1 = folder_preserving_link([("mode", "contact_groups")])
- url2 = folder_preserving_link([("mode", "rulesets"), ("group", "grouping")])
+ groups_page_url = folder_preserving_link([("mode", "contact_groups")])
+ group_assign_url = folder_preserving_link([("mode", "rulesets"), ("group", "grouping")])
if len(contact_groups) == 0:
html.write(_("Please first create some <a href='%s'>contact groups</a>") %
- url1)
+ groups_page_url)
else:
- entries = [ (group['alias'], c) for c, group in contact_groups.items() ]
- entries.sort()
+ entries = sorted([ (group['alias'], c) for c, group in contact_groups.items() ])
is_member_of_at_least_one = False
for alias, gid in entries:
if not alias:
alias = gid
+
if not is_locked('contactgroups'):
html.checkbox("cg_" + gid, gid in user.get("contactgroups", []))
- url = folder_preserving_link([("mode", "edit_contact_group"), ("edit", gid)])
- html.a(alias, href=url)
- html.br()
else:
is_member = gid in user.get("contactgroups", [])
if is_member:
is_member_of_at_least_one = True
- url = folder_preserving_link([("mode", "edit_contact_group"), ("edit", gid)])
- html.a(alias, href=url)
- html.br()
+ html.hidden_field("cg_" + gid, '1' if is_member else '')
- html.hidden_field("cg_" + gid, is_member and '1' or '')
+ url = folder_preserving_link([("mode", "edit_contact_group"), ("edit", gid)])
+ html.a(alias, href=url)
+ html.br()
if is_locked('contactgroups') and not is_member_of_at_least_one:
html.i(_('No contact groups assigned.'))
@@ -11038,7 +11035,8 @@ def mode_edit_user(phase):
"then first <a href='%s'>do so</a>. Hosts and services can be "
"assigned to contact groups using <a href='%s'>rules</a>.<br><br>"
"If you do not put the user into any contact group "
- "then no monitoring contact will be created for the user.") % (url1, url2))
+ "then no monitoring contact will be created for the user.") %
+ (groups_page_url, group_assign_url))
forms.header(_("Notifications"), isopen=False)
if not rulebased_notifications:
Module: check_mk
Branch: master
Commit: f24ae397b0d82ca258f3d6cc79f553fc736e602c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f24ae397b0d82c…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Thu Apr 27 15:25:43 2017 +0200
4627 FIX apc_symmetra: Fix bogus 100000000 A battery current occurring on some devices
Some APC Symmetra devices react badly to OIDs being polled out of order, leading to
a 1000000000 A being displayed in the check that cannot be seen in an SNMP walk.
The OIDs of this check have been reordered to circumvent this problem.
Change-Id: I22622b01513f63190c1200350b03808fbd68a887
---
.werks/4627 | 13 +++++++++++++
checks/apc_symmetra | 8 +++++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/.werks/4627 b/.werks/4627
new file mode 100644
index 0000000..eefffe7
--- /dev/null
+++ b/.werks/4627
@@ -0,0 +1,13 @@
+Title: apc_symmetra: Fix bogus 100000000 A battery current occurring on some devices
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1493298932
+
+Some APC Symmetra devices react badly to OIDs being polled out of order, leading to
+a 1000000000 A being displayed in the check that cannot be seen in an SNMP walk.
+The OIDs of this check have been reordered to circumvent this problem.
diff --git a/checks/apc_symmetra b/checks/apc_symmetra
index 8c86b17..4a1ef0b 100644
--- a/checks/apc_symmetra
+++ b/checks/apc_symmetra
@@ -67,9 +67,9 @@ def parse_apc_symmetra(info):
return parsed
# some numeric fields may be empty
- battery_status, output_status, state_output_state, battery_capacity, \
+ battery_status, output_status, battery_capacity, \
battery_replace, battery_num_batt_packs, battery_time_remain, calib_result, \
- last_diag_date, battery_temp, battery_current = info[0]
+ last_diag_date, battery_temp, battery_current, state_output_state = info[0]
if state_output_state != '':
# string contains a bitmask, convert to int
@@ -245,10 +245,11 @@ check_info['apc_symmetra'] = {
"inventory_function" : inventory_apc_symmetra,
"check_function" : check_apc_symmetra,
"service_description" : "APC Symmetra status",
+ # A Note on the order of OIDs: If the 11.1.1.0 is not the last to be polled,
+ # this leads to bogus values for some other OIDs on some devices.
"snmp_info" : (".1.3.6.1.4.1.318.1.1.1", [
"2.1.1.0", # PowerNet-MIB::upsBasicBatteryStatus,
"4.1.1.0", # PowerNet-MIB::upsBasicOutputStatus,
- "11.1.1.0", # PowerNet-MIB::upsBasicStateOutputState
"2.2.1.0", # PowerNet-MIB::upsAdvBatteryCapacity,
"2.2.4.0", # PowerNet-MIB::upsAdvBatteryReplaceIndicator,
"2.2.6.0", # PowerNet-MIB::upsAdvBatteryNumOfBadBattPacks,
@@ -257,6 +258,7 @@ check_info['apc_symmetra'] = {
"7.2.4.0", # PowerNet-MIB::upsLastDiagnosticsDate
"2.2.2.0", # PowerNet-MIB::upsAdvBatteryTemperature,
"2.2.9.0", # PowerNet-MIB::upsAdvBatteryCurrent,
+ "11.1.1.0", # PowerNet-MIB::upsBasicStateOutputState
]),
"snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.318.1.3"),
"has_perfdata" : True,
Module: check_mk
Branch: master
Commit: e0aade379841f643d66da59d8a71d68426f4b677
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e0aade379841f6…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Apr 27 09:24:21 2017 +0200
Fixed linking of our SUID executables, which was broken recently.
The detection of the right RRD library is a bit tricky: We can't simply put
-lrrd_th or -lrrd globally into LIBS. The problem is that our SUID programs
icmpsender and icmpreceiver would be linked with that option, too, but because
of security reasons the dynamic linker will ignore our LD_LIBRARY_PATH => no
RRD library found or even the wrong one... :-/
Change-Id: I136227050e7fd1c3ba4fa354e56b1d85314ac11c
---
configure.ac | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index b2d2965..2238308 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,19 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(socket, connect)
AC_CHECK_LIB(socket, shutdown)
-AC_SEARCH_LIBS([rrd_xport], [rrd_th rrd], [], [AC_MSG_ERROR([unable to find the rrd_xport function])])
+
+# The detection of the right RRD library is a bit tricky: We can't simply put
+# -lrrd_th or -lrrd globally into LIBS. The problem is that our SUID programs
+# icmpsender and icmpreceiver would be linked with that option, too, but because
+# of security reasons the dynamic linker will ignore our LD_LIBRARY_PATH => no
+# RRD library found or even the wrong one... :-/
+RRDLIB=
+old_LIBS=$LIBS
+AC_SEARCH_LIBS([rrd_xport], [rrd_th rrd],
+ [test "$ac_cv_search_rrd_xport" = "none required" || RRDLIB="$ac_cv_search_rrd_xport"],
+ [AC_MSG_ERROR([unable to find the rrd_xport function])])
+LIBS=$old_LIBS
+AC_SUBST(RRDLIB)
# Checks for header files.
AC_HEADER_DIRENT
Module: check_mk
Branch: master
Commit: c6b46606eedc7c5a561f3dd0b65f4778f9b6564b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c6b46606eedc7c…
Author: Roland Halbig <rh(a)mathias-kettner.de>
Date: Thu Apr 20 13:27:02 2017 +0200
refactoring htmllib: escaping and encodings via member object calls.
Change-Id: I49654704d9a55a1d3bd49ee224809f100b410838
---
web/htdocs/htmllib.py | 84 +++++++++++++++++++++++++++++++++------------------
1 file changed, 55 insertions(+), 29 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 90e1364..5d8c01a 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -111,7 +111,7 @@ class Escaper(object):
# For example: replace '"' with '"', '<' with '<'.
# This code is slow. Works on str and unicode without changing
# the type. Also works on things that can be converted with '%s'.
- def _escape_attribute(self, value):
+ def escape_attribute(self, value):
attr_type = type(value)
if value is None:
return ''
@@ -133,12 +133,12 @@ class Escaper(object):
# This is useful for messages where we want to keep formatting
# options. (Formerly known as 'permissive_attrencode') """
# for the escaping functions
- def _escape_text(self, text):
+ def escape_text(self, text):
if isinstance(text, HTML):
return "%s" % text # This is HTML code which must not be escaped
- text = self._escape_attribute(text)
+ text = self.escape_attribute(text)
text = self._unescaper_text.sub(r'<\1\2>', text)
# Also repair link definitions
text = self._unescaper_href.sub(r'<a href="\1">', text)
@@ -151,21 +151,6 @@ class Escaper(object):
#
- # Encode HTML attributes: replace " with ", also replace
- # < and >. This code is slow. Works on str and unicode without
- # changing the type. Also works on things that can be converted
- # with %s.
- def attrencode(self, value):
- return self._escape_attribute(value)
-
-
- # Only strip off some tags. We allow some simple tags like
- # <b>, <tt>, <i> to be part of the string. This is useful
- # for messages where we still want to have formating options.
- def permissive_attrencode(self, obj):
- return self._escape_text(obj)
-
-
#.
#
# HTML encoding
@@ -522,7 +507,7 @@ class OutputFunnel(object):
# '----------------------------------------------------------------------'
-class HTMLGenerator(Escaper, OutputFunnel):
+class HTMLGenerator(OutputFunnel):
""" Usage Notes:
@@ -581,6 +566,9 @@ class HTMLGenerator(Escaper, OutputFunnel):
self.testing_mode = False
+ self.escaper = Escaper()
+
+
#
# Rendering
@@ -618,14 +606,14 @@ class HTMLGenerator(Escaper, OutputFunnel):
if v is None:
continue
- k = self._escape_attribute(k.rstrip('_'))
+ k = self.escaper.escape_attribute(k.rstrip('_'))
if v == '':
options.append(k)
continue
if not isinstance(v, list):
- v = self._escape_attribute(v)
+ v = self.escaper.escape_attribute(v)
else:
if k == "class":
sep = ' '
@@ -634,7 +622,7 @@ class HTMLGenerator(Escaper, OutputFunnel):
else:
sep = '_'
- v = sep.join([a for a in (self._escape_attribute(vi) for vi in v) if a])
+ v = sep.join([a for a in (self.escaper.escape_attribute(vi) for vi in v) if a])
if sep.startswith(';'):
v = re.sub(';+', ';', v)
@@ -672,7 +660,7 @@ class HTMLGenerator(Escaper, OutputFunnel):
if isinstance(tag_content, HTML):
tag += tag_content.lstrip(' ').rstrip('\n')
else:
- tag += self._escape_text(tag_content)
+ tag += self.escaper.escape_text(tag_content)
tag += "</%s>" % (tag_name)
@@ -726,7 +714,7 @@ class HTMLGenerator(Escaper, OutputFunnel):
def write_text(self, text):
""" Write text. Highlighting tags such as h2|b|tt|i|br|pre|a|sup|p|li|ul|ol are not escaped. """
- self.write(self._escape_text(text))
+ self.write(self.escaper.escape_text(text))
def write_html(self, content):
@@ -1356,13 +1344,10 @@ class RequestHandler(object):
# '----------------------------------------------------------------------'
-class html(HTMLGenerator, Encoder, RequestHandler):
+class html(HTMLGenerator, RequestHandler):
def __init__(self):
super(html, self).__init__()
-# HTMLGenerator.__init__(self)
-# Encoder.__init__(self)
-# RequestHandler.__init__(self)
# rendering state
self.html_is_open = False
@@ -1420,6 +1405,10 @@ class html(HTMLGenerator, Encoder, RequestHandler):
# FIXME: Drop this
self.auto_id = 0
+ # encoding
+ self.encoder = Encoder()
+
+
RETURN = 13
SHIFT = 16
CTRL = 17
@@ -1428,6 +1417,43 @@ class html(HTMLGenerator, Encoder, RequestHandler):
F1 = 112
+ #
+ # Encoding
+ #
+
+ def urlencode_vars(self, vars):
+ return self.encoder.urlencode_vars(vars)
+
+ def urlencode(self, value):
+ return self.encoder.urlencode(value)
+
+ # Escape a variable name so that it only uses allowed charachters for URL variables
+ def varencode(self, varname):
+ return self.encoder.varencode(varname)
+
+ def u8(self, c):
+ return self.encoder.u8(c)
+
+ def utf8_to_entities(self, text):
+ return self.encoder.utf8_to_entities(text)
+
+
+ #
+ # escaping - deprecated functions
+ #
+ # Encode HTML attributes: e.g. replace '"' with '"', '<' and '>' with '<' and '>'
+ def attrencode(self, value):
+ return self.escaper.escape_attribute(value)
+
+ # Only strip off some tags. We allow some simple tags like <b> or <tt>.
+ def permissive_attrencode(self, obj):
+ return self.escaper.escape_text(obj)
+
+
+ #
+ # Stripping
+ #
+
# remove all HTML-tags
def strip_tags(self, ht):
@@ -2563,7 +2589,7 @@ class html(HTMLGenerator, Encoder, RequestHandler):
id_ = id
self._context_button(title, url, icon=icon, hot=hot, id_=id_, bestof=bestof, hover_title=hover_title, fkey=fkey, class_=class_)
if fkey and self.keybindings_enabled:
- self.add_keybinding([self.F1 + (fkey - 1)], "document.location='%s';" % self._escape_attribute(url))
+ self.add_keybinding([self.F1 + (fkey - 1)], "document.location='%s';" % self.escaper.escape_attribute(url))
def _context_button(self, title, url, icon=None, hot=False, id_=None, bestof=None, hover_title=None, fkey=None, class_=None):