Module: check_mk
Branch: master
Commit: 01dca1b313dd912f165f81a1e80ce73b9a4ae5bc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=01dca1b313dd91…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Mon Oct 8 09:41:08 2018 +0200
6794 FIX esx_vsphere_objects: Don't crash without matching rule
Since werk 6790 the check crashed if no matching rule was configured.
This has been fixed.
Change-Id: I40bddad90df544b2245908be73803d306319a2b8
---
.werks/6794 | 11 +++++++++++
checks/esx_vsphere_objects | 4 +++-
.../generictests/datasets/esx_vsphere_objects_1_regression.py | 2 +-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.werks/6794 b/.werks/6794
new file mode 100644
index 0000000..7041ed1
--- /dev/null
+++ b/.werks/6794
@@ -0,0 +1,11 @@
+Title: esx_vsphere_objects: Don't crash without matching rule
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1539342283
+Class: fix
+
+Since werk 6790 the check crashed if no matching rule was configured.
+This has been fixed.
diff --git a/checks/esx_vsphere_objects b/checks/esx_vsphere_objects
index e2fb178..8e8df5b 100644
--- a/checks/esx_vsphere_objects
+++ b/checks/esx_vsphere_objects
@@ -123,10 +123,12 @@ check_info['esx_vsphere_objects'] = {
def inventory_esx_vsphere_objects_count(parsed):
- return [(None, None)]
+ yield None, {}
def check_esx_vsphere_objects_count(_no_item, params, parsed):
+ if params is None:
+ params = {}
virtualmachines = [o for o in parsed.itervalues() if o.name.startswith("VM
")]
yield 0, "Virtualmachines: %d" % len(virtualmachines), [('vms',
len(virtualmachines))]
diff --git a/tests/unit/checks/generictests/datasets/esx_vsphere_objects_1_regression.py
b/tests/unit/checks/generictests/datasets/esx_vsphere_objects_1_regression.py
index 5454d9b..0bb49b5 100644
--- a/tests/unit/checks/generictests/datasets/esx_vsphere_objects_1_regression.py
+++ b/tests/unit/checks/generictests/datasets/esx_vsphere_objects_1_regression.py
@@ -60,7 +60,7 @@ discovery = {'': [('HostSystem 10.1.1.111', {}),
('VM virt1-1.4.2', {}),
('VM win2003', {}),
('VM win2016rechner', {})],
- 'count': [(None, None)]}
+ 'count': [(None, {})]}
checks = {'': [('HostSystem 10.1.1.111', 'default',