예제 #1
0
static void
stats_format_csv(StatsCluster *sc, gint type, StatsCounterItem *counter, gpointer user_data)
{
  GString *csv = (GString *) user_data;
  gchar *s_id, *s_instance, *tag_name;
  gchar buf[32];
  gchar state;

  s_id = stats_format_csv_escapevar(sc->key.id);
  s_instance = stats_format_csv_escapevar(sc->key.instance);

  if (sc->dynamic)
    state = 'd';
  else if (sc->use_count == 0)
    state = 'o';
  else
    state = 'a';

  tag_name = stats_format_csv_escapevar(stats_cluster_get_type_name(sc, type));
  g_string_append_printf(csv, "%s;%s;%s;%c;%s;%"G_GSIZE_FORMAT"\n",
                         stats_cluster_get_component_name(sc, buf, sizeof(buf)),
                         s_id, s_instance, state, tag_name, stats_counter_get(&sc->counter_group.counters[type]));
  g_free(tag_name);
  g_free(s_id);
  g_free(s_instance);
}
예제 #2
0
static gchar *
_construct_counter_item_name(StatsCluster *sc, gint type)
{
  GString *name = g_string_new("");

  g_string_append(name, sc->query_key);
  g_string_append(name, ".");
  g_string_append(name, stats_cluster_get_type_name(sc, type));

  return g_string_free(name, FALSE);
}
예제 #3
0
static void
stats_log_format_counter(StatsCluster *sc, gint type, StatsCounterItem *item, gpointer user_data)
{
  EVTREC *e = (EVTREC *) user_data;
  EVTTAG *tag;
  gchar buf[32];

  tag = evt_tag_printf(stats_cluster_get_type_name(type), "%s(%s%s%s)=%u", 
                       stats_cluster_get_component_name(sc, buf, sizeof(buf)),
                       sc->id,
                       (sc->id[0] && sc->instance[0]) ? "," : "",
                       sc->instance,
                       stats_counter_get(&sc->counters[type]));
  evt_rec_add_tag(e, tag);
}