Module: check_mk
Branch: master
Commit: ed4172d34318c023edbc3a5c43c52a2cff1a9978
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ed4172d34318c0…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri Oct 25 13:21:59 2013 +0200
if/if64: Fixed check info in case of missing interface indexes
---
checks/if | 3 ++-
checks/if64 | 32 ++++++++++++++++++++++++--------
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/checks/if b/checks/if
index 4cc331d..458beb0 100644
--- a/checks/if
+++ b/checks/if
@@ -33,7 +33,8 @@ def check_if(item, params, info):
def if_convert_to_if64(info):
newinfo = []
for line in info:
- newinfo.append(line[0:8] + ['0'] + line[8:12] + ['0'] +
line[12:16] + line[1:2] + line[16:17])
+ if saveint(line[0]) > 0: #Fix for switches with empty indexes
+ newinfo.append(line[0:8] + ['0'] + line[8:12] + ['0'] +
line[12:16] + line[1:2] + line[16:17])
return newinfo
check_includes['if'] = [ "if.include" ]
diff --git a/checks/if64 b/checks/if64
index d45d098..485d290 100644
--- a/checks/if64
+++ b/checks/if64
@@ -29,7 +29,9 @@ def fix_if64_highspeed(info):
if type(line[3]) == str: # not yet converted
line[3] = saveint(line[3]) * 1000000
+
def inventory_if64(info):
+ info = [ x for x in info if saveint(x[0]) > 0 ] #Fix for switches like DLINK, with
empty lines in MIB
fix_if64_highspeed(info)
return inventory_if_common(info)
@@ -38,7 +40,25 @@ def check_if64(item, params, info):
return check_if_common(item, params, info)
-# check if number of network interfaces (IF-MIB::ifNumber.0) is at least 2
+def if64_scan_function(oid):
+ ignored_strings = [
+ "LANCOM",
+ ]
+ for string in ignored_strings:
+ if string in oid(".1.3.6.1.2.1.1.1.0"):
+ return False
+
+ if ".4.1.11863." in oid(".1.3.6.1.2.1.1.2.0"):
+ return False
+
+ if if64_disabled(g_hostname):
+ return False
+
+ if oid(".1.3.6.1.2.1.31.1.1.1.6.*") != None:
+ return True
+ return False
+
+
check_info["if64"] = {
'check_function': check_if64,
@@ -68,11 +88,7 @@ check_info["if64"] = {
"31.1.1.1.18", # ifAlias 18
"2.2.1.6", # ifPhysAddress 19
]),
- 'snmp_scan_function': \
- lambda oid: "LANCOM" not in oid(".1.3.6.1.2.1.1.1.0") and \
- ".4.1.11863." not in oid(".1.3.6.1.2.1.1.2.0")
and \
- (not if64_disabled(g_hostname)) and \
- oid(".1.3.6.1.2.1.31.1.1.1.6.*") != None,
- 'group': 'if',
- 'default_levels_variable': 'if_default_levels',
+ 'snmp_scan_function' : if64_scan_function,
+ 'group' : 'if',
+ 'default_levels_variable' : 'if_default_levels',
}