Module: check_mk
Branch: master
Commit: a7f00fedb650cd5f653c40f8cc68606cd4b6ae77
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a7f00fedb650cd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 9 11:37:49 2015 +0100
Cleaned up SNMP logging; Prepare inline SNMP handling for new end OID limiting
---
modules/check_mk.py | 5 ++---
modules/snmp.py | 11 ++++-------
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 578129a..d7927b7 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4889,9 +4889,8 @@ def cleanup_globals():
global g_timeout
g_timeout = None
- if 'g_snmp_sessions' in globals():
- global g_snmp_sessions
- g_snmp_sessions = {}
+ if has_inline_snmp and use_inline_snmp:
+ cleanup_inline_snmp_globals()
# Diagnostic function for detecting global variables that have
diff --git a/modules/snmp.py b/modules/snmp.py
index c376d06..4225dc4 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -141,7 +141,7 @@ def get_snmp_table(hostname, ip, check_type, oid_info):
if opt_use_snmp_walk or is_usewalk_host(hostname):
rowinfo = get_stored_snmpwalk(hostname, fetchoid)
elif has_inline_snmp and use_inline_snmp:
- rowinfo = inline_snmpwalk_on_suboid(hostname, check_type, fetchoid)
+ rowinfo = inline_snmpwalk_on_suboid(hostname, check_type, fetchoid, oid)
else:
rowinfo = snmpwalk_on_suboid(hostname, ip, fetchoid)
@@ -150,8 +150,7 @@ def get_snmp_table(hostname, ip, check_type, oid_info):
# .1.3.6.1.2.1.1.1.0 was being walked. We try to detect these situations
# by removing any duplicate OID information
if len(rowinfo) > 1 and rowinfo[0][0] == rowinfo[1][0]:
- if opt_verbose:
- sys.stderr.write("Detected broken SNMP agent. Ignoring duplicate
OID %s.\n" % rowinfo[0][0])
+ vverbose("Detected broken SNMP agent. Ignoring duplicate OID
%s.\n" % rowinfo[0][0])
rowinfo = rowinfo[:1]
columns.append((fetchoid, rowinfo))
@@ -419,8 +418,7 @@ def snmpwalk_on_suboid(hostname, ip, oid, hex_plain = False):
portspec = snmp_port_spec(hostname)
command = snmp_walk_command(hostname) + \
" -OQ -OU -On -Ot %s%s %s" % (ip, portspec, oid)
- if opt_debug:
- sys.stderr.write(' Running %s\n' % (command,))
+ vverbose(' Running %s\n' % command)
snmp_process = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
@@ -459,7 +457,6 @@ def snmpwalk_on_suboid(hostname, ip, oid, hex_plain = False):
error = snmp_process.stderr.read()
exitstatus = snmp_process.wait()
if exitstatus:
- if opt_verbose:
- sys.stderr.write(tty_red + tty_bold + "ERROR: " + tty_normal +
"SNMP error: %s\n" % error.strip())
+ verbose(tty_red + tty_bold + "ERROR: " + tty_normal + "SNMP error:
%s\n" % error.strip())
raise MKSNMPError("SNMP Error on %s: %s (Exit-Code: %d)" % (ip,
error.strip(), exitstatus))
return rowinfo