Module: check_mk
Branch: master
Commit: 9ab3d8cbdd92dd2bca17ec6727c8ca0d49d68ff1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9ab3d8cbdd92dd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 28 12:10:12 2013 +0100
FIX Error messages of datasource programs (e.g. VSphere Agent) are now visible within
WATO
In previous versions, the error messages produced by datasource programs, e.g. during
service
inventory or host diagnose, were not visible in WATO. The messages are now processed to
be
shown in the GUI when an error occured.
---
.werks/288 | 10 ++++++++++
ChangeLog | 1 +
modules/check_mk_base.py | 14 ++++++++------
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/.werks/288 b/.werks/288
new file mode 100644
index 0000000..49913ea
--- /dev/null
+++ b/.werks/288
@@ -0,0 +1,10 @@
+Title: Error messages of datasource programs (e.g. VSphere Agent) are now visible within
WATO
+Level: 1
+Component: core
+Version: 1.2.3i7
+Date: 1385636887
+Class: fix
+
+In previous versions, the error messages produced by datasource programs, e.g. during
service
+inventory or host diagnose, were not visible in WATO. The messages are now processed to
be
+shown in the GUI when an error occured.
diff --git a/ChangeLog b/ChangeLog
index f7c377c..70ba72e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
1.2.3i7:
Core & Setup:
* 0217 FIX: More verbose error output for SNMP errors on the command line...
+ * 0288 FIX: Error messages of datasource programs (e.g. VSphere Agent) are now
visible within WATO...
Checks & Agents:
* 0060 cisco_fantray: new check for monitoring fan trays of Cisco Nexus switches
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index a1a5f60..e2aed27 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -613,21 +613,23 @@ def get_agent_info(hostname, ipaddress, max_cache_age):
# Get data in case of external program
def get_agent_info_program(commandline):
+ import subprocess
if opt_verbose:
sys.stderr.write("Calling external program %s\n" % commandline)
try:
- sout = os.popen(commandline + " 2>/dev/null")
- output = sout.read()
- exitstatus = sout.close()
+ p = subprocess.Popen(commandline, shell = True, stdout = subprocess.PIPE, stderr
= subprocess.PIPE)
+ exitstatus = p.wait()
+ stdout = p.stdout.read()
+ stderr = p.stderr.read()
except Exception, e:
raise MKAgentError("Could not execute '%s': %s" % (commandline,
e))
if exitstatus:
- if exitstatus >> 8 == 127:
+ if exitstatus == 127:
raise MKAgentError("Program '%s' not found (exit code 127)"
% (commandline,))
else:
- raise MKAgentError("Agent exited with code %d" % (exitstatus
>> 8,))
- return output
+ raise MKAgentError("Agent exited with code %d: %s" % (exitstatus,
stderr))
+ return stdout
# Get data in case of TCP
def get_agent_info_tcp(hostname, ipaddress, port = None):