Code

Small fix if run in "checkresult" mode
[nagixsc.git] / nagixsc_http2nagios.py
index 4c23fe50d908cf549b6df4e25cfaab5a5bf82956..ad86b65eba536feb843e40198c1f06af8a55a11d 100755 (executable)
@@ -22,6 +22,7 @@ from nagixsc import *
 parser = optparse.OptionParser()
 
 parser.add_option('-c', '', dest='cfgfile', help='Config file')
+parser.add_option('', '--nossl', action='store_true', dest='nossl', help='Disable SSL (overwrites config file)')
 
 parser.set_defaults(cfgfile='http2nagios.cfg')
 
@@ -111,16 +112,19 @@ class HTTP2NagiosHandler(MyHTTPRequestHandler):
                                self.wfile.write('Wrote %s check results, %s failed' % (count_services, count_failed))
                                return
                        else:
-                               http_error(500, 'Could not write all %s check results' % count_services)
+                               self.http_error(501, 'Could not write all %s check results' % count_services)
                                return
 
                else:
-                       http_error(500, 'Nag(IX)SC - No data received')
+                       self.http_error(502, 'Nag(IX)SC - No data received')
                        return
 
 
 
 def main():
+       if options.nossl:
+               config['ssl'] = False
+
        if config['ssl'] and not os.path.isfile(config['cert']):
                print 'SSL certificate "%s" not found!' % config['cert']
                sys.exit(127)