summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8887856)
raw | patch | inline | side by side (parent: 8887856)
author | Sven Velt <sven@velt.de> | |
Thu, 17 Feb 2011 14:34:32 +0000 (15:34 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Thu, 17 Feb 2011 14:34:32 +0000 (15:34 +0100) |
Signed-off-by: Sven Velt <sven@velt.de>
nagixsc_xml2cfg.py | patch | blob | history | |
sample-configs/xml2cfg_tmpl/host.tmpl | patch | blob | history |
diff --git a/nagixsc_xml2cfg.py b/nagixsc_xml2cfg.py
index 284a9d31dc0b14aa7c4ff642b2ff52538a210e37..9cbd179cd93a4507512b58abf31362221fc73efb 100755 (executable)
--- a/nagixsc_xml2cfg.py
+++ b/nagixsc_xml2cfg.py
import datetime
import libxml2
import optparse
+import socket
import sys
parser = optparse.OptionParser()
use templ_host_default
host_name %(host_name)s
- address 127.0.0.1
+ address %(address)s
}
'''
checks = xml_to_dict(doc, options.verb, options.host, options.service)
+# Set default socket options
+if hasattr(socket, 'setdefaulttimeout'):
+ socket.setdefaulttimeout(2)
+
# Loop over check results and search for new hosts and new services
foundhosts = []
foundhosts.append(check['host_name'])
if 'hosts' in options.output:
+ try:
+ check['address'] = socket.gethostbyname(check['host_name'])
+ except socket.gaierror:
+ check['address'] = '127.0.0.1'
print HOSTTEMPL % check
if check['service_description'] and 'services' in options.output:
index 7846d814c91c876b9ff17f93d7b655150f51cc2c..6a54e045b3eea20919a7665d7f8411aa8be81b80 100644 (file)
use templ_host_default
host_name %(host_name)s
- address 127.0.0.1
+ address %(address)s
}