grr/server/grr_response_server/stats_store.py
def ReadStats(process_id_prefix,
              metric_name,
              time_range = None,
              token = None):
  """Reads past values for a given metric from the data-store.

  Args:
    process_id_prefix: String prefix used for matching process ids to query for.
    metric_name: Name of the metric to read past entries for.
    time_range: An optional tuple of RDFDateTime objects representing the range
      of timestamps to query for.
    token: Database token to use for querying the data.

  Returns:
    A nested dict containing all past values for a metric in a given time
    range. The dict is organized in the format expected by the
    StatsStoreDataQuery class (see the __init__ method of the class).
  """
  if _ShouldUseRelationalDB():
    stats_entries = data_store.REL_DB.ReadStatsStoreEntries(
        process_id_prefix,
        metric_name,
        time_range=time_range,
        max_results=_MAX_STATS_ENTRIES)
    return _ConvertStatsEntriesToDataQueryFormat(stats_entries)
  else:
    if time_range is None:
      time_range = data_store.DataStore.ALL_TIMESTAMPS

    stats_store_obj = aff4.FACTORY.Create(
        aff4_stats_store.StatsStore.DATA_STORE_ROOT,
        aff4_type=aff4_stats_store.StatsStore,
        mode="r",
        token=token)
    process_ids = stats_store_obj.ListUsedProcessIds()
    filtered_ids = [
        pid for pid in process_ids if pid.startswith(process_id_prefix)
    ]
    return stats_store_obj.MultiReadStats(
        process_ids=filtered_ids, metric_name=metric_name, timestamp=time_range)
Reads past values for a given metric from the data-store.

  Args:
    process_id_prefix: String prefix used for matching process ids to query for.
    metric_name: Name of the metric to read past entries for.
    time_range: An optional tuple of RDFDateTime objects representing the range
      of timestamps to query for.
    token: Database token to use for querying the data.

  Returns:
    A nested dict containing all past values for a metric in a given time
    range. The dict is organized in the format expected by the
    StatsStoreDataQuery class (see the __init__ method of the class).
  
Reads past values for a given metric from the data-store.
Reads past values for a given metric from the data - store .
def ReadStats(process_id_prefix,
              metric_name,
              time_range = None,
              token = None):
  if _ShouldUseRelationalDB():
    stats_entries = data_store.REL_DB.ReadStatsStoreEntries(
        process_id_prefix,
        metric_name,
        time_range=time_range,
        max_results=_MAX_STATS_ENTRIES)
    return _ConvertStatsEntriesToDataQueryFormat(stats_entries)
  else:
    if time_range is None:
      time_range = data_store.DataStore.ALL_TIMESTAMPS
    stats_store_obj = aff4.FACTORY.Create(
        aff4_stats_store.StatsStore.DATA_STORE_ROOT,
        aff4_type=aff4_stats_store.StatsStore,
        mode="r",
        token=token)
    process_ids = stats_store_obj.ListUsedProcessIds()
    filtered_ids = [
        pid for pid in process_ids if pid.startswith(process_id_prefix)
    ]
    return stats_store_obj.MultiReadStats(
        process_ids=filtered_ids, metric_name=metric_name, timestamp=time_range)
def ReadStats ( process_id_prefix , metric_name , time_range = None , token = None ) : if _ShouldUseRelationalDB ( ) : stats_entries = data_store . REL_DB . ReadStatsStoreEntries ( process_id_prefix , metric_name , time_range = time_range , max_results = _MAX_STATS_ENTRIES ) return _ConvertStatsEntriesToDataQueryFormat ( stats_entries ) else : if time_range is None : time_range = data_store . DataStore . ALL_TIMESTAMPS stats_store_obj = aff4 . FACTORY . Create ( aff4_stats_store . StatsStore . DATA_STORE_ROOT , aff4_type = aff4_stats_store . StatsStore , mode = "r" , token = token ) process_ids = stats_store_obj . ListUsedProcessIds ( ) filtered_ids = [ pid for pid in process_ids if pid . startswith ( process_id_prefix ) ] return stats_store_obj . MultiReadStats ( process_ids = filtered_ids , metric_name = metric_name , timestamp = time_range )
Reads past values for a given metric from the data-store.
Reads past values for a given metric from the data - store .
"""Reads past values for a given metric from the data-store.

  Args:
    process_id_prefix: String prefix used for matching process ids to query for.
    metric_name: Name of the metric to read past entries for.
    time_range: An optional tuple of RDFDateTime objects representing the range
      of timestamps to query for.
    token: Database token to use for querying the data.

  Returns:
    A nested dict containing all past values for a metric in a given time
    range. The dict is organized in the format expected by the
    StatsStoreDataQuery class (see the __init__ method of the class).
  """
A nested dict containing all past values for a metric in a given time
range. The dict is organized in the format expected by the
StatsStoreDataQuery class .
A nested dict containing all past values for a metric in a given time range . The dict is organized in the format expected by the StatsStoreDataQuery class .
process_id_prefix
String prefix used for matching process ids to query for.
String prefix used for matching process ids to query for .
metric_name
Name of the metric to read past entries for.
Name of the metric to read past entries for .
time_range
An optional tuple of RDFDateTime objects representing the range
of timestamps to query for.
An optional tuple of RDFDateTime objects representing the range of timestamps to query for .
token
Database token to use for querying the data.
Database token to use for querying the data .