summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e97877c)
raw | patch | inline | side by side (parent: e97877c)
author | Sven Velt <sven@velt.de> | |
Fri, 5 Mar 2010 12:06:52 +0000 (13:06 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Fri, 5 Mar 2010 12:06:52 +0000 (13:06 +0100) |
An empty command line entry in conf file did raise an error within
subprocess call. Now an unknow check result is returned.
Signed-off-by: Sven Velt <sven@velt.de>
subprocess call. Now an unknow check result is returned.
Signed-off-by: Sven Velt <sven@velt.de>
nagixsc/__init__.py | patch | blob | history |
diff --git a/nagixsc/__init__.py b/nagixsc/__init__.py
index 327208453ff60fb001768708c698a4f67a8301f6..54a2125519fb1b8dd86d7c1ded8af7cf140dd38a 100644 (file)
--- a/nagixsc/__init__.py
+++ b/nagixsc/__init__.py
##############################################################################
def exec_check(host_name, service_descr, cmdline):
+ cmdarray = shlex.split(cmdline)
+
+ check = {}
+ check['host_name'] = host_name
+ check['service_description'] = service_descr
+
+ if len(cmdarray) == 0:
+ check['output'] = 'No command line specified!'
+ check['returncode'] = 127
+ return check
+
try:
- cmd = subprocess.Popen(shlex.split(cmdline), stdout=subprocess.PIPE)
- output = cmd.communicate()[0].rstrip()
- retcode = cmd.returncode
+ cmd = subprocess.Popen(cmdarray, stdout=subprocess.PIPE)
+ check['output'] = cmd.communicate()[0].rstrip()
+ check['returncode'] = cmd.returncode
except OSError:
- output = 'Could not execute "%s"' % cmdline
- retcode = 127
+ check['output'] = 'Could not execute "%s"' % cmdline
+ check['returncode'] = 127
- return {'host_name':host_name, 'service_description':service_descr, 'returncode':retcode, 'output':output, 'timestamp':datetime.datetime.now().strftime('%s')}
+ check['timestamp'] = datetime.datetime.now().strftime('%s')
+ return check
##############################################################################