Module: check_mk
Branch: master
Commit: 9ef0193af36dd1e0e0b8a6a5fc5e985b995851f6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9ef0193af36dd1…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Tue Jul 10 13:09:37 2018 +0200
6226 Allow to match against the monitoring site in rules
This allows to apply rules only on specific sites. This is required
to make the feature expect regular messages work in a distibuted
environment with config replication.
Example: If you have three centrally configured event consoles,
and you want a device to regularily report to one of them, you
previously had no way to configure that only the one site reports
missing messages. Instead, all sites the device doesn't send messages
to would repeatedly open events. This limitation can now be
worked around by specifying to which site expect rules should apply.
Change-Id: Ie9557ee96d3e62169823593c3f41a70f03a853c9
---
.werks/6226 | 22 ++++++++++++++++++++++
cmk/ec/main.py | 8 ++++++++
web/plugins/wato/mkeventd.py | 16 +++++++++++++---
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/.werks/6226 b/.werks/6226
new file mode 100644
index 0000000..5bc2da3
--- /dev/null
+++ b/.werks/6226
@@ -0,0 +1,22 @@
+Title: Allow to match against the monitoring site in rules
+Level: 2
+Component: ec
+Class: feature
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1531314180
+
+This allows to apply rules only on specific sites. Restricting
+rules to sites can yield performance benefits in environments with
+many sites. Beyond that, this is required to make the feature expect
+regular messages work in a distributed environment with
+config replication.
+
+Example: If you have three centrally configured event consoles,
+and you want a device to regularily report to one of them, you
+previously had no way to configure that only the one site reports
+missing messages. Instead, all sites the device doesn't send messages
+to would repeatedly open events. This limitation can now be
+worked around by specifying to which site expect rules should apply.
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 01a34ca..93a0386 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -1199,6 +1199,10 @@ class EventServer(ECServerThread):
# in that case.
for rule in self._rules:
if "expect" in rule:
+
+ if not self.event_rule_matches_site(rule, event=None):
+ continue
+
# Interval is either a number of seconds, or pair of a number of seconds
# (e.g. 86400, meaning one day) and a timezone offset relative to UTC in hours.
interval = rule["expect"]["interval"]
@@ -1659,6 +1663,7 @@ class EventServer(ECServerThread):
def event_rule_matches_generic(self, rule, event):
generic_match_functions = [
+ self.event_rule_matches_site,
self.event_rule_matches_host,
self.event_rule_matches_ip,
self.event_rule_matches_facility,
@@ -1671,6 +1676,9 @@ class EventServer(ECServerThread):
return False
return True
+ def event_rule_matches_site(self, rule, event):
+ return "match_site" not in rule or cmk.omd_site() in rule["match_site"]
+
def event_rule_matches_host(self, rule, event):
if match(rule.get("match_host"), event["host"], complete=True) is False:
if self._config["debug_rules"]:
diff --git a/web/plugins/wato/mkeventd.py b/web/plugins/wato/mkeventd.py
index 8b5b2be..9633c9c 100644
--- a/web/plugins/wato/mkeventd.py
+++ b/web/plugins/wato/mkeventd.py
@@ -576,7 +576,10 @@ def vs_mkeventd_rule(customer=None):
"The options <i>week</i>, <i>two days</i> and <i>day</i> refer to "
"periodic intervals aligned at 00:00:00 on the 1st of January 1970. "
"You can specify a relative offset in hours in order to re-align this "
- "to any other point of time."),
+ "to any other point of time. In a distributed environment, make "
+ "sure to specify which site should expect the messages in the match "
+ "criteria above, else all sites with config replication will warn if "
+ "messages fail to arrive."),
optional_keys = False,
columns = 2,
elements = [
@@ -704,6 +707,13 @@ def vs_mkeventd_rule(customer=None):
case_sensitive = False,
)
),
+ ( "match_site",
+ DualListChoice(
+ title = _("Match site"),
+ help = _("Apply this rule only on the following sites"),
+ choices = config.get_event_console_site_choices(),
+ )
+ ),
( "match_host",
RegExpUnicode(
title = _("Match host"),
@@ -903,12 +913,12 @@ def vs_mkeventd_rule(customer=None):
title = _("Rule Properties"),
elements = elements,
optional_keys = [ "delay", "livetime", "count", "expect", "match_priority", "match_priority",
- "match_facility", "match_sl", "match_host", "match_ipaddress", "match_application", "match_timeperiod",
+ "match_facility", "match_sl", "match_host", "match_site", "match_ipaddress", "match_application", "match_timeperiod",
"set_text", "set_host", "set_application", "set_comment",
"set_contact", "cancel_priority", "cancel_application", "match_ok", "contact_groups", ],
headers = [
( _("Rule Properties"), [ "id", "description", "comment", "docu_url", "disabled", "customer" ] ),
- ( _("Matching Criteria"), [ "match", "match_host", "match_ipaddress", "match_application", "match_priority", "match_facility",
+ ( _("Matching Criteria"), [ "match", "match_site", "match_host", "match_ipaddress", "match_application", "match_priority", "match_facility",
"match_sl", "match_ok", "cancel_priority", "cancel_application", "match_timeperiod", "invert_matching" ]),
( _("Outcome & Action"), [ "state", "sl", "contact_groups", "actions", "actions_in_downtime",
"cancel_actions", "cancel_action_phases", "drop", "autodelete", "event_limit" ]),
Module: check_mk
Branch: master
Commit: d1b117f2c1ea076a8ca98e944cb816041b280f4c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1b117f2c1ea07…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jul 11 15:19:22 2018 +0200
Fixed a few consider-merging-isinstance warnings.
The unbelievable power of the distributive law in action...
Change-Id: I9bf7b9d59d2015e841b88630880dd3c305995f26
---
cmk/structured_data.py | 2 +-
cmk_base/config.py | 2 +-
cmk_base/data_sources/abstract.py | 4 +---
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/cmk/structured_data.py b/cmk/structured_data.py
index b6cfde5..6fb678a 100644
--- a/cmk/structured_data.py
+++ b/cmk/structured_data.py
@@ -112,7 +112,7 @@ class StructuredDataTree(object):
def _validate_tree_path(self, tree_path):
if not tree_path:
raise MKGeneralException("Empty tree path or zero.")
- if not (isinstance(tree_path, str) or isinstance(tree_path, unicode)):
+ if not (isinstance(tree_path, (str, unicode))):
raise MKGeneralException("Wrong tree path format. Must be of type string.")
if not (tree_path.endswith(":") or tree_path.endswith(".")):
raise MKGeneralException("No valid tree path.")
diff --git a/cmk_base/config.py b/cmk_base/config.py
index a3f3b37..e14688f 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -67,7 +67,7 @@ def get_default_config():
for key in get_variable_names():
value = getattr(default_config, key)
- if isinstance(value, dict) or isinstance(value, list):
+ if isinstance(value, (dict, list)):
value = copy.deepcopy(value)
cfg[key] = value
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index cbc1f0a..c63551b 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -415,9 +415,7 @@ class DataSource(object):
if isinstance(self._exception, MKEmptyAgentData):
status = self._exit_code_spec.get("empty_output", 2)
- elif isinstance(self._exception, MKAgentError) \
- or isinstance(self._exception, MKIPAddressLookupError) \
- or isinstance(self._exception, MKSNMPError):
+ elif isinstance(self._exception, (MKAgentError, MKIPAddressLookupError, MKSNMPError)):
status = self._exit_code_spec.get("connection", 2)
elif isinstance(self._exception, MKTimeout):
Module: check_mk
Branch: master
Commit: 7c825e2d5d6cc6eb74e7384120c22090bc98bf1d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7c825e2d5d6cc6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 10 17:17:25 2018 +0200
6342 FIX Fixed degraded SNMP check performance when using SNMP sub checks
When checking a host with SNMP sub checks which normally all get the same data, the
data was fetched multiple times. One time for each subcheck used for monitoring a host.
This resulted in significantly increased check times and time outs. All 1.5 versions
are affected by this issue.
We experienced this issue with a CMCiii device which is normally monitored by a set of
sub checks (cmciii.*).
Change-Id: I83494499ac31fa354b463388068e6551aea36a54
---
.werks/6342 | 18 ++++++++++++++++++
cmk_base/data_sources/snmp.py | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/.werks/6342 b/.werks/6342
new file mode 100644
index 0000000..82c4ec3
--- /dev/null
+++ b/.werks/6342
@@ -0,0 +1,18 @@
+Title: Fixed degraded SNMP check performance when using SNMP sub checks
+Level: 2
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1531235656
+
+When checking a host with SNMP sub checks which normally all get the same data, the
+data was fetched multiple times. One time for each subcheck used for monitoring a host.
+
+This resulted in significantly increased check times and time outs. All 1.5 versions
+are affected by this issue.
+
+We experienced this issue with a CMCiii device which is normally monitored by a set of
+sub checks (cmciii.*).
diff --git a/cmk_base/data_sources/snmp.py b/cmk_base/data_sources/snmp.py
index dbff296..23bcc0c 100644
--- a/cmk_base/data_sources/snmp.py
+++ b/cmk_base/data_sources/snmp.py
@@ -219,6 +219,11 @@ class SNMPDataSource(DataSource):
self._logger.debug("%s: Skip fetching data (persisted info exists)" % (check_plugin_name))
continue
+ # Prevent duplicate data fetching of identical section in case of SNMP sub checks
+ if section_name in info:
+ self._logger.debug("%s: Skip fetching data (section already fetched)" % (check_plugin_name))
+ continue
+
self._logger.debug("%s: Fetching data" % (check_plugin_name))
# oid_info can now be a list: Each element of that list is interpreted as one real oid_info