Module: check_mk
Branch: master
Commit: 9764860adefb1fbf7e8329b8304f01776eb01a83
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9764860adefb1f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Apr 17 16:49:11 2015 +0200
if64, if64_tplink: convert implementation to use parse function
---
checks/if64 | 14 +++++++-------
checks/if64_tplink | 22 +++++++---------------
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/checks/if64 b/checks/if64
index 325e4bf..58e4197 100644
--- a/checks/if64
+++ b/checks/if64
@@ -24,20 +24,19 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-def fix_if64_highspeed(info):
+def parse_if64(info):
+ parsed = []
for line in info:
- if type(line[4]) == str: # not yet converted
- line[4] = saveint(line[4]) * 1000000
+ # Fix for switches like DLINK, with empty lines in MIB
+ if saveint(line[1]) > 0:
+ parsed.append(line[:4] + [saveint(line[4]) * 1000000] + line[5:])
+ return parsed
def inventory_if64(info):
- # Fix for switches like DLINK, with empty lines in MIB
- info = [ x for x in info if saveint(x[1]) > 0 ]
- fix_if64_highspeed(info)
return inventory_if_common(info, has_nodeinfo = True)
def check_if64(item, params, info):
- fix_if64_highspeed(info)
return check_if_common(item, params, info, has_nodeinfo = True)
@@ -65,6 +64,7 @@ def if64_scan_function(oid):
check_info["if64"] = {
+ "parse_function": parse_if64,
'check_function': check_if64,
'inventory_function': inventory_if64,
'service_description': 'Interface %s',
diff --git a/checks/if64_tplink b/checks/if64_tplink
index 01376b2..e958077 100644
--- a/checks/if64_tplink
+++ b/checks/if64_tplink
@@ -24,25 +24,17 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-def fix_tplink_highspeed(info):
+def parse_if64_tplink(info):
+ parsed = []
for line in info:
- if type(line[3]) == str: # not yet converted
- line[3] = saveint(line[3]) * 1000000
+ parsed.append(line[:3] + [ int(line[3]) * 1000000 ] + line[4:])
+ return parsed
-def inventory_tplink(info):
- fix_tplink_highspeed(info)
- return inventory_if_common(info)
-
-def check_tplink(item, params, info):
- fix_tplink_highspeed(info)
- return check_if_common(item, params, info)
-
-
-# check if number of network interfaces (IF-MIB::ifNumber.0) is at least 2
check_info["if64_tplink"] = {
- 'check_function': check_tplink,
- 'inventory_function': inventory_tplink,
+ 'parse_function': parse_if64_tplink,
+ 'check_function': check_if_common,
+ 'inventory_function': inventory_if_common,
'service_description': 'Interface %s',
'has_perfdata': True,
'includes': [ 'if.include' ],