Module: check_mk
Branch: master
Commit: 8116520226afc6a33227ea76f49767ebd28a6c6e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8116520226afc6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 20 16:38:48 2015 +0100
Fixed shortly introduced problems with diskstat discovery
---
modules/check_mk_base.py | 21 ++++++++++++++-------
modules/discovery.py | 10 +++++-----
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index a530599..28d1749 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -261,21 +261,28 @@ class MKCheckTimeout(Exception):
# extra sections (new feature since 1.2.7i1) only the main section
# raises exceptions. Error in extra sections are silently ignored
# and the info is replaced with None.
-def get_info_for_check(hostname, ipaddress, infotype, max_cachefile_age=None,
ignore_check_interval=False):
-
- if infotype in check_info:
- extra_sections = check_info[infotype]["extra_sections"]
+def get_info_with_extra_sections(hostname, ipaddress, section_name, max_cachefile_age,
ignore_check_interval, info_func):
+ if section_name in check_info:
+ extra_sections = check_info[section_name]["extra_sections"]
if extra_sections:
- info = [ get_host_info(hostname, ipaddress, infotype, max_cachefile_age,
ignore_check_interval) ]
+ info = [ info_func(hostname, ipaddress, section_name, max_cachefile_age,
ignore_check_interval) ]
for es in extra_sections:
try:
- info.append(get_host_info(hostname, ipaddress, es, max_cachefile_age,
ignore_check_interval=False))
+ info.append(info_func(hostname, ipaddress, es, max_cachefile_age,
ignore_check_interval=False))
except:
info.append(None)
return info
- return get_host_info(hostname, ipaddress, infotype, max_cachefile_age,
ignore_check_interval)
+ return info_func(hostname, ipaddress, section_name, max_cachefile_age,
ignore_check_interval)
+
+def get_info_for_check(hostname, ipaddress, section_name, max_cachefile_age=None,
ignore_check_interval=False):
+ return get_info_with_extra_sections(hostname, ipaddress, section_name,
+ max_cachefile_age, ignore_check_interval,
info_func=get_host_info)
+def get_info_for_inventory(hostname, ipaddress, section_name, use_caches):
+ return get_info_with_extra_sections(hostname, ipaddress, section_name,
+ use_caches and inventory_max_cachefile_age or 0,
+ ignore_check_interval=True,
info_func=get_realhost_info)
# This is the main function for getting information needed by a
# certain check. It is called once for each check type. For SNMP this
diff --git a/modules/discovery.py b/modules/discovery.py
index 59ce57c..d5c6270 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -349,13 +349,10 @@ def discover_check_type(hostname, ipaddress, check_type,
use_caches):
try:
info = None # default in case of exception
- info = get_realhost_info(hostname, ipaddress, section_name,
- use_caches and inventory_max_cachefile_age or 0,
ignore_check_interval=True)
-
+ info = get_info_for_inventory(hostname, ipaddress, section_name, use_caches)
except MKAgentError, e:
if str(e):
raise
-
except MKSNMPError, e:
if str(e):
raise
@@ -368,7 +365,10 @@ def discover_check_type(hostname, ipaddress, check_type,
use_caches):
# During inventory we behave like a non-cluster. We do not know
# yet if the service is going to be clustered!
if check_info[check_type]["node_info"]:
- info = [ [None] + line for line in info ]
+ if check_info[section_name]["extra_sections"]:
+ info = [ sec and [ [None] + line for line in sec ] or None for sec in info ]
+ else:
+ info = [ [None] + line for line in info ]
# Now do the actual inventory
try: