summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 01ccc55)
raw | patch | inline | side by side (parent: 01ccc55)
author | Sven Velt <sven@velt.de> | |
Wed, 22 Dec 2010 14:48:43 +0000 (15:48 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Wed, 22 Dec 2010 14:48:43 +0000 (15:48 +0100) |
Either use "command_prefix" in [nagixsc] for all service checks in this
conf file or use "_command_prefix" per host/sections. Last overwrites
the first.
Signed-off-by: Sven Velt <sven@velt.de>
conf file or use "_command_prefix" per host/sections. Last overwrites
the first.
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 19ef4166cd963bfd5381b8a512144f299273a289..827a104b26c849d855a4e919d3afcad22e342484 100644 (file)
--- a/nagixsc/__init__.py
+++ b/nagixsc/__init__.py
def exec_timeout_handler(signum, frame):
raise ExecTimeoutError
-def exec_check(host_name, service_descr, cmdline, timeout=None, timeout_returncode=2):
+def exec_check(host_name, service_descr, cmdline, cmdprefix='', timeout=None, timeout_returncode=2):
cmdarray = shlex.split(cmdline)
check = {}
check['commandline'] = cmdline
check['command'] = cmdarray[0].split(os.path.sep)[-1]
+ if cmdprefix:
+ check['fullcommandline'] = cmdprefix + ' ' + cmdline
+ cmdarray = shlex.split(cmdprefix) + cmdarray
+ else:
+ check['fullcommandline'] = cmdline
+
if timeout:
signal.signal(signal.SIGALRM, exec_timeout_handler)
signal.alarm(timeout)
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
add_pnp4nagios_template_hint = False
+ # Read "command_prefix" from "[nagixsc]", default "" (empty string)
+ try:
+ cmdprefix_conffile = config.get('nagixsc','command_prefix')
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+ cmdprefix_conffile = ''
+
# Sections are Hosts (not 'nagixsc'), options in sections are Services
hosts = config.sections()
if 'nagixsc' in hosts:
services = config.options(host)
+ # Look for host/section specific "command_prefix"
+ if '_command_prefix' in services:
+ cmdprefix = config.get(host, '_command_prefix')
+ else:
+ cmdprefix = cmdprefix_conffile
+
# Look for host check
if '_host_check' in services and not opt_service:
cmdline = config.get(host, '_host_check')
- check = exec_check(host_name, None, cmdline, timeout, timeout_returncode)
+ check = exec_check(host_name, None, cmdline, cmdprefix, timeout, timeout_returncode)
if add_pnp4nagios_template_hint and '|' in check['output']:
check['output'] += ' [%s]' % check['command']
checks.append(check)
if service[0] != '_':
cmdline = config.get(host, service)
- check = exec_check(host_name, service, cmdline, timeout, timeout_returncode)
+ check = exec_check(host_name, service, cmdline, cmdprefix, timeout, timeout_returncode)
if add_pnp4nagios_template_hint and '|' in check['output']:
check['output'] += ' [%s]' % check['command']
checks.append(check)