Module: check_mk
Branch: master
Commit: c593838683907194c4ff9021d010ceef3ad48cde
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c5938386839071…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 7 14:02:20 2015 +0100
Cleaned up cmk --snmpwalk code a bit
---
modules/check_mk.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index a43cb60..8d577db 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4352,13 +4352,14 @@ def output_plain_hostinfo(hostname):
sys.stdout.write(get_piggyback_info(hostname))
-def do_snmptranslate(walk):
- walk = walk[0]
+def do_snmptranslate(args):
+ if not args:
+ raise MKGeneralException("Please provide the name of a SNMP walk
file")
+ walk_filename = args[0]
- path_walk = "%s/%s" % (snmpwalks_dir, walk)
- if not os.path.exists(path_walk):
- print "Walk does not exist"
- return
+ walk_path = "%s/%s" % (snmpwalks_dir, walk_filename)
+ if not os.path.exists(walk_path):
+ raise MKGeneralException("Walk does not exist")
def translate(lines):
result_lines = []
@@ -4387,7 +4388,7 @@ def do_snmptranslate(walk):
entries_per_cycle = 500
translated_lines = []
- walk_lines = file(path_walk).readlines()
+ walk_lines = file(walk_path).readlines()
sys.stderr.write("Processing %d lines.\n" % len(walk_lines))
i = 0