Example #1
0
def update(config_path, verbose):
    '''
    Run updates. Pass me path to config file which contains settings for redis
    as well as which soldat servers to process data for.
  '''

    with acquire_lock():

        start = time.time()
        # Parse our config yaml file
        config = Config(config_path)

        r = redis.Redis(**config.redis_connect)

        for server in config.servers:
            print(
                'Updating stats for {server.url_slug} ({server.title}) ({server.log_source})'
                .format(server=server))

            # Redis key name manager
            keys = Keys(config, server)

            # Limit our data to however much retention
            retention = Retention(r, keys, config, server)

            # Parse each of our soldat DIRs
            for soldat_dir in server.dirs:

                # Support getting logs via local files or ssh or ftp
                if server.log_source == 'local':
                    filemanager = LocalFileManager(r, keys, soldat_dir,
                                                   retention)
                elif server.log_source == 'ssh':
                    filemanager = SshFileManager(r, keys, soldat_dir,
                                                 retention,
                                                 server.connection_options)
                elif server.log_source == 'ftp':
                    filemanager = FtpFileManager(r, keys, soldat_dir,
                                                 retention,
                                                 server.connection_options)

                # Console logs
                try:
                    update_events(r, keys, retention, filemanager, server,
                                  verbose)
                except Exception:
                    logging.exception('Failed updating stats for %s (%s) (%s)',
                                      server.url_slug, server.title,
                                      server.log_source)

            # Trim old events
            retention.run_retention()
            print('Updating took {0} seconds'.format(
                round(time.time() - start, 2)))
Example #2
0
def run_update(config_path):
  '''
    Run updates. Pass me path to config file which contains settings for redis
    as well as which soldat servers to process data for.
  '''

  config = Config(config_path)

  r = redis.Redis(**config.redis_connect)

  for server in config.servers:
    print('Updating stats for {server}'.format(server=server.url_slug))
    keys = Keys(config, server)
    retention = Retention(config, keys, r)
    for soldat_dir in server.dirs:
      update_kills(r, keys, retention, soldat_dir)
      update_events(r, keys, soldat_dir)
    retention.run_retention()
Example #3
0
def run_update(config_path):
  '''
    Run updates. Pass me path to config file which contains settings for redis
    as well as which soldat servers to process data for.
  '''

  start = time.time()
  # Parse our config yaml file
  config = Config(config_path)

  r = redis.Redis(**config.redis_connect)

  for server in config.servers:
    print('Updating stats for {server}'.format(server=server.url_slug))

    # Redis key name manager
    keys = Keys(config, server)

    # Limit our data to however much retention
    retention = Retention(r, keys, config)

    # Parse each of our soldat DIRs
    for soldat_dir in server.dirs:

      # Support getting logs via local files or ssh or ftp
      if server.log_source == 'local':
        filemanager = LocalFileManager(r, keys, soldat_dir)
      elif server.log_source == 'ssh':
        filemanager = SshFileManager(r, keys, soldat_dir, server.connection_options)
      elif server.log_source == 'ftp':
        filemanager = FtpFileManager(r, keys, soldat_dir, server.connection_options)

      # Console logs
      update_events(r, keys, retention, filemanager)

    # Trim old events
    retention.run_retention()
    print('Updating took {0} seconds'.format(round(time.time() - start, 2)))