summaryrefslogtreecommitdiffstats
path: root/runtime/statsobj.c
diff options
context:
space:
mode:
authorBrian Knox <briank@talksum.com>2012-04-01 18:37:43 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-04-01 18:37:43 +0200
commit74df1b744f9482a315d88dbc7465557afa96897d (patch)
tree0fadc09e408538c893765c064d14790481c30b4f /runtime/statsobj.c
parent9896cf16b7b799cbd3dc0c6f2a2c25b89a9478bc (diff)
downloadrsyslog-74df1b744f9482a315d88dbc7465557afa96897d.tar.gz
rsyslog-74df1b744f9482a315d88dbc7465557afa96897d.tar.xz
rsyslog-74df1b744f9482a315d88dbc7465557afa96897d.zip
stats module: added capability to format as cee-enhanced syslog
Diffstat (limited to 'runtime/statsobj.c')
-rw-r--r--runtime/statsobj.c50
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.
*/