Module: check_mk
Branch: master
Commit: 071746664ec40ff327790a3aaaeb7c303f04ba01
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=071746664ec40f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed May 13 09:46:28 2015 +0200
More verbose output on cmk -vv during SNMP scan
---
modules/check_mk.py | 29 ++++++++++++++++++-----------
modules/discovery.py | 15 +++++++++++----
2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index efbc70b..698398b 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -801,22 +801,29 @@ def get_single_oid(hostname, ipaddress, oid):
if oid in g_single_oid_cache:
return g_single_oid_cache[oid]
+ vverbose(" Getting OID %s: " % oid)
if opt_use_snmp_walk or is_usewalk_host(hostname):
walk = get_stored_snmpwalk(hostname, oid)
if len(walk) == 1:
- return walk[0][1]
+ value = walk[0][1]
else:
- return None
+ value = None
- try:
- if has_inline_snmp and use_inline_snmp:
- value = inline_snmp_get_oid(hostname, oid)
- else:
- value = snmp_get_oid(hostname, ipaddress, oid)
- except:
- if opt_debug:
- raise
- value = None
+ else:
+ try:
+ if has_inline_snmp and use_inline_snmp:
+ value = inline_snmp_get_oid(hostname, oid)
+ else:
+ value = snmp_get_oid(hostname, ipaddress, oid)
+ except:
+ if opt_debug:
+ raise
+ value = None
+
+ if value != None:
+ vverbose("%s%s%s%s\n" % (tty_bold, tty_green, value, tty_normal))
+ else:
+ vverbose("failed.\n")
g_single_oid_cache[oid] = value
return value
diff --git a/modules/discovery.py b/modules/discovery.py
index 1b60441..26399e4 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -325,7 +325,7 @@ def snmp_scan(hostname, ipaddress, for_inv=False):
global g_hostname
g_hostname = hostname
- vverbose(" SNMP scan:")
+ vverbose(" SNMP scan:\n")
if not in_binary_hostlist(hostname, snmp_without_sys_descr):
sys_descr_oid = ".1.3.6.1.2.1.1.1.0"
sys_descr = get_single_oid(hostname, ipaddress, sys_descr_oid)
@@ -338,6 +338,9 @@ def snmp_scan(hostname, ipaddress, for_inv=False):
else:
items = check_info.items()
+ positive_found = []
+ default_found = []
+
for check_type, check in items:
if check_type in ignored_checktypes:
continue
@@ -363,7 +366,7 @@ def snmp_scan(hostname, ipaddress, for_inv=False):
(check_type, type(result)))
elif result:
found.append(check_type)
- vverbose(" " + check_type)
+ positive_found.append(check_type)
except MKGeneralException:
# some error messages which we explicitly want to show to the user
# should be raised through this
@@ -372,9 +375,13 @@ def snmp_scan(hostname, ipaddress, for_inv=False):
pass
else:
found.append(check_type)
- vverbose(" " + tty_blue + tty_bold + check_type + tty_normal)
+ default_found.append(check_type)
+
+ vverbose(" SNMP scan found: %s%s%s%s\n" % (tty_bold, tty_yellow,
" ".join(positive_found), tty_normal))
+ if default_found:
+ vverbose(" without scan function: %s%s%s%s\n" % (tty_bold, tty_blue,
" ".join(default_found), tty_normal))
+
- vverbose("\n")
found.sort()
return found