static const char *
__gen_stats(const dav_resource *resource, apr_pool_t *pool)
{
	DAV_XDEBUG_POOL(pool, 0, "%s()", __FUNCTION__);

	dav_rainx_server_conf *c = resource_get_server_config(resource);

	apr_global_mutex_lock(c->lock.handle);
	struct shm_stats_s *stats = apr_shm_baseaddr_get(c->shm.handle);
	apr_global_mutex_unlock(c->lock.handle);

	return apr_pstrcat(pool,
			STR_KV(time_all,       "counter req.time"),
			STR_KV(time_put,       "counter req.time.put"),
			STR_KV(time_get,       "counter req.time.get"),
			STR_KV(time_del,       "counter req.time.del"),
			STR_KV(time_stat,      "counter req.time.stat"),
			STR_KV(time_info,      "counter req.time.info"),
			STR_KV(time_raw,       "counter req.time.raw"),
			STR_KV(time_other,     "counter req.time.other"),

			STR_KV(req_all,       "counter req.hits"),
			STR_KV(req_chunk_put, "counter req.hits.put"),
			STR_KV(req_chunk_get, "counter req.hits.get"),
			STR_KV(req_chunk_del, "counter req.hits.del"),
			STR_KV(req_stat,      "counter req.hits.stat"),
			STR_KV(req_info,      "counter req.hits.info"),
			STR_KV(req_raw,       "counter req.hits.raw"),
			STR_KV(req_other,     "counter req.hits.other"),

			STR_KV(rep_2XX,       "counter rep.hits.2xx"),
			STR_KV(rep_4XX,       "counter rep.hits.4xx"),
			STR_KV(rep_5XX,       "counter rep.hits.5xx"),
			STR_KV(rep_other,     "counter rep.hits.other"),
			STR_KV(rep_403,       "counter rep.hits.403"),
			STR_KV(rep_404,       "counter rep.hits.404"),
			STR_KV(rep_bread,     "counter rep.bread"),
			STR_KV(rep_bwritten,  "counter rep.bwritten"),
			NULL);
}
Example #2
0
static const char *
__gen_stats(const dav_resource *resource, apr_pool_t *pool)
{
	struct shm_stats_s *stats = NULL;

	DAV_XDEBUG_POOL(pool, 0, "%s()", __FUNCTION__);

	memset(&stats, 0, sizeof(stats));
	dav_rainx_server_conf *c = NULL;
	c = resource_get_server_config(resource);
	apr_global_mutex_lock(c->lock.handle);
	stats = apr_shm_baseaddr_get(c->shm.handle);
	apr_global_mutex_unlock(c->lock.handle);

	apr_uint64_t req = rainx_stats_rrd_get_delta(&(stats->body.rrd_req_sec), 4);
	apr_uint64_t reqavgtime = rainx_stats_rrd_get_delta(&(stats->body.rrd_duration), 4);
	apr_uint64_t req_put = rainx_stats_rrd_get_delta(&(stats->body.rrd_req_put_sec), 4);
	apr_uint64_t reqavgtime_put = rainx_stats_rrd_get_delta(&(stats->body.rrd_put_duration), 4);
	apr_uint64_t req_get = rainx_stats_rrd_get_delta(&(stats->body.rrd_req_get_sec), 4);
	apr_uint64_t reqavgtime_get = rainx_stats_rrd_get_delta(&(stats->body.rrd_get_duration), 4);
	apr_uint64_t req_del = rainx_stats_rrd_get_delta(&(stats->body.rrd_req_del_sec), 4);
	apr_uint64_t reqavgtime_del = rainx_stats_rrd_get_delta(&(stats->body.rrd_del_duration), 4);

	apr_uint64_t r_time = 0, r_put_time = 0, r_get_time = 0, r_del_time = 0;
	if(req > 0)
		r_time = reqavgtime / req;
	if(req_put > 0)
		r_put_time = reqavgtime_put / req_put;
	if(req_get > 0)
		r_get_time = reqavgtime_get / req_get;
	if(req_del > 0)
		r_del_time = reqavgtime_del / req_del;

	double r_rate = 0, r_put_rate = 0, r_get_rate = 0, r_del_rate = 0;
	r_rate = (double)req / 4;
	r_put_rate = (double)req_put / 4;
	r_get_rate = (double)req_get / 4;
	r_del_rate = (double)req_del / 4;

	return apr_pstrcat(pool, 
			STR_KV(req_all,       "req.all"),
			STR_KV(req_chunk_put, "req.put"),
			STR_KV(req_chunk_get, "req.get"),
			STR_KV(req_chunk_del, "req.del"),
			STR_KV(req_stat,      "req.stat"),
			STR_KV(req_info,      "req.info"),
			STR_KV(req_raw,       "req.raw"),
			STR_KV(req_other,     "req.other"),
			STR_KV(rep_2XX,       "rep.2xx"),
			STR_KV(rep_4XX,       "rep.4xx"),
			STR_KV(rep_5XX,       "rep.5xx"),
			STR_KV(rep_other,     "rep.other"),
			STR_KV(rep_403,       "rep.403"),
			STR_KV(rep_404,       "rep.404"),
			STR_KV(rep_bread,     "rep.bread"),
			STR_KV(rep_bwritten,  "rep.bwritten"),
			apr_psprintf(pool, "rainx.reqpersec %f\n", r_rate),
			apr_psprintf(pool, "rainx.avreqtime %"APR_UINT64_T_FMT"\n", r_time),
			apr_psprintf(pool, "rainx.reqputpersec %f\n", r_put_rate),
			apr_psprintf(pool, "rainx.avputreqtime %"APR_UINT64_T_FMT"\n", r_put_time),
			apr_psprintf(pool, "rainx.reqgetpersec %f\n", r_get_rate),
			apr_psprintf(pool, "rainx.avgetreqtime %"APR_UINT64_T_FMT"\n", r_get_time),
			apr_psprintf(pool, "rainx.reqdelpersec %f\n", r_del_rate),
			apr_psprintf(pool, "rainx.avdelreqtime %"APR_UINT64_T_FMT"\n", r_del_time),
			NULL);
}