From 8ec6f3ce116ddbe6ae1fdfc47b2a0cda2c0347b7 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 24 Jan 2015 14:14:49 +1100 Subject: [PATCH] Add ckmsgq stats to stratifierstats. --- src/stratifier.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/stratifier.c b/src/stratifier.c index 635dbbbe..978551e6 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1514,6 +1514,21 @@ static void broadcast_ping(sdata_t *sdata) #define SAFE_HASH_OVERHEAD(HASHLIST) (HASHLIST ? HASH_OVERHEAD(hh, HASHLIST) : 0) +static void ckmsgq_stats(ckmsgq_t *ckmsgq, int size, json_t **val) +{ + int objects, generated; + int64_t memsize; + ckmsg_t *msg; + + mutex_lock(ckmsgq->lock); + DL_COUNT(ckmsgq->msgs, msg, objects); + generated = ckmsgq->messages; + mutex_unlock(ckmsgq->lock); + + memsize = (sizeof(ckmsg_t) + size) * objects; + JSON_CPACK(*val, "{si,si,si}", "count", objects, "memory", memsize, "generated", generated); +} + static char *stratifier_stats(sdata_t *sdata) { json_t *val = json_object(), *subval; @@ -1565,6 +1580,16 @@ static char *stratifier_stats(sdata_t *sdata) JSON_CPACK(subval, "{si,si,si}", "count", objects, "memory", memsize, "generated", generated); json_set_object(val, "shares", subval); + ckmsgq_stats(sdata->ssends, sizeof(smsg_t), &subval); + json_set_object(val, "ssends", subval); + /* Don't know exactly how big the string is so just count the pointer for now */ + ckmsgq_stats(sdata->srecvs, sizeof(char *), &subval); + json_set_object(val, "srecvs", subval); + ckmsgq_stats(sdata->ckdbq, sizeof(char *), &subval); + json_set_object(val, "ckdbq", subval); + ckmsgq_stats(sdata->stxnq, sizeof(json_params_t), &subval); + json_set_object(val, "stxnq", subval); + buf = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER); json_decref(val); LOGNOTICE("Stratifier stats: %s", buf);