Module: check_mk
Branch: master
Commit: fd0f7d1d19982e8d53b384e1bd847cf8d0a1415b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fd0f7d1d19982e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Nov 6 13:31:23 2010 +0100
check_mk -I snmp will try all checks without scan function
---
ChangeLog | 2 ++
LIESMICH.zutun | 3 ---
checks/ifoperstatus | 5 ++---
checks/snmp_info | 3 +++
modules/check_mk.py | 15 ++++++++++++++-
5 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8be561a..815e857 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,8 @@
make Nagios reject the configuration.
* --snmpwalk: do not translate anymore, use numbers. All checks work
with numbers now anyway.
+ * check_mk -I snmp will now try all checktypes not having an snmp scan
+ function. That way all possible checks should be inventorized.
Checks & Agents:
* megaraid_pdisks: Using the real enclosure number as check item now
diff --git a/LIESMICH.zutun b/LIESMICH.zutun
index 48f8913..da47ea0 100644
--- a/LIESMICH.zutun
+++ b/LIESMICH.zutun
@@ -80,9 +80,6 @@ getrennte Checks für Memory and Pagefile.
-------------------------------------------------------------------------------
ab 1.1.9i1:
--------------------------------------------------------------------------------
-IDEE: Scan-Modus: Wenn man einen Host per SNMP scannt und *keine*
-Antwort kommt, dann probiert man einfach alle SNMP-Checks aus.
-
PNP4Nagios-Popups automatisch einbauen, mit eigenen intelligenten
Icons.
diff --git a/checks/ifoperstatus b/checks/ifoperstatus
index 4861ee9..5241fd6 100644
--- a/checks/ifoperstatus
+++ b/checks/ifoperstatus
@@ -59,6 +59,5 @@ def check_ifoperstatus(item, targetstate, info):
check_info['ifoperstatus'] = (check_ifoperstatus, "Interface %s", 0,
inventory_ifoperstatus)
snmp_info['ifoperstatus'] = ( ".1.3.6.1.2.1.2.2.1", [ 2, 3, 8 ] )
-# check if number of network interfaces (IF-MIB::ifNumber.0) is at least 2
-# snmp_scan_functions['ifoperstatus'] = \
-# lambda oid: int(oid(".1.3.6.1.2.1.2.1.0")) >= 2
+# Never inventorize automatically. let if/if64 be the default
+snmp_scan_functions['ifoperstatus'] = lambda oid: False
diff --git a/checks/snmp_info b/checks/snmp_info
index 4577f7d..62b5b47 100644
--- a/checks/snmp_info
+++ b/checks/snmp_info
@@ -38,3 +38,6 @@ def check_snmp_info(checktype, params, info):
check_info['snmp_info'] = (check_snmp_info, "SNMP Info", 0,
inventory_snmp_info)
snmp_info_single['snmp_info'] = ( None, ".1.3.6.1.2.1.1", [
"1.0", "4.0", "5.0", "6.0" ] )
+
+# Do not use this check per default
+snmp_scan_functions['snmp_info'] = lambda oid: False
diff --git a/modules/check_mk.py b/modules/check_mk.py
index b77d01f..8472556 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -665,10 +665,21 @@ def snmp_scan(hostname, ipaddress):
try:
if detect_function(lambda oid: get_single_oid(hostname, ipaddress, oid)):
found.append(checktype)
- sys.stdout.write("%s " % checktype)
+ sys.stdout.write(tty_green + tty_bold + checktype + " " +
tty_normal)
sys.stdout.flush()
except:
pass
+
+ # Now try all checks not having a scan function
+ for checktype in check_info.keys():
+ datatype = checktype.split('.')[0]
+ if datatype not in snmp_info:
+ continue # no snmp check
+ if checktype not in snmp_scan_functions:
+ sys.stdout.write(tty_blue + tty_bold + checktype + tty_normal + "
")
+ sys.stdout.flush()
+ found.append(checktype)
+
if found == []:
sys.stdout.write("nothing detected.\n")
else:
@@ -1583,6 +1594,8 @@ def do_snmp_scan(hostnamelist):
continue
checknames = snmp_scan(hostname, ipaddress)
for checkname in checknames:
+ if opt_debug:
+ sys.stdout.write("Trying inventory for %s on %s\n" %
(checkname, hostname))
make_inventory(checkname, [hostname])