Module: check_mk
Branch: master
Commit: 54ebfddad693e6449784c0bc4e6bf8f449a6535a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=54ebfddad693e6…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Jun 2 15:35:12 2014 +0200
agent_ibmsvc: now supporting older python versions and throw error if there is a
authentication failure
---
agents/special/agent_ibmsvc | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/agents/special/agent_ibmsvc b/agents/special/agent_ibmsvc
old mode 100755
new mode 100644
index d536d9d..3e3ac39
--- a/agents/special/agent_ibmsvc
+++ b/agents/special/agent_ibmsvc
@@ -136,7 +136,7 @@ for o,a in opts:
elif o in [ '-t', '--timeout' ]:
opt_timeout = int(a)
elif o in [ '-k', '--accept-any-hostkey' ]:
- opt_any_hostkey = "-o UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no"
+ opt_any_hostkey = "-o StrictHostKeyChecking=no"
elif o in [ '-h', '--help' ]:
usage()
sys.exit(0)
@@ -182,12 +182,21 @@ cmd += "'"
if opt_debug:
sys.stderr.write("executing external command: %s\n" % cmd)
-try:
- for line in subprocess.check_output(cmd, shell=True).split('\n'):
- print line,
-except subprocess.CalledProcessError:
+
+
+result = subprocess.Popen(cmd, shell=True, stdout = subprocess.PIPE, stderr =
subprocess.PIPE, stdin = None)
+stdout, stderr = result.communicate()
+exit_code = result.wait()
+
+if exit_code not in [ 0, 1 ]:
print "Error connecting via ssh"
- sys.exit(1)
+ sys.exit(2)
+
+if stdout.startswith("CMMVC7016E"):
+ print str(stdout)
+ sys.exit(2)
+for line in stdout.split('\n'):
+ print line
#############################################################################