예제 #1
0
파일: slabs.c 프로젝트: 4e/memcached
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c) {
    bool ret = true;

    if (add_stats != NULL) {
        if (!stat_type) {
            /* prepare general statistics for the engine */
            STATS_LOCK();
            APPEND_STAT("bytes", "%llu", (unsigned long long)stats.curr_bytes);
            APPEND_STAT("curr_items", "%u", stats.curr_items);
            APPEND_STAT("total_items", "%u", stats.total_items);
            APPEND_STAT("evictions", "%llu",
                        (unsigned long long)stats.evictions);
            APPEND_STAT("reclaimed", "%llu",
                        (unsigned long long)stats.reclaimed);
            STATS_UNLOCK();
        } else if (nz_strcmp(nkey, stat_type, "items") == 0) {
            item_stats(add_stats, c);
        } else if (nz_strcmp(nkey, stat_type, "slabs") == 0) {
            slabs_stats(add_stats, c);
        } else if (nz_strcmp(nkey, stat_type, "sizes") == 0) {
            item_stats_sizes(add_stats, c);
        } else {
            ret = false;
        }
    } else {
        ret = false;
    }

    return ret;
}
예제 #2
0
파일: mc_slabs.c 프로젝트: yzou/kmemcache
/**
 * mc_get_stats() - get a datum for stats in binary protocol
 * @stat_type	:
 * @nkey	:
 * @f		:
 * @c		:
 *
 * Return 0 on success, otherwise errno.
 */
int mc_get_stats(const char *stat_type, int nkey, add_stat_fn f, void *c)
{
	int ret = 0;

	if (f) {
		if (!stat_type) {
			/* prepare general statistics for the engine */
			u32 curr_items;
			u32 total_items;
			u64 curr_bytes;

			curr_items = ATOMIC32_READ(stats.curr_items);
			curr_bytes = ATOMIC64_READ(stats.curr_bytes);
			total_items= ATOMIC32_READ(stats.total_items);

			APPEND_STAT("bytes", "%llu", (unsigned long long)curr_bytes);
			APPEND_STAT("curr_items", "%u", curr_items);
			APPEND_STAT("total_items", "%u", total_items);

			mc_item_stats_totals(f, c);
		} else if (nz_strcmp(nkey, stat_type, "items") == 0) {
			mc_item_stats(f, c);
		} else if (nz_strcmp(nkey, stat_type, "slabs") == 0) {
			mc_slabs_stats(f, c);
		} else if (nz_strcmp(nkey, stat_type, "sizes") == 0) {
			mc_item_stats_sizes(f, c);
		} else {
			ret = -EFAULT;
		}
	} else {
		ret = -EFAULT;
	}

	return ret;
}
예제 #3
0
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c) {
    bool ret = true;

    if (add_stats != NULL) {
        if (!stat_type) {
            /* prepare general statistics for the engine */
            STATS_LOCK();
            APPEND_STAT("bytes", "%llu", (unsigned long long)stats_state.curr_bytes);
            APPEND_STAT("curr_items", "%llu", (unsigned long long)stats_state.curr_items);
            APPEND_STAT("total_items", "%llu", (unsigned long long)stats.total_items);
            STATS_UNLOCK();
            if (settings.slab_automove > 0) {
                pthread_mutex_lock(&slabs_lock);
                APPEND_STAT("slab_global_page_pool", "%u", slabclass[SLAB_GLOBAL_PAGE_POOL].slabs);
                pthread_mutex_unlock(&slabs_lock);
            }
            item_stats_totals(add_stats, c);
        } else if (nz_strcmp(nkey, stat_type, "items") == 0) {
            item_stats(add_stats, c);
        } else if (nz_strcmp(nkey, stat_type, "slabs") == 0) {
            slabs_stats(add_stats, c);
        } else if (nz_strcmp(nkey, stat_type, "sizes") == 0) {
            item_stats_sizes(add_stats, c);
        } else if (nz_strcmp(nkey, stat_type, "sizes_enable") == 0) {
            item_stats_sizes_enable(add_stats, c);
        } else if (nz_strcmp(nkey, stat_type, "sizes_disable") == 0) {
            item_stats_sizes_disable(add_stats, c);
        } else {
            ret = false;
        }
    } else {
        ret = false;
    }

    return ret;
}