Module: check_mk
Branch: master
Commit: bf54a4e357de85e69a74d6e8c395a9d40672dad9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf54a4e357de85…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Mar 14 14:15:04 2018 +0100
Fixed typo which resulted in an exception during housekeeping.
Change-Id: I9b63b497b9f12c95982f2de7ae6fa9f72cdcb74b
---
cmk/ec/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index f9d1e1f..180f652 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -1760,7 +1760,7 @@ class EventServer(ECServerThread):
if g_config['archive_mode'] != 'mongodb':
with lock_logging:
- expire_logfiles(settings)
+ expire_logfiles(self.settings)
# For all events that have been created in a host downtime check the host
# whether or not it is still in downtime. In case the downtime has ended
Module: check_mk
Branch: master
Commit: 13174af6ef78bc61824ffe31d3630ff2a608c8c5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=13174af6ef78bc…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Mar 14 13:47:39 2018 +0100
Make the format and test-pylint-simple targets in test/ happy again.
A few comments would really need some more love, but anyway...
Fixed shebang on the way.
Change-Id: I66b07825645ccf08f20fadd4eee674f2fbb7fae0
---
cmk/ec/defaults.py | 25 ++++++++++++++++++-------
cmk/ec/export.py | 34 ++++++++++++++++++++++------------
tests/Makefile | 2 +-
3 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/cmk/ec/defaults.py b/cmk/ec/defaults.py
index 73d4683..d933ae8 100644
--- a/cmk/ec/defaults.py
+++ b/cmk/ec/defaults.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
@@ -23,21 +23,32 @@
# 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.
-
+"""Defaults for rule pack and configuration"""
import cmk.log
+# Clean this up one day by using the way recommended by gettext.
+# (See https://docs.python.org/2/library/gettext.html). For this we
+# need the path to the locale files here.
+try:
+ _
+except NameError:
+ _ = lambda x: x # Fake i18n when not available
+
+
def default_rule_pack(rules):
+ """Returns the default rule pack"""
return {
- "id" : "default",
- "title" : _("Default rule pack"),
- "rules" : rules,
- "disabled" : False,
+ "id": "default",
+ "title": _("Default rule pack"),
+ "rules": rules,
+ "disabled": False,
}
def default_config():
+ """Returns the default configuration"""
return {
"rules": [], # old pre 1.2.7i1 format. Only used if rule_packs is empty
"rule_packs": [], # new format with rule packages
@@ -57,7 +68,7 @@ def default_config():
"retention_interval": 60,
"housekeeping_interval": 60,
"statistics_interval": 5,
- "history_lifetime": 365, # days
+ "history_lifetime": 365, # days
"history_rotation": "daily",
"replication": None,
"remote_status": None,
diff --git a/cmk/ec/export.py b/cmk/ec/export.py
index 95173e0..b1bb825 100644
--- a/cmk/ec/export.py
+++ b/cmk/ec/export.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
@@ -44,10 +44,13 @@ import cmk.ec.settings
class MkpRulePackBindingError(Exception):
+
+ """Base class for exceptions related to rule pack binding"""
pass
class MkpRulePackProxy(UserDict.DictMixin):
+
"""
An object of this class represents an entry (i.e. a rule pack) in
mkp_rule_packs. It is used as a reference to an EC rule pack
@@ -56,6 +59,7 @@ class MkpRulePackProxy(UserDict.DictMixin):
A newly created instance is not yet connected to a specific rule pack.
This is achieved via the method bind_to.
"""
+
def __init__(self, rule_pack_id):
# Ideally the 'id_' would not be necessary and the proxy object would
# be bound to it's referenced object upon initialization. Unfortunately,
@@ -77,20 +81,25 @@ class MkpRulePackProxy(UserDict.DictMixin):
return '%s("%s")' % (self.__class__.__name__, self.id_)
def keys(self):
+ """List of keys of this rule pack"""
return self.rule_pack.keys()
def bind_to(self, mkp_rule_pack):
+ """Binds this rule pack to the given MKP rule pack"""
if self.id_ != mkp_rule_pack['id']:
- raise MkpRulePackBindingError('The IDs of %s and %s cannot be different.' % (self, mkp_rule_pack))
+ raise MkpRulePackBindingError(
+ 'The IDs of %s and %s cannot be different.' % (self, mkp_rule_pack))
self.rule_pack = mkp_rule_pack
@property
def is_bound(self):
+ """Has this rule pack been bound via bind_to()?"""
return self.rule_pack is not None
-class RulePackType(Enum):
+class RulePackType(Enum): # pylint: disable=too-few-public-methods
+
"""
A class to distinguishes the four kinds of rule pack types:
@@ -120,12 +129,11 @@ class RulePackType(Enum):
if not is_proxy and not is_packaged:
return RulePackType.internal
- elif is_proxy and not is_packaged:
+ if is_proxy and not is_packaged:
return RulePackType.exported
- elif is_proxy and is_packaged:
+ if is_proxy and is_packaged:
return RulePackType.unmodified_mkp
- else:
- return RulePackType.modified_mkp
+ return RulePackType.modified_mkp
def rule_pack_dir():
@@ -160,12 +168,13 @@ def read_rule_packs(context):
for rule in context["rules"]:
if "livetime" in rule:
livetime = rule["livetime"]
- if type(livetime) != tuple:
+ if not isinstance(livetime, tuple):
rule["livetime"] = (livetime, ["open"])
# Convert old plain rules into a list of one rule pack
if context["rules"] and not context["rule_packs"]:
- context["rule_packs"] = [cmk.ec.defaults.default_rule_pack(context["rules"])]
+ context["rule_packs"] = [
+ cmk.ec.defaults.default_rule_pack(context["rules"])]
def read_exported_rule_packs(context):
@@ -291,15 +300,15 @@ def add_rule_pack_proxies(file_names):
save_rule_packs(legacy_rules, rule_packs)
-def override_rule_pack_proxy(nr, rule_packs):
+def override_rule_pack_proxy(rule_pack_nr, rule_packs):
"""
Replaces a MkpRulePackProxy by a working copy of the underlying rule pack.
"""
- proxy = rule_packs[nr]
+ proxy = rule_packs[rule_pack_nr]
if not isinstance(proxy, MkpRulePackProxy):
raise TypeError('Expected an instance of %s got %s' %
(MkpRulePackProxy.__name__, proxy.__class__.__name__))
- rule_packs[nr] = copy.deepcopy(proxy.rule_pack)
+ rule_packs[rule_pack_nr] = copy.deepcopy(proxy.rule_pack)
def release_packaged_rule_packs(file_names):
@@ -362,6 +371,7 @@ def rule_pack_id_to_mkp(package_info):
MKP exists, the value of that mapping is None.
"""
def mkp_of(rule_pack_file):
+ """Find the MKP for the given file"""
for mkp, content in package_info.get('installed', {}).iteritems():
if rule_pack_file in content.get('files', {}).get('ec_rule_packs', []):
return mkp
diff --git a/tests/Makefile b/tests/Makefile
index 3dacf87..2b62c7d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -67,7 +67,7 @@ setup:
# TODO(sp): Proof of concept only for now, do this in a more general way
PYTHONPATH := $(realpath ..)
MYPYPATH := $(realpath typeshed)
-FILES_TO_CHECK := $(realpath ../cmk/ec/settings.py)
+FILES_TO_CHECK := $(realpath $(addprefix ../cmk/ec/,defaults.py export.py settings.py))
sanitize: format test-mypy test-pylint-simple
Module: check_mk
Branch: master
Commit: a69a187767830448cce0079a2ce46b47a5c4c0dc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a69a1877678304…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Tue Mar 13 14:58:48 2018 +0100
5911 FIX mem.linux: Fixed Perf-O-Meter displaying wrong usage if swap is used
In 1.5.0 the Perf-O-Meter for Linux memory services has been reworked. However
it's showing wrong usage if swap is used. In all other cases it is not used
at all (division by zero). This is now fixed.
Change-Id: Iad3290bf5f70230df008ee226d872f4464c7f43f
---
.werks/5911 | 12 ++++++++++++
web/plugins/metrics/check_mk.py | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/.werks/5911 b/.werks/5911
new file mode 100644
index 0000000..4d0c697
--- /dev/null
+++ b/.werks/5911
@@ -0,0 +1,12 @@
+Title: mem.linux: Fixed Perf-O-Meter displaying wrong usage if swap is used
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1520949390
+Class: fix
+
+In 1.5.0 the Perf-O-Meter for Linux memory services has been reworked. However
+it's showing wrong usage if swap is used. In all other cases it is not used
+at all (division by zero). This is now fixed.
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 1ac6928..af91f66 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -5721,7 +5721,7 @@ perfometer_info.append({
"mem_free",
"swap_free"
],
- "label" : ("mem_total,mem_used,+,swap_used,/,100,*", "%"),
+ "label" : ("mem_used,swap_used,+,mem_total,/,100,*", "%"),
})
perfometer_info.append({