Module: check_mk
Branch: master
Commit: 8e4469f48933a09d1abb9b72aa5e9649814f3960
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8e4469f48933a0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 8 11:50:52 2013 +0200
Fix error handling in vSphere agent
---
agents/special/agent_vsphere | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index a832654..fca2522 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -67,7 +67,7 @@ long_options = [
try:
opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
except getopt.GetoptError, err:
- print str(err)
+ sys.stderr.write("%s\n" % err)
sys.exit(1)
opt_debug = False
@@ -97,9 +97,11 @@ for o,a in opts:
if len(args) == 1:
host_address = args[0]
+elif not args:
+ sys.stderr.write("ERROR: No host given.\n")
+ sys.exit(1)
else:
- sys.stderr.write("ERROR: No HOST given.\n")
- usage()
+ sys.stderr.write("ERROR: Please specify exactly one host.\n")
sys.exit(1)
def get_agent_info_tcp(hostname):