grr/server/grr_response_server/stats_server.py
def RunOnce(self):
    """Main method of this registry hook.

    StatsServer implementation may be overriden. If there's a "stats_server"
    module present in grr/local directory then
    grr.local.stats_server.StatsServer implementation will be used instead of
    a default one.
    """

    # Figure out which port to use.
    port = config.CONFIG["Monitoring.http_port"]
    if not port:
      logging.info("Monitoring server disabled.")
      return

    # TODO(user): Implement __contains__ for GrrConfigManager.
    max_port = config.CONFIG.Get("Monitoring.http_port_max", None)
    if max_port is None:
      # Use the same number of available ports as the adminui is using. If we
      # have 10 available for adminui we will need 10 for the stats server.
      adminui_max_port = config.CONFIG.Get("AdminUI.port_max",
                                           config.CONFIG["AdminUI.port"])
      max_port = port + adminui_max_port - config.CONFIG["AdminUI.port"]

    try:
      # pylint: disable=g-import-not-at-top
      from grr_response_server.local import stats_server
      # pylint: enable=g-import-not-at-top
      server_cls = stats_server.StatsServer
      logging.debug("Using local StatsServer")
    except ImportError:
      logging.debug("Using default StatsServer")
      server_cls = StatsServer

    for port in range(port, max_port + 1):
      try:
        logging.info("Starting monitoring server on port %d.", port)
        server_obj = server_cls(port)
        server_obj.Start()
        return
      except base_stats_server.PortInUseError as e:
        if e.port < max_port:
          logging.info(e.message)
          continue
        raise
Main method of this registry hook.

    StatsServer implementation may be overriden. If there's a "stats_server"
    module present in grr/local directory then
    grr.local.stats_server.StatsServer implementation will be used instead of
    a default one.
    
Main method of this registry hook.
StatsServer implementation may be overriden. If there's a "stats_server"
module present in grr/local directory then
grr.local.stats_server.StatsServer implementation will be used instead of
a default one.
Main method of this registry hook . StatsServer implementation may be overriden . If there ' s a " stats_server " module present in grr / local directory then grr . local . stats_server . StatsServer implementation will be used instead of a default one .
def RunOnce(self):
    port = config.CONFIG["Monitoring.http_port"]
    if not port:
      logging.info("Monitoring server disabled.")
      return
    max_port = config.CONFIG.Get("Monitoring.http_port_max", None)
    if max_port is None:
      adminui_max_port = config.CONFIG.Get("AdminUI.port_max",
                                           config.CONFIG["AdminUI.port"])
      max_port = port + adminui_max_port - config.CONFIG["AdminUI.port"]
    try:
      from grr_response_server.local import stats_server
      server_cls = stats_server.StatsServer
      logging.debug("Using local StatsServer")
    except ImportError:
      logging.debug("Using default StatsServer")
      server_cls = StatsServer
    for port in range(port, max_port + 1):
      try:
        logging.info("Starting monitoring server on port %d.", port)
        server_obj = server_cls(port)
        server_obj.Start()
        return
      except base_stats_server.PortInUseError as e:
        if e.port < max_port:
          logging.info(e.message)
          continue
        raise
def RunOnce ( self ) : port = config . CONFIG [ "Monitoring.http_port" ] if not port : logging . info ( "Monitoring server disabled." ) return max_port = config . CONFIG . Get ( "Monitoring.http_port_max" , None ) if max_port is None : adminui_max_port = config . CONFIG . Get ( "AdminUI.port_max" , config . CONFIG [ "AdminUI.port" ] ) max_port = port + adminui_max_port - config . CONFIG [ "AdminUI.port" ] try : from grr_response_server . local import stats_server server_cls = stats_server . StatsServer logging . debug ( "Using local StatsServer" ) except ImportError : logging . debug ( "Using default StatsServer" ) server_cls = StatsServer for port in range ( port , max_port + 1 ) : try : logging . info ( "Starting monitoring server on port %d." , port ) server_obj = server_cls ( port ) server_obj . Start ( ) return except base_stats_server . PortInUseError as e : if e . port < max_port : logging . info ( e . message ) continue raise
Main method of this registry hook.
Main method of this registry hook .
"""Main method of this registry hook.

    StatsServer implementation may be overriden. If there's a "stats_server"
    module present in grr/local directory then
    grr.local.stats_server.StatsServer implementation will be used instead of
    a default one.
    """ # Figure out which port to use. # TODO(user): Implement __contains__ for GrrConfigManager. # Use the same number of available ports as the adminui is using. If we # have 10 available for adminui we will need 10 for the stats server. # pylint: disable=g-import-not-at-top # pylint: enable=g-import-not-at-top
self