summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6507bf3)
raw | patch | inline | side by side (parent: 6507bf3)
author | Sven Velt <sven@velt.de> | |
Tue, 8 Dec 2009 21:57:12 +0000 (22:57 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Tue, 8 Dec 2009 21:57:12 +0000 (22:57 +0100) |
nagixsc_conf2xml.py | patch | blob | history |
diff --git a/nagixsc_conf2xml.py b/nagixsc_conf2xml.py
index 149bdd135827cfb96827d613179a9a0b0025fe87..029fa3fe2f6fd1692a8d8212cfae55f6c785bfa9 100755 (executable)
--- a/nagixsc_conf2xml.py
+++ b/nagixsc_conf2xml.py
parser.add_option('-c', '', dest='conffile', help='Config file')
parser.add_option('-o', '', dest='outfile', help='Output file')
parser.add_option('-e', '', dest='encoding', help='Encoding ("%s")' % '", "'.join(available_encodings()) )
+parser.add_option('-H', '', dest='host', help='Hostname/section to search for in config file')
+parser.add_option('-D', '', dest='service', help='Service description to search for in config file (needs -H)')
parser.add_option('-v', '', action='count', dest='verb', help='Verbose output')
parser.set_defaults(conffile='nagixsc.conf')
parser.set_defaults(outfile='-')
parser.set_defaults(encoding='base64')
+parser.set_defaults(host=None)
+parser.set_defaults(service=None)
parser.set_defaults(verb=0)
(options, args) = parser.parse_args()
if 'nagixsc' in hosts:
hosts.remove('nagixsc')
+# Filter out host/section if it exists
+if options.host:
+ if options.host in hosts:
+ hosts = [options.host,]
+ else:
+ hosts = []
+
for host in hosts:
# Overwrite section/host name with '_host_name'
if config.has_option(host,'_host_name'):
host_name = host
+ services = config.options(host)
# Look for host check
- if config.has_option(host,'_host_check'):
+ if '_host_check' in services and not options.service:
cmdline = config.get(host, '_host_check')
check = exec_check(host_name, None, cmdline)
checks.append(check)
- for service in config.options(host):
+ # Filter out service if it exists
+ if options.service:
+ if options.service in services:
+ services = [options.service,]
+ else:
+ services = []
+
+ for service in services:
# If option starts with '_' it may be a NagixSC option in the future
if service[0] != '_':
cmdline = config.get(host, service)