diff options
-rw-r--r-- | runtime/statsobj.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/runtime/statsobj.c b/runtime/statsobj.c index 0be480b7..9169d7db 100644 --- a/runtime/statsobj.c +++ b/runtime/statsobj.c @@ -166,6 +166,56 @@ finalize_it: RETiRet; } +/* get all the object's countes together as CEE. */ +static rsRetVal +getStatsLineCEE(statsobj_t *pThis, cstr_t **ppcstr) +{ + cstr_t *pcstr; + ctr_t *pCtr; + DEFiRet; + + CHKiRet(cstrConstruct(&pcstr)); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("@cee: {"), 7); + + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("\""), 1); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("name"), 4); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("\""), 1); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT(":"), 1); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("\""), 1); + rsCStrAppendStr(pcstr, pThis->name); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("\""), 1); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT(","), 1); + + /* now add all counters to this line */ + pthread_mutex_lock(&pThis->mutCtr); + for(pCtr = pThis->ctrRoot ; pCtr != NULL ; pCtr = pCtr->next) { + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("\""), 1); + rsCStrAppendStr(pcstr, pCtr->name); + rsCStrAppendStrWithLen(pcstr, UCHAR_CONSTANT("\""), 1); + cstrAppendChar(pcstr, ':'); + switch(pCtr->ctrType) { + case ctrType_IntCtr: + rsCStrAppendInt(pcstr, *(pCtr->val.pIntCtr)); // TODO: OK????? + break; + case ctrType_Int: + rsCStrAppendInt(pcstr, *(pCtr->val.pInt)); + break; + } + if (pCtr->next != NULL) { + cstrAppendChar(pcstr, ','); + } else { + cstrAppendChar(pcstr, '}'); + } + + } + pthread_mutex_unlock(&pThis->mutCtr); + + CHKiRet(cstrFinalize(pcstr)); + *ppcstr = pcstr; + +finalize_it: + RETiRet; +} /* get all the object's countes together with object name as one line. */ |