Module: check_mk
Branch: master
Commit: 70b4656d0992ba66bee0578ae9a2a7c83b423c7f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=70b4656d0992ba…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Jan 10 13:23:36 2019 +0100
All special agents now return gracefully if no arguments are specified
The special agents agent_innovaphone, agent_prism and agent_tinkerforge
don't throw an exception anymore if they are called without an argument.
Change-Id: I55c670d604e2ec256d5cbffe0824de9ea0d910b8
---
agents/special/agent_innovaphone | 4 ++++
agents/special/agent_prism | 7 +++++++
agents/special/agent_tinkerforge | 8 +++++++-
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/agents/special/agent_innovaphone b/agents/special/agent_innovaphone
index 946672f..f032df6 100755
--- a/agents/special/agent_innovaphone
+++ b/agents/special/agent_innovaphone
@@ -29,6 +29,10 @@ import base64
import urllib2
import xml.etree.ElementTree as etree
+if len(sys.argv) != 4:
+ sys.stderr.write("usage: agent_innovaphone HOST USER PASSWORD\n")
+ sys.exit(1)
+
server = sys.argv[1]
user = sys.argv[2]
password = sys.argv[3]
diff --git a/agents/special/agent_prism b/agents/special/agent_prism
index 9f1e585..de3e18f 100755
--- a/agents/special/agent_prism
+++ b/agents/special/agent_prism
@@ -193,6 +193,13 @@ def main():
options, _args = parser.parse_args()
settings = vars(options)
+ if (settings.get('server') is None or settings.get('username') is
None or
+ settings.get('password') is None):
+ sys.stderr.write(
+ 'usage: agent_prism --server SERVER --username USER --password PASSWORD
[--port PORT]\n'
+ )
+ sys.exit(1)
+
req_headers = gen_headers(settings['username'],
settings['password'])
global base_url
diff --git a/agents/special/agent_tinkerforge b/agents/special/agent_tinkerforge
index b42b810..6f23dd6 100755
--- a/agents/special/agent_tinkerforge
+++ b/agents/special/agent_tinkerforge
@@ -58,6 +58,8 @@
# implemented
import os
+import socket
+import sys
from optparse import OptionParser
import time
@@ -279,7 +281,11 @@ def main():
return 1
conn = IPConnection()
- conn.connect(settings['host'], settings['port'])
+ try:
+ conn.connect(settings['host'], settings['port'])
+ except socket.error as e:
+ sys.stderr.write('%s\n' % e)
+ return 1
device_handlers = init_device_handlers()