示例#1
0
    def __init__(self,
                 requestHandler=GlancesXMLRPCHandler,
                 cached_time=1,
                 config=None,
                 args=None):
        # Args
        self.args = args

        # Init the XML RPC server
        try:
            self.server = GlancesXMLRPCServer(args.bind_address, args.port,
                                              requestHandler)
        except Exception as e:
            logger.critical("Cannot start Glances server: {0}".format(e))
            sys.exit(2)

        # The users dict
        # username / password couple
        # By default, no auth is needed
        self.server.user_dict = {}
        self.server.isAuth = False

        # Register functions
        self.server.register_introspection_functions()
        self.server.register_instance(GlancesInstance(cached_time, config))

        if not self.args.disable_autodiscover:
            # Note: The Zeroconf service name will be based on the hostname
            self.autodiscover_client = GlancesAutoDiscoverClient(
                socket.gethostname(), args)
        else:
            logger.info("Glances autodiscover announce is disabled")
示例#2
0
    def __init__(self,
                 requestHandler=GlancesXMLRPCHandler,
                 config=None,
                 args=None):
        # Args
        self.args = args

        # Init the XML RPC server
        try:
            self.server = GlancesXMLRPCServer(args.bind_address, args.port, requestHandler)
        except Exception as e:
            logger.critical("Cannot start Glances server: {}".format(e))
            sys.exit(2)
        else:
            print('Glances XML-RPC server is running on {}:{}'.format(args.bind_address, args.port))

        # The users dict
        # username / password couple
        # By default, no auth is needed
        self.server.user_dict = {}
        self.server.isAuth = False

        # Register functions
        self.server.register_introspection_functions()
        self.server.register_instance(GlancesInstance(config, args))

        if not self.args.disable_autodiscover:
            # Note: The Zeroconf service name will be based on the hostname
            # Correct issue: Zeroconf problem with zeroconf service name #889
            self.autodiscover_client = GlancesAutoDiscoverClient(socket.gethostname().split('.', 1)[0], args)
        else:
            logger.info("Glances autodiscover announce is disabled")