Module: check_mk
Branch: master
Commit: a43e24cd82d6369754acf1ba2ff7e8c382e67523
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a43e24cd82d636…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 27 11:08:43 2018 +0200
6373 FIX Fixed UnicodeEncodeError when piping "cmk -M" to stream or file
The output of e.g. "cmk -M" was not correctly encoded when the output
was written to streams or files leading to a "UnicodeEncodeError: 'ascii' codec can't encode character" error.
Change-Id: Iff3d9bc0a63ca78c4e7e24bf5f909ebfbcd616ca
---
.werks/6373 | 12 ++++++++++++
cmk/tty.py | 8 ++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/.werks/6373 b/.werks/6373
new file mode 100644
index 0000000..73c7352
--- /dev/null
+++ b/.werks/6373
@@ -0,0 +1,12 @@
+Title: Fixed UnicodeEncodeError when piping "cmk -M" to stream or file
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1532682455
+
+The output of e.g. "cmk -M" was not correctly encoded when the output
+was written to streams or files leading to a "UnicodeEncodeError: 'ascii' codec can't encode character" error.
diff --git a/cmk/tty.py b/cmk/tty.py
index 42ae84e..63e9be7 100644
--- a/cmk/tty.py
+++ b/cmk/tty.py
@@ -115,10 +115,10 @@ def print_table(headers, colors, rows, indent = ""):
if type(x) == unicode:
return x.encode('utf-8')
else:
- return x
+ return "%s" % x
for row in rows:
- lengths = [ max(len(str(make_utf8(c))), l) for c, l in zip(row, lengths) ]
+ lengths = [ max(len(make_utf8(c)), l) for c, l in zip(row, lengths) ]
fmt = indent
sep = ""
@@ -129,7 +129,7 @@ def print_table(headers, colors, rows, indent = ""):
first = True
fmt += "\n"
for row in [ headers ] + rows:
- sys.stdout.write(fmt % tuple(row[:len(headers)]))
+ sys.stdout.write(fmt % tuple(make_utf8(c) for c in row[:len(headers)]))
if first:
first = False
- sys.stdout.write(fmt % tuple([ "-" * l for l in lengths ]))
+ sys.stdout.write(fmt % tuple("-" * l for l in lengths))
Module: check_mk
Branch: master
Commit: f645915e8f69fe756031a98487638f61edd4ae2e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f645915e8f69fe…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jul 27 13:28:39 2018 +0200
Classified the remaining warnings.
Change-Id: Iccb49e3358b3d1ddb7da0a66af4180a5ad069fc7
---
tests/pylint/pylintrc | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 37bf8c1..afc75db 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -12,11 +12,6 @@ extension-pkg-whitelist=rrdtool,_ldap,netifaces,pymssql
[MESSAGES CONTROL]
disable=
- inconsistent-return-statements,
- missing-docstring,
- no-else-return,
- no-self-use,
- protected-access,
#---------------------------------------------------------------------------
# We should really enable this, there could be some real exceptions waiting
# to be thrown. But some work is needed first to sprinkle abc annotations
@@ -57,6 +52,14 @@ disable=
broad-except,
#---------------------------------------------------------------------------
# Enabling this would enhance readability quite a bit and it might even
+ # uncover bugs. Fixing this is not rocket science, just some work.
+ inconsistent-return-statements,
+ #---------------------------------------------------------------------------
+ # Enabling this warning would be nice, it is mostly a sign of sloppy
+ # programming practice. In some cases, they can even hide bugs.
+ no-else-return,
+ #---------------------------------------------------------------------------
+ # Enabling this would enhance readability quite a bit and it might even
# uncover bugs. Fixing this is not rocket science, just some work: Roughly
# 400 warnings in about 60 modules, but this can be fixed step by step.
redefined-outer-name,
@@ -66,6 +69,15 @@ disable=
# this.
redefined-builtin,
#---------------------------------------------------------------------------
+ # Enabling this would be nice, but not crucial. Nevertheless, this would
+ # improve readability and involve some cleanups in our class hierarchy, so
+ # we should do this some day.
+ protected-access,
+ #---------------------------------------------------------------------------
+ # Enabling this would be nice, but not crucial. At the moment, we have quite
+ # a few violations, so we postpone fixing this.
+ no-self-use,
+ #---------------------------------------------------------------------------
# Enabling this would be nice, but not crucial. At the moment, we have quite
# a few violations (about 220 in roughly 40 modules), so we postpone fixing
# this. Note that due to our arcane use of types, we need to be very careful
@@ -133,6 +145,9 @@ disable=
bad-whitespace,
line-too-long,
#---------------------------------------------------------------------------
+ # We are light years away from enabling this...
+ missing-docstring,
+ #---------------------------------------------------------------------------
# Enabling the two spelling-related checks increases pylints runtime from
# 11 min to 40 min, so we better keep those disabled for normal runs.
# wrong-spelling-in-comment,
Module: check_mk
Branch: master
Commit: 227f88d159438485527796684b46e8957822fff0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=227f88d1594384…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jul 27 09:52:31 2018 +0200
Fixed and enabled relative-import warning.
Change-Id: I436f308c3b589e248f56f00ad0cbbb7578cc8811
---
cmk_base/data_sources/__init__.py | 2 +-
tests/pylint/pylintrc | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/cmk_base/data_sources/__init__.py b/cmk_base/data_sources/__init__.py
index 37f39e5..0269225 100644
--- a/cmk_base/data_sources/__init__.py
+++ b/cmk_base/data_sources/__init__.py
@@ -275,7 +275,7 @@ class DataSources(object):
hosts.append((self._hostname, self._ipaddress, self, config.check_max_cachefile_age))
if nodes:
- import abstract
+ import cmk_base.data_sources.abstract as abstract
abstract.DataSource.set_may_use_cache_file()
# Special agents can produce data for the same check_plugin_name on the same host, in this case
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 682b1cf..1df6709 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -19,7 +19,6 @@ disable=
no-else-return,
no-self-use,
protected-access,
- relative-import,
#---------------------------------------------------------------------------
# We should really enable this, there could be some real exceptions waiting
# to be thrown. But some work is needed first to sprinkle abc annotations
Module: check_mk
Branch: master
Commit: c09eaffd169861ccf4aff91ef04ab5de10ac4acc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c09eaffd169861…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Jul 5 15:49:46 2018 +0200
6120 FIX cisco_nexus_cpu: use the ruleset "CPU utilization for simple devices"
Since Werk 5748 cisco_nexus_cpu is preferred over cisco_cpu on all Nexus
devices. As a result short peaks in CPU utilization might result in a WARN or
CRIT on devices that used cisco_cpu before, since the cisco_nexus_cpu check
does not deliver averaged values. To add the possibility of averaging to the
cisco_nexus_cpu check the ruleset "CPU utilization for simple devices" is now
used. With this ruleset it is possible to define arbitrary averaging periods.
The old ruleset "CPU utilization for Appliances" is not supported anymore for
the cisco_nexus_cpu check.
To accommodate for this change affected hosts have to be rediscovered and all
rules for devices that use the cisco_nexus_cpu checks have to be moved to the
new ruleset.
Change-Id: I4c97f3b81459086c32d40f9f049a04361e3a3bcd
---
.werks/6120 | 21 +++++++++++++++++++++
checkman/cisco_nexus_cpu | 3 +--
checks/cisco_nexus_cpu | 9 ++++++---
cmk/gui/plugins/wato/check_parameters.py | 22 +++++++++++-----------
4 files changed, 39 insertions(+), 16 deletions(-)
diff --git a/.werks/6120 b/.werks/6120
new file mode 100644
index 0000000..169141b
--- /dev/null
+++ b/.werks/6120
@@ -0,0 +1,21 @@
+Title: cisco_nexus_cpu: use the ruleset "CPU utilization for simple devices"
+Level: 1
+Component: checks
+Compatible: incomp
+Edition: cre
+Version: 1.6.0i1
+Date: 1530797354
+Class: fix
+
+Since Werk 5748 cisco_nexus_cpu is preferred over cisco_cpu on all Nexus
+devices. As a result short peaks in CPU utilization might result in a WARN or
+CRIT on devices that used cisco_cpu before, since the cisco_nexus_cpu check
+does not deliver averaged values. To add the possibility of averaging to the
+cisco_nexus_cpu check the ruleset "CPU utilization for simple devices" is now
+used. With this ruleset it is possible to define arbitrary averaging periods.
+The old ruleset "CPU utilization for Appliances" is not supported anymore for
+the cisco_nexus_cpu check.
+
+To accommodate for this change affected hosts have to be rediscovered and all
+rules for devices that use the cisco_nexus_cpu checks have to be moved to the
+new ruleset.
diff --git a/checkman/cisco_nexus_cpu b/checkman/cisco_nexus_cpu
index 97ceba5..9bc6087 100644
--- a/checkman/cisco_nexus_cpu
+++ b/checkman/cisco_nexus_cpu
@@ -4,8 +4,7 @@ catalog: hw/network/cisco
license: GPL
distribution: check_mk
description:
- This check monitors the CPU utilization of Cisco Nexus devices
- which do not support CPU information from CISCO-PROCESS-MIB.
+ This check monitors the CPU utilization of Cisco Nexus devices.
Default levels are 80, 90 percent. These are configurable.
diff --git a/checks/cisco_nexus_cpu b/checks/cisco_nexus_cpu
index 06822f2..957619d 100644
--- a/checks/cisco_nexus_cpu
+++ b/checks/cisco_nexus_cpu
@@ -28,12 +28,14 @@
# .1.3.6.1.4.1.9.9.305.1.1.1.0 1 --> CISCO-SYSTEM-EXT-MIB::cseSysCPUUtilization.0
-cisco_nexus_cpu_default_levels = (80.0, 90.0)
+factory_settings["cisco_nexus_cpu_default_levels"] = {
+ 'levels': (80.0, 90.0),
+}
def inventory_cisco_nexus_cpu(info):
if info[0][0]:
- return [ (None, "cisco_nexus_cpu_default_levels") ]
+ return [ (None, {}) ]
def check_cisco_nexus_cpu(_no_item, params, info):
@@ -49,6 +51,7 @@ check_info['cisco_nexus_cpu'] = {
'snmp_scan_function' : lambda oid: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower() \
and "nx-os" in oid(".1.3.6.1.2.1.1.1.0").lower() \
and oid(".1.3.6.1.4.1.9.9.305.1.1.1.0"),
- 'group' : "cpu_utilization",
+ 'group' : "cpu_utilization_os",
'includes' : [ "cpu_util.include" ],
+ 'default_levels_variable' : "cisco_nexus_cpu_default_levels",
}
diff --git a/cmk/gui/plugins/wato/check_parameters.py b/cmk/gui/plugins/wato/check_parameters.py
index 8cd86ac..55778f0 100644
--- a/cmk/gui/plugins/wato/check_parameters.py
+++ b/cmk/gui/plugins/wato/check_parameters.py
@@ -9831,19 +9831,19 @@ register_check_parameters(
_("CPU utilization for simple devices"),
Dictionary(
help = _("This rule configures levels for the CPU utilization (not load) for "
- "the operating systems Windows and VMWare ESX host systems, as well as devices "
- "implementing the Host Resources MIB. The utilization "
- "ranges from 0 to 100 - regardless of the number of CPUs."),
+ "the operating systems Windows and VMWare ESX host systems, as well as devices "
+ "implementing the Host Resources MIB. The utilization "
+ "ranges from 0 to 100 - regardless of the number of CPUs."),
elements = [
( "average",
- Integer(
- title = _("Averaging"),
- help = _("When this option is activated then the CPU utilization is being "
- "averaged <b>before</b> the levels are being applied."),
- unit = _("minutes"),
- minvalue = 1,
- default_value = 15,
- label = _("Compute average over last "),
+ Integer(
+ title = _("Averaging"),
+ help = _("When this option is activated then the CPU utilization is being "
+ "averaged <b>before</b> the levels are being applied."),
+ unit = _("minutes"),
+ minvalue = 1,
+ default_value = 15,
+ label = _("Compute average over last "),
)),
( "levels",
Levels(