grr/server/grr_response_server/stats_server.py
def BuildVarzJsonString():
  """Builds Varz JSON string from all stats metrics."""

  results = {}
  for name, metric_info in iteritems(
      stats_collector_instance.Get().GetAllMetricsMetadata()):
    info_dict = dict(metric_type=metric_info.metric_type.name)
    if metric_info.value_type:
      info_dict["value_type"] = metric_info.value_type.name
    if metric_info.docstring:
      info_dict["docstring"] = metric_info.docstring
    if metric_info.units:
      info_dict["units"] = metric_info.units.name

    if metric_info.fields_defs:
      info_dict["fields_defs"] = []
      for field_def in metric_info.fields_defs:
        info_dict["fields_defs"].append((field_def.field_name,
                                         utils.SmartStr(field_def.field_type)))

      value = {}
      all_fields = stats_collector_instance.Get().GetMetricFields(name)
      for f in all_fields:
        joined_fields = ":".join(utils.SmartStr(fname) for fname in f)
        value[joined_fields] = _JSONMetricValue(
            metric_info,
            stats_collector_instance.Get().GetMetricValue(name, fields=f))
    else:
      value = _JSONMetricValue(
          metric_info,
          stats_collector_instance.Get().GetMetricValue(name))

    results[name] = dict(info=info_dict, value=value)

  encoder = json.JSONEncoder()
  return encoder.encode(results)
Builds Varz JSON string from all stats metrics.
Builds Varz JSON string from all stats metrics.
Builds Varz JSON string from all stats metrics .
def BuildVarzJsonString():
  results = {}
  for name, metric_info in iteritems(
      stats_collector_instance.Get().GetAllMetricsMetadata()):
    info_dict = dict(metric_type=metric_info.metric_type.name)
    if metric_info.value_type:
      info_dict["value_type"] = metric_info.value_type.name
    if metric_info.docstring:
      info_dict["docstring"] = metric_info.docstring
    if metric_info.units:
      info_dict["units"] = metric_info.units.name
    if metric_info.fields_defs:
      info_dict["fields_defs"] = []
      for field_def in metric_info.fields_defs:
        info_dict["fields_defs"].append((field_def.field_name,
                                         utils.SmartStr(field_def.field_type)))
      value = {}
      all_fields = stats_collector_instance.Get().GetMetricFields(name)
      for f in all_fields:
        joined_fields = ":".join(utils.SmartStr(fname) for fname in f)
        value[joined_fields] = _JSONMetricValue(
            metric_info,
            stats_collector_instance.Get().GetMetricValue(name, fields=f))
    else:
      value = _JSONMetricValue(
          metric_info,
          stats_collector_instance.Get().GetMetricValue(name))
    results[name] = dict(info=info_dict, value=value)
  encoder = json.JSONEncoder()
  return encoder.encode(results)
def BuildVarzJsonString ( ) : results = { } for name , metric_info in iteritems ( stats_collector_instance . Get ( ) . GetAllMetricsMetadata ( ) ) : info_dict = dict ( metric_type = metric_info . metric_type . name ) if metric_info . value_type : info_dict [ "value_type" ] = metric_info . value_type . name if metric_info . docstring : info_dict [ "docstring" ] = metric_info . docstring if metric_info . units : info_dict [ "units" ] = metric_info . units . name if metric_info . fields_defs : info_dict [ "fields_defs" ] = [ ] for field_def in metric_info . fields_defs : info_dict [ "fields_defs" ] . append ( ( field_def . field_name , utils . SmartStr ( field_def . field_type ) ) ) value = { } all_fields = stats_collector_instance . Get ( ) . GetMetricFields ( name ) for f in all_fields : joined_fields = ":" . join ( utils . SmartStr ( fname ) for fname in f ) value [ joined_fields ] = _JSONMetricValue ( metric_info , stats_collector_instance . Get ( ) . GetMetricValue ( name , fields = f ) ) else : value = _JSONMetricValue ( metric_info , stats_collector_instance . Get ( ) . GetMetricValue ( name ) ) results [ name ] = dict ( info = info_dict , value = value ) encoder = json . JSONEncoder ( ) return encoder . encode ( results )
Builds Varz JSON string from all stats metrics.
Builds Varz JSON string from all stats metrics .
"""Builds Varz JSON string from all stats metrics."""