Module: check_mk
Branch: master
Commit: cde5384212d70d2b1647ba3a4de3ac0101f0e171
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cde5384212d70d…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jul 17 11:02:28 2017 +0200
4976 FIX wmi_cpuload: Fixed UNKNOWN service state due to werk #4742
Some agent outputs do not include required sections 'computer_system'
and 'system_perf' and werk #4742 fixed that. But if required tables
are specified the wmi.include lib performed an intersection of these
tables. In case of wmi_cpuload check plugin 'system_perf' section
has only counters and comes together with 'computer_system' which has
table names and intersection of these tables would be empty.
Thus no service is discovered.
Change-Id: I537810883c67f23849e0971b33d4371b65c2ba20
---
.werks/4976 | 17 +++++++++++++++++
checks/wmi.include | 36 +++++++++++++++++++++++-------------
checks/wmi_cpuload | 3 ++-
3 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/.werks/4976 b/.werks/4976
new file mode 100644
index 0000000..ae8aafc
--- /dev/null
+++ b/.werks/4976
@@ -0,0 +1,17 @@
+Title: wmi_cpuload: Fixed UNKNOWN service state due to werk #4742
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1500281231
+
+Some agent outputs do not include required sections 'computer_system'
+and 'system_perf' and werk #4742 fixed that. But if required tables
+are specified the wmi.include lib performed an intersection of these
+tables. In case of wmi_cpuload check plugin 'system_perf' section
+has only counters and comes together with 'computer_system' which has
+table names and intersection of these tables would be empty.
+Thus no service is discovered.
diff --git a/checks/wmi.include b/checks/wmi.include
index da4c2e1..a87672c 100644
--- a/checks/wmi.include
+++ b/checks/wmi.include
@@ -207,20 +207,30 @@ def inventory_wmi_table(tables, **kwargs):
potential_instances = None
if isinstance(tables, dict):
- table_names = kwargs.get('required_tables', tables.keys())
-
- for table_name in table_names:
- if table_name not in tables:
- # if table is missing, nothing gets inventorized. This can
- # only happen if required_tables was set
- return []
-
+ required_tables = kwargs.get('required_tables', tables.keys())
+ if not set(required_tables) <= set(tables.keys()):
+ # if table is missing, nothing gets inventorized. This can
+ # only happen if required_tables was set
+ return []
+
+ if kwargs.get("skip_intersection", False):
+ # Unfortunately there are tables which do NOT provide any
+ # names. In this case we fallback to old behaviour.
+ #
+ # Eg. wmi_cpuload check plugin:
+ # 'system_perf' section has only counters and comes together
+ # with 'computer_system' which has table names and intersection
+ # of these tables would be empty. Thus no service is discovered.
+ potential_instances = [""]
+
+ else:
# inventarize one item per instance that exists in all tables
- table_rows = tables[table_name].row_labels()
- if potential_instances is None:
- potential_instances = set(table_rows)
- else:
- potential_instances &= set(table_rows)
+ for required_table in required_tables:
+ table_rows = tables[required_table].row_labels()
+ if potential_instances is None:
+ potential_instances = set(table_rows)
+ else:
+ potential_instances &= set(table_rows)
else:
potential_instances = tables.row_labels()
diff --git a/checks/wmi_cpuload b/checks/wmi_cpuload
index 954dce7..0a96466 100644
--- a/checks/wmi_cpuload
+++ b/checks/wmi_cpuload
@@ -27,7 +27,8 @@
def inventory_wmi_cpuload(parsed):
return inventory_wmi_table(parsed, \
- required_tables = [ "computer_system", "system_perf"
])
+ required_tables = [ "computer_system", "system_perf"
],
+ skip_intersection=True)
def check_wmi_cpuload(item, params, parsed):