Module: check_mk
Branch: master
Commit: d6580433e128bc76acd2abda7ca6de6f7e7fa3b7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d6580433e128bc…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Nov 24 12:16:48 2016 +0100
updated werk text
---
.werks/4092 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.werks/4092 b/.werks/4092
index a60c7d2..3b9a46b 100644
--- a/.werks/4092
+++ b/.werks/4092
@@ -1,4 +1,4 @@
-Title: if.include: fixed wrong calculated number of interfaces which are up
+Title: if.include: fixed wrong calculated number of interfaces which are up in case of interface groups
Level: 1
Component: checks
Class: fix
Module: check_mk
Branch: master
Commit: 89337fce5980a4a15f55f13fcc3b2f57a170b5a0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=89337fce5980a4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 24 09:36:49 2016 +0100
4069 FIX cmciii.phase: Fixed broken check with some devices
The check failed to discover services on devices not reporting a
"device" info in the phase name.
The check also failed for devices having spaces in the unit names.
---
.werks/4069 | 13 +++++++++++++
ChangeLog | 1 +
checks/cmciii | 31 +++++++++++++++++++++++++------
3 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/.werks/4069 b/.werks/4069
new file mode 100644
index 0000000..66269ee
--- /dev/null
+++ b/.werks/4069
@@ -0,0 +1,13 @@
+Title: cmciii.phase: Fixed broken check with some devices
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i3
+Date: 1479976504
+
+The check failed to discover services on devices not reporting a
+"device" info in the phase name.
+
+The check also failed for devices having spaces in the unit names.
diff --git a/ChangeLog b/ChangeLog
index a186e1f..e38b932 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
* 4088 FIX: ntp: fixed incomplete data handling
* 4090 FIX: apc_rackpdu_power, apc_symmetra, apc_symmetra_input, apc_symmetra_output: some fixes...
* 4091 FIX: oracle_tablespace: Werk 3907 broke the detection of UNDO- and TEMP-Tablespaces
+ * 4069 FIX: cmciii.phase: Fixed broken check with some devices...
Multisite:
* 3974 FIX: Sorting comments in hover menu of comments icon by time now
diff --git a/checks/cmciii b/checks/cmciii
index 5300a88..5f0cb34 100644
--- a/checks/cmciii
+++ b/checks/cmciii
@@ -856,8 +856,15 @@ def reparse_cmciii_phase(parsed):
for name, value in inputs.items():
if name[1].find("Phase") != -1:
parts = name[1].split('.')
+
+ # Prepend an empty device name to handle the special case where
+ # no device name is given in the alias
+ if name[1].startswith("Phase "):
+ parts = [""] + parts
+
if len(parts) == 3:
device, phase, value_name = parts
+
else:
device, phase, value_name, value_name_add = parts
value_name = (value_name, value_name_add)
@@ -866,23 +873,35 @@ def reparse_cmciii_phase(parsed):
unit = units[unit_id-1][1]
phase = phase[-1]
+ # Device may contain spaces. Replace them because spaces will break
+ # item matching in the check.
+ device = device.replace(" ", "_")
+
output.setdefault((unit, device, phase), {})
output[(unit, device, phase)][value_name] = value
-
-
return output
def inventory_cmciii_phase(parsed):
parsed = reparse_cmciii_phase(parsed)
- for device, unit, phase in parsed.keys():
- yield "%s %s Phase %s" % (device, unit, phase), {}
+ for unit, device, phase in parsed.keys():
+ if device:
+ item = "%s %s Phase %s" % (unit, device, phase)
+ else:
+ item = "%s Phase %s" % (unit, phase)
+
+ yield item, {}
def check_cmciii_phase(item, params, parsed):
- device, unit, word, phase = item.split()
- data = reparse_cmciii_phase(parsed)[(device, unit, phase)]
+ item_parts = item.split()
+ if len(item_parts) == 3:
+ unit, device, phase = item_parts[0], "", item_parts[-1]
+ else:
+ unit, device, _unused, phase = item_parts
+
+ data = reparse_cmciii_phase(parsed)[(unit, device, phase)]
parsed = {}
parsed[item] = {}
Module: check_mk
Branch: master
Commit: 26e9776588779d568372824885cb70d6fae4ebe4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=26e9776588779d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 23 18:32:15 2016 +0100
Cleaned up all_hosts_untagged and all_clusters_untagged to use standard caching mechanism
---
modules/check_mk.py | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 38e60e0..633b330 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -619,21 +619,25 @@ def duplicate_hosts():
# Returns a set of all host names to be handled by this site
# hosts of other sitest or disabled hosts are excluded
-all_hosts_untagged = None
def all_active_realhosts():
- global all_hosts_untagged
- if all_hosts_untagged == None:
- all_hosts_untagged = filter_active_hosts(all_configured_realhosts())
- return all_hosts_untagged
+ active_realhosts = cmk_base.config_cache.get_set("active_realhosts")
+
+ if active_realhosts.is_empty():
+ active_realhosts.update(filter_active_hosts(all_configured_realhosts()))
+
+ return active_realhosts
+
# Returns a set of all cluster host names to be handled by
# this site hosts of other sitest or disabled hosts are excluded
-all_clusters_untagged = None
def all_active_clusters():
- global all_clusters_untagged
- if all_clusters_untagged == None:
- all_clusters_untagged = filter_active_hosts(all_configured_clusters())
- return all_clusters_untagged
+ active_clusters = cmk_base.config_cache.get_set("active_clusters")
+
+ if active_clusters.is_empty():
+ active_clusters.update(filter_active_hosts(all_configured_clusters()))
+
+ return active_clusters
+
# Returns a set of active hosts for this site
def filter_active_hosts(hostlist, keep_offline_hosts=False):
@@ -653,6 +657,7 @@ def filter_active_hosts(hostlist, keep_offline_hosts=False):
if (keep_offline_hosts or in_binary_hostlist(hostname, only_hosts))
and host_is_member_of_site(hostname, distributed_wato_site) ])
+
def host_is_member_of_site(hostname, site):
for tag in tags_of_host(hostname):
if tag.startswith("site:"):
@@ -660,6 +665,7 @@ def host_is_member_of_site(hostname, site):
# hosts without a site: tag belong to all sites
return True
+
def parse_hostname_list(args, with_clusters = True, with_foreign_hosts = False):
if with_foreign_hosts:
valid_hosts = all_configured_realhosts()
@@ -2415,8 +2421,6 @@ skipped_config_variable_names = [
"contacts",
"host_paths",
"timeperiods",
- "all_hosts_untagged",
- "all_clusters_untagged",
"extra_service_conf",
"extra_host_conf",
"extra_nagios_conf",
@@ -4139,14 +4143,6 @@ def cleanup_globals():
# | Code for reading the configuration files. |
# '----------------------------------------------------------------------'
-# These variables shal be ignored when performing checks which global
-# variables have been changed during runtime of e.g. the Check_MK
-# keepalive mode
-ignore_changed_global_variables = [
- 'all_hosts_untagged',
- 'all_clusters_untagged',
-]
-
vars_before_config = set([])
# Now - at last - we can read in the user's configuration files
@@ -4304,7 +4300,7 @@ def read_config_files(with_conf_d=True, validate_hosts=True):
vars_after_config = all_nonfunction_vars()
ignored_variables = set(['vars_before_config', 'parts',
'hosttags' ,'seen_hostnames',
- 'taggedhost' ,'hostname'] + ignore_changed_global_variables)
+ 'taggedhost' ,'hostname'])
errors = 0
for name in vars_after_config:
if name not in ignored_variables and name not in vars_before_config: