Module: check_mk
Branch: master
Commit: 498b206a903b97daad7bba663f89a18ece1348c4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=498b206a903b97…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Apr 29 09:53:20 2011 +0200
sped up use of stored snmp walks
---
ChangeLog | 1 +
modules/snmp.py | 5 +++++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b3a28e9..eafc253 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,7 @@
* Allow merging of dictionary based check parameters
* --debug now implies -v
* new option --debug: creates execution profile of check_mk itself
+ * sped up use of stored snmp walks
Multisite:
* FIX: webservice: suppress livestatus errors in multi-site setups
diff --git a/modules/snmp.py b/modules/snmp.py
index e9e0e60..bec9d6b 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -365,13 +365,16 @@ def get_stored_snmpwalk(hostname, oid):
sys.stderr.write("Getting %s from %s\n" % (oid, path))
if not os.path.exists(path):
raise MKGeneralException("No snmpwalk file %s\n" % path)
+
rowinfo = []
+ hot = False
for line in file(path):
parts = line.split(None, 1)
o = parts[0]
if o.startswith('.'):
o = o[1:]
if o == oid or o.startswith(oid_prefix + "."):
+ hot = True
if len(parts) > 1:
value = parts[1]
if agent_simulator:
@@ -381,4 +384,6 @@ def get_stored_snmpwalk(hostname, oid):
rowinfo.append((o, strip_snmp_value(value))) # return pair of OID and value
if dot_star:
return rowinfo # only return first (used by get_single_oid)
+ elif hot: # end of interesting part, no point in further search
+ return rowinfo
return rowinfo