Module: check_mk
Branch: master
Commit: 7310f2f1b5f52120330c8a247954fe5a357b64ff
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7310f2f1b5f521…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jan 22 09:21:51 2014 +0100
FIX Fix ugly Python exception in host diagnosis page in case of SNMP error
The stderr output of the SNMP commands is now captured correctly and displayed
at the correct place in case of an error.
---
.werks/453 | 10 ++++++++++
ChangeLog | 1 +
modules/snmp.py | 7 ++++---
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/.werks/453 b/.werks/453
new file mode 100644
index 0000000..6ab454a
--- /dev/null
+++ b/.werks/453
@@ -0,0 +1,10 @@
+Title: Fix ugly Python exception in host diagnosis page in case of SNMP error
+Level: 1
+Component: core
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1390378855
+
+The stderr output of the SNMP commands is now captured correctly and displayed
+at the correct place in case of an error.
diff --git a/ChangeLog b/ChangeLog
index e0257f1..c2bd82a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@
* 0426 FIX: Fixed processing of cached agent plugins / local scripts...
* 0451 FIX: Ignore missing check types when creating configuration for Nagios
* 0259 FIX: Fixed htpasswd permission problem in check_mk standalone installation...
+ * 0453 FIX: Fix ugly Python exception in host diagnosis page in case of SNMP
error...
Checks & Agents:
* 0306 esx_vsphere_counters: added missing ramdisk levels sfcbtickets
diff --git a/modules/snmp.py b/modules/snmp.py
index 1df83b1..17b2e91 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -407,7 +407,7 @@ def snmpwalk_on_suboid(hostname, ip, oid, hex_plain = False):
if opt_debug:
sys.stderr.write(' Running %s\n' % (command,))
- snmp_process = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE)
+ snmp_process = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
# Ugly(1): in some cases snmpwalk inserts line feed within one
# dataset. This happens for example on hexdump outputs longer
@@ -441,9 +441,10 @@ def snmpwalk_on_suboid(hostname, ip, oid, hex_plain = False):
except StopIteration:
pass
+ 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\n")
- raise MKSNMPError("SNMP Error on %s (Exit-Code: %d)" % (ip,
exitstatus))
+ sys.stderr.write(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