X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=nagixsc_http2nagios.py;h=0a709a585b9ea745d5e376c480808ddcbf22d85e;hb=07780292ee133f25f46f64e25e32463f34ba66c6;hp=ad86b65eba536feb843e40198c1f06af8a55a11d;hpb=e49ca957f7c364fe2352f04e10c2529194c322da;p=nagixsc.git diff --git a/nagixsc_http2nagios.py b/nagixsc_http2nagios.py index ad86b65..0a709a5 100755 --- a/nagixsc_http2nagios.py +++ b/nagixsc_http2nagios.py @@ -22,6 +22,7 @@ from nagixsc import * parser = optparse.OptionParser() parser.add_option('-c', '', dest='cfgfile', help='Config file') +parser.add_option('-d', '--daemon', action='store_true', dest='daemon', help='Daemonize, go to background') parser.add_option('', '--nossl', action='store_true', dest='nossl', help='Disable SSL (overwrites config file)') parser.set_defaults(cfgfile='http2nagios.cfg') @@ -50,6 +51,10 @@ except ConfigParser.NoOptionError, e: print 'Config file error: %s ' % e sys.exit(1) +if os.access(config['checkresultdir'],os.W_OK) == False: + print 'Checkresult directory "%s" is not writable.' % config['checkresultdir'] + sys.exit(1) + users = {} for u in cfgread.options('users'): users[u] = cfgread.get('users', u) @@ -129,6 +134,9 @@ def main(): print 'SSL certificate "%s" not found!' % config['cert'] sys.exit(127) + if options.daemon: + daemonize(pidfile='/var/run/nagixsc_http2nagios.pid') + server = MyHTTPServer((config['ip'], config['port']), HTTP2NagiosHandler, ssl=config['ssl'], sslpemfile=config['cert']) try: server.serve_forever()