Module: check_mk
Branch: master
Commit: 2b24271c0772febadc5313b4db4bd1ffc29356dd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b24271c0772fe…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 30 10:54:03 2018 +0200
Update to #6186
Change-Id: Ideabfe117b26fb0d8937f6b4c7e9c53c17dfb5ee
---
cmk_base/checking.py | 1 +
cmk_base/discovery.py | 60 +++++++++++++++++++++++++++++++--------------------
2 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index 40eac9c..c1c9fb1 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -268,6 +268,7 @@ def execute_check(multi_host_sections, hostname, ipaddress,
check_plugin_name, i
dont_submit = False
try:
+ # TODO: There is duplicate code with discovery._execute_discovery(). Find a
common place!
try:
section_content = multi_host_sections.get_section_content(hostname,
ipaddress, section_name,
for_discovery=False)
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index 8daf98f..8c5fd8f 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -872,33 +872,38 @@ def _execute_discovery(multi_host_sections, hostname, ipaddress,
check_plugin_na
except KeyError:
raise MKGeneralException("No such check type '%s'" %
check_plugin_name)
+ # Now do the actual discovery
try:
- section_content = multi_host_sections.get_section_content(hostname, ipaddress,
- check_plugin_name,
for_discovery=True)
- except MKParseFunctionError, e:
- if cmk.debug.enabled():
- x = e.exc_info()
- raise x[0], x[1], x[2] # re-raise the original exception to not destory the
trace
+ # TODO: There is duplicate code with checking.execute_check(). Find a common
place!
+ try:
+ section_content = multi_host_sections.get_section_content(hostname,
ipaddress,
+ check_plugin_name,
for_discovery=True)
+ except MKParseFunctionError, e:
+ if cmk.debug.enabled() or on_error == "raise":
+ x = e.exc_info()
+ if x[0] == item_state.MKCounterWrapped:
+ return []
+ else:
+ # re-raise the original exception to not destory the trace. This may
raise a MKCounterWrapped
+ # exception which need to lead to a skipped check instead of a crash
+ raise x[0], x[1], x[2]
- if on_error == "warn":
- section_name = checks.section_name_of(check_plugin_name)
- console.warning("Exception while parsing agent section '%s':
%s\n" % (section_name, e))
- elif on_error == "raise":
- raise
- return []
+ elif on_error == "warn":
+ section_name = checks.section_name_of(check_plugin_name)
+ console.warning("Exception while parsing agent section '%s':
%s\n" % (section_name, e))
- if section_content is None: # No data for this check type
- return []
+ return []
- # In case of SNMP checks but missing agent response, skip this check.
- # Special checks which still need to be called even with empty data
- # may declare this.
- if not section_content and checks.is_snmp_check(check_plugin_name) \
- and not checks.check_info[check_plugin_name]["handle_empty_info"]:
- return []
+ if section_content is None: # No data for this check type
+ return []
+
+ # In case of SNMP checks but missing agent response, skip this check.
+ # Special checks which still need to be called even with empty data
+ # may declare this.
+ if not section_content and checks.is_snmp_check(check_plugin_name) \
+ and not checks.check_info[check_plugin_name]["handle_empty_info"]:
+ return []
- # Now do the actual discovery
- try:
# Check number of arguments of discovery function. Note: This
# check for the legacy API will be removed after 1.2.6.
if len(inspect.getargspec(discovery_function).args) == 2:
@@ -1185,7 +1190,16 @@ def get_check_preview(hostname, use_caches, do_snmp_scan,
on_error):
continue # Skip not existing check silently
try:
- section_content = multi_host_sections.get_section_content(hostname,
ipaddress, section_name, for_discovery=True)
+ try:
+ section_content = multi_host_sections.get_section_content(hostname,
ipaddress, section_name, for_discovery=True)
+ except MKParseFunctionError, e:
+ if cmk.debug.enabled() or on_error == "raise":
+ x = e.exc_info()
+ # re-raise the original exception to not destory the trace. This
may raise a MKCounterWrapped
+ # exception which need to lead to a skipped check instead of a
crash
+ raise x[0], x[1], x[2]
+ else:
+ raise
except Exception, e:
if cmk.debug.enabled():
raise