summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b3fcf0f)
raw | patch | inline | side by side (parent: b3fcf0f)
author | Sven Velt <sven@velt.de> | |
Wed, 13 Jan 2010 21:55:15 +0000 (22:55 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Wed, 13 Jan 2010 21:55:15 +0000 (22:55 +0100) |
nagixsc.py | patch | blob | history | |
nagixsc_conf2xml.py | patch | blob | history |
diff --git a/nagixsc.py b/nagixsc.py
index 21fc9a85009f732559eabb7b54cbcab505e1db97..d65aa09591406e85d9fbde3c1e79206433e5859b 100644 (file)
--- a/nagixsc.py
+++ b/nagixsc.py
import base64
import datetime
import libxml2
+import shlex
+import subprocess
import sys
def debug(level, verb, string):
return base64.b64encode(data)
+##############################################################################
+
+def exec_check(host_name, service_descr, cmdline):
+ try:
+ cmd = subprocess.Popen(shlex.split(cmdline), stdout=subprocess.PIPE)
+ output = cmd.communicate()[0].rstrip()
+ retcode = cmd.returncode
+ except OSError:
+ output = 'Could not execute "%s"' % cmdline
+ retcode = 127
+
+ return {'host_name':host_name, 'service_description':service_descr, 'returncode':retcode, 'output':output, 'timestamp':datetime.datetime.now().strftime('%s')}
+
+
##############################################################################
def read_xml(options):
diff --git a/nagixsc_conf2xml.py b/nagixsc_conf2xml.py
index d1ae4a8c9cbe351a0eda691d793c7b878f7e2af2..42ebcbcb5b29599055c03a666f9f30c59e39b3b4 100755 (executable)
--- a/nagixsc_conf2xml.py
+++ b/nagixsc_conf2xml.py
import ConfigParser
import optparse
-import shlex
-import subprocess
import sys
##############################################################################
##############################################################################
-def exec_check(host_name, service_descr, cmdline):
- try:
- cmd = subprocess.Popen(shlex.split(cmdline), stdout=subprocess.PIPE)
- output = cmd.communicate()[0].rstrip()
- retcode = cmd.returncode
- except OSError:
- output = 'Could not execute "%s"' % cmdline
- retcode = 127
-
- return {'host_name':host_name, 'service_description':service_descr, 'returncode':retcode, 'output':output, 'timestamp':datetime.datetime.now().strftime('%s')}
-
-##############################################################################
-
config = ConfigParser.RawConfigParser()
config.optionxform = str # We need case-sensitive options
conf_list = config.read(options.conffile)