Module: check_mk
Branch: master
Commit: 4968dcd8d60789044108fbd456062aca2178e4e0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4968dcd8d60789…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Tue Jul 17 10:52:08 2018 +0200
Be strict about discovery returning 2-tuples
lparstat_aix, windows_broadcom_bonding:
Remove empty comment string
cmk_base/discovery.py:
Remove the ValueError that never was,
and be more explicit. Adapt reality to
error message (no quadruples!)
Change-Id: I2793f59f897481da566433e3cb73fe071c55a0c1
---
checks/lparstat_aix | 2 +-
checks/windows_broadcom_bonding | 2 +-
cmk_base/discovery.py | 13 ++++++-------
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/checks/lparstat_aix b/checks/lparstat_aix
index 4ae565a..242736a 100644
--- a/checks/lparstat_aix
+++ b/checks/lparstat_aix
@@ -50,7 +50,7 @@ lparstat_default_levels = (5, 10)
def inventory_lparstat(info):
if len(info) >= 1 and len(info[-1]) >= 5:
- return [(None, "", "lparstat_default_levels")]
+ return [(None, "lparstat_default_levels")]
def check_lparstat(item, params, info):
if len(info) == 1:
diff --git a/checks/windows_broadcom_bonding b/checks/windows_broadcom_bonding
index a400ffa..f01270e 100644
--- a/checks/windows_broadcom_bonding
+++ b/checks/windows_broadcom_bonding
@@ -34,7 +34,7 @@
def inventory_windows_broadcom_bonding(info):
inventory = []
for line in info[1:]:
- inventory.append( (" ".join(line[:-1]), "", None) )
+ inventory.append( (" ".join(line[:-1]), None) )
return inventory
def check_windows_broadcom_bonding(item, params, info):
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index 9de6777..a4940f9 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -792,13 +792,12 @@ def _execute_discovery(multi_host_sections, hostname, ipaddress,
check_plugin_na
if len(entry) == 2: # comment is now obsolete
item, paramstring = entry
- else:
- try:
- item, paramstring = entry[0], entry[2]
- except ValueError:
- console.error("%s: Check %s returned invalid discovery data (not
2 or 3 elements): %r\n" %
- (hostname,
check_plugin_name, repr(entry)))
- continue
+ elif len(entry) == 3: # allow old school
+ item, __, paramstring = entry
+ else: # we really don't want longer tuples (or 1-tuples).
+ console.error("%s: Check %s returned invalid discovery data (not 2
or 3 elements): %r\n" %
+ (hostname,
check_plugin_name, repr(entry)))
+ continue
# Check_MK 1.2.7i3 defines items to be unicode strings. Convert non unicode
# strings here seamless. TODO remove this conversion one day and replace it