Module: check_mk
Branch: master
Commit: a82a80a9f3de7be20fa2338e973a41094d4acde9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a82a80a9f3de7b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 1 14:49:01 2014 +0200
Massive speedup of cmk --snmptranslate
---
.werks/1038 | 8 ++++++++
ChangeLog | 1 +
modules/check_mk.py | 19 ++++++++++---------
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/.werks/1038 b/.werks/1038
new file mode 100644
index 0000000..6e177a4
--- /dev/null
+++ b/.werks/1038
@@ -0,0 +1,8 @@
+Title: Massive speedup of cmk --snmptranslate
+Level: 1
+Component: core
+Version: 1.2.5i5
+Date: 1404218927
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 431281a..d07b938 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
Core & Setup:
* 1012 Fix quoting of backslashes in custom checks with nagios core...
NOTE: Please refer to the migration notes!
+ * 1038 Massive speedup of cmk --snmptranslate
* 1035 FIX: Do not fail on errors in *.mk files anymore - except in interactive
mode...
Checks & Agents:
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 9e943f5..22b912e 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4376,9 +4376,6 @@ def do_snmptranslate(walk):
for idx, line in enumerate(result):
result_lines.append((line, lines[idx]))
- # Add missing fields one by one
- for line in lines[len(result_lines):]:
- result_lines.extend(translate([line]))
except Exception, e:
print e
@@ -4386,17 +4383,21 @@ def do_snmptranslate(walk):
# Translate n-oid's per cycle
- entries_per_cycle = 50
+ entries_per_cycle = 500
translated_lines = []
walk_lines = file(path_walk).readlines()
- sys.stderr.write("Processing %d lines (%d per dot)\n" % (len(walk_lines),
entries_per_cycle))
- for i in range(0, len(walk_lines), entries_per_cycle):
- sys.stderr.write(".")
+ sys.stderr.write("Processing %d lines.\n" % len(walk_lines))
+
+ i = 0
+ while i < len(walk_lines):
+ sys.stderr.write("\r%d to go... " % (len(walk_lines) - i))
sys.stderr.flush()
process_lines = walk_lines[i:i+entries_per_cycle]
- translated_lines.extend(translate(process_lines))
- sys.stderr.write("\n")
+ translated = translate(process_lines)
+ i += len(translated)
+ translated_lines += translated
+ sys.stderr.write("\rfinished. \n")
# Output formatted
longest_translation = 40