コード例 #1
0
enum http_rc_e
action_cache_status (struct req_args_s *args)
{
	struct hc_resolver_stats_s s = {{0}};
	hc_resolver_info (resolver, &s);

	GString *gstr = g_string_new ("{");
	g_string_append_printf (gstr, " \"csm0\":{"
		"\"count\":%" G_GINT64_FORMAT ",\"max\":%u,\"ttl\":%lu},",
		s.csm0.count, s.csm0.max, s.csm0.ttl);
	g_string_append_printf (gstr, " \"meta1\":{"
		"\"count\":%" G_GINT64_FORMAT ",\"max\":%u,\"ttl\":%lu}",
		s.services.count, s.services.max, s.services.ttl);
	g_string_append_c (gstr, '}');
	return _reply_success_json (args, gstr);
}
コード例 #2
0
static enum http_rc_e
action_cache_status (const struct cache_args_s *args)
{
    struct hc_resolver_stats_s s;
    memset (&s, 0, sizeof (s));
    hc_resolver_info (resolver, &s);

    GString *gstr = g_string_new ("{");
    g_string_append_printf (gstr, " \"clock\":%lu,", s.clock);
    g_string_append_printf (gstr, " \"csm0\":{"
    "\"count\":%" G_GINT64_FORMAT ",\"max\":%u,\"ttl\":%lu},",
    s.csm0.count, s.csm0.max, s.csm0.ttl);
    g_string_append_printf (gstr, " \"meta1\":{"
    "\"count\":%" G_GINT64_FORMAT ",\"max\":%u,\"ttl\":%lu}",
    s.services.count, s.services.max, s.services.ttl);
    g_string_append_c (gstr, '}');
    return _reply_success_json (args->rp, gstr);
}
コード例 #3
0
ファイル: metacd_http.c プロジェクト: racciari/oio-sds
static enum http_rc_e
action_status(struct req_args_s *args)
{
    if (0 == strcasecmp("HEAD", args->rq->cmd))
        return _reply_success_json(args, NULL);
    if (0 != strcasecmp("GET", args->rq->cmd))
        return _reply_method_error(args);

    GString *gstr = g_string_sized_new (128);

    /* first, the stats about all the requests received */
    GArray *array = network_server_stat_getall(args->rq->client->server);
    for (guint i=0; i<array->len ; ++i) {
        struct server_stat_s *st = &g_array_index (array, struct server_stat_s, i);
        g_string_append_printf (gstr, "%s = %"G_GUINT64_FORMAT"\n",
        g_quark_to_string (st->which), st->value);
    }
    g_array_free (array, TRUE);

    /* some stats about the internal cache */
    struct hc_resolver_stats_s s = {0};
    hc_resolver_info(resolver, &s);

    g_string_append_printf(gstr, "gauge cache.dir.count = %"G_GINT64_FORMAT"\n", s.csm0.count);
    g_string_append_printf(gstr, "gauge cache.dir.max = %u\n", s.csm0.max);
    g_string_append_printf(gstr, "gauge cache.dir.ttl = %lu\n", s.csm0.ttl);
    g_string_append_printf(gstr, "gauge cache.dir.clock = %lu\n", s.clock);

    g_string_append_printf(gstr, "gauge cache.srv.count = %"G_GINT64_FORMAT"\n", s.services.count);
    g_string_append_printf(gstr, "gauge cache.srv.max = %u\n", s.services.max);
    g_string_append_printf(gstr, "gauge cache.srv.ttl = %lu\n", s.services.ttl);
    g_string_append_printf(gstr, "gauge cache.srv.clock = %lu\n", s.clock);

    gint64 count_down = 0;
    SRV_DO(count_down = lru_tree_count(srv_down));
    g_string_append_printf(gstr, "gauge down.srv = %"G_GINT64_FORMAT"\n",
                           count_down);

    args->rp->set_body_gstr(gstr);
    args->rp->set_status(HTTP_CODE_OK, "OK");
    args->rp->set_content_type("text/x-java-properties");
    args->rp->finalize();
    return HTTPRC_DONE;
}