示例#1
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    args = parse_command_line()

    if options.pycurl == 0 or options.pycurl == "0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = '1'

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init()
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()
            
    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
                                        sys.argv[0])
        command = args[0]
        if command == 'info':
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
示例#2
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    args = parse_command_line()
    skip_ssl_validation = False

    if unicode(options.pycurl) == u"0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = "1"

    if unicode(options.sslcheck) == u"0":
        skip_ssl_validation = True

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init(skip_ssl_validation)
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
                                        sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
示例#3
0
文件: ddagent.py 项目: hkaj/dd-agent
def main():
    # Deprecation notice
    from utils.deprecations import deprecate_old_command_line_tools
    deprecate_old_command_line_tools()

    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    define("use_simple_http_client", default=0, help="Use Tornado SimpleHTTPClient instead of CurlAsyncHTTPClient")
    args = parse_command_line()
    skip_ssl_validation = False
    use_simple_http_client = False

    if unicode(options.sslcheck) == u"0":
        skip_ssl_validation = True

    if unicode(options.use_simple_http_client) == u"1":
        use_simple_http_client = True

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init(skip_ssl_validation, use_simple_http_client=use_simple_http_client)
        try:
            app.run()
        except Exception:
            log.exception("Uncaught exception in the forwarder")
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
示例#4
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    args = parse_command_line()

    if unicode(options.pycurl) == u"0":
        os.environ["USE_SIMPLE_HTTPCLIENT"] = "1"

    if unicode(options.sslcheck) == u"0":
        # monkey-patch the AsyncHTTPClient code
        import tornado.simple_httpclient

        tornado.simple_httpclient.match_hostname = lambda x, y: None
        print ("Skipping SSL hostname validation, useful when using a transparent proxy")

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient

        app = init()
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (sys.argv[0])
        command = args[0]
        if command == "info":
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == "help":
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
示例#5
0
文件: pup.py 项目: bakins/dd-agent
 def get(self):
     dogstatsd_status = DogstatsdStatus.load_latest_status()
     forwarder_status = ForwarderStatus.load_latest_status()
     collector_status = CollectorStatus.load_latest_status()
     self.render(os.path.join(agent_root, "pup", "status.html"),
         port=port,
         platform=platform.platform(),
         agent_version=get_version(),
         python_version=platform.python_version(),
         logger_info=logger_info(),
         dogstatsd=dogstatsd_status.to_dict(),
         forwarder=forwarder_status.to_dict(),
         collector=collector_status.to_dict(),
     )
示例#6
0
文件: gui.py 项目: hutchic/dd-agent
 def latest_status(self):
     try:
         loaded_template = template.Loader(".")
         dogstatsd_status = DogstatsdStatus.load_latest_status()
         forwarder_status = ForwarderStatus.load_latest_status()
         collector_status = CollectorStatus.load_latest_status()
         generated_template = loaded_template.load("status.html").generate(
             port=22,
             platform=platform.platform(),
             agent_version=get_version(),
             python_version=platform.python_version(),
             logger_info=logger_info(),
             dogstatsd=dogstatsd_status.to_dict(),
             forwarder=forwarder_status.to_dict(),
             collector=collector_status.to_dict(),
         )
         return generated_template
     except Exception:
         return "Unable to fetch latest status"
示例#7
0
 def _info_all(self):
     CollectorStatus.print_latest_status(verbose=True)
     DogstatsdStatus.print_latest_status(verbose=True)
     ForwarderStatus.print_latest_status(verbose=True)
示例#8
0
 def _info_all(self):
     CollectorStatus.print_latest_status(verbose=True)
     DogstatsdStatus.print_latest_status(verbose=True)
     ForwarderStatus.print_latest_status(verbose=True)