From 7b9f421f1a036e063b9b3f9ebbb3311120632743 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Sat, 7 Sep 2013 15:58:09 +0200 Subject: experimental: make impstats return delta values where possible Conflicts: plugins/impstats/impstats.c plugins/imptcp/imptcp.c --- action.c | 4 ++-- plugins/imptcp/imptcp.c | 2 +- plugins/imudp/imudp.c | 2 +- plugins/imuxsock/imuxsock.c | 6 +++--- runtime/queue.c | 12 ++++++------ runtime/statsobj.c | 5 ++++- runtime/statsobj.h | 9 +++++++-- tcpsrv.c | 2 +- tools/omfile.c | 10 +++++----- 9 files changed, 30 insertions(+), 22 deletions(-) diff --git a/action.c b/action.c index 6b52d708..fd50f969 100644 --- a/action.c +++ b/action.c @@ -382,11 +382,11 @@ actionConstructFinalize(action_t *pThis, struct cnfparamvals *queueParams) STATSCOUNTER_INIT(pThis->ctrProcessed, pThis->mutCtrProcessed); CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("processed"), - ctrType_IntCtr, &pThis->ctrProcessed)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrProcessed)); STATSCOUNTER_INIT(pThis->ctrFail, pThis->mutCtrFail); CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("failed"), - ctrType_IntCtr, &pThis->ctrFail)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrFail)); CHKiRet(statsobj.ConstructFinalize(pThis->statsobj)); diff --git a/plugins/imptcp/imptcp.c b/plugins/imptcp/imptcp.c index 906521dd..baaec1a2 100644 --- a/plugins/imptcp/imptcp.c +++ b/plugins/imptcp/imptcp.c @@ -935,7 +935,7 @@ addLstn(ptcpsrv_t *pSrv, int sock, int isIPv6) CHKiRet(statsobj.SetName(pLstn->stats, statname)); STATSCOUNTER_INIT(pLstn->ctrSubmit, pLstn->mutCtrSubmit); CHKiRet(statsobj.AddCounter(pLstn->stats, UCHAR_CONSTANT("submitted"), - ctrType_IntCtr, &(pLstn->ctrSubmit))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pLstn->ctrSubmit))); CHKiRet(statsobj.ConstructFinalize(pLstn->stats)); /* add to start of server's listener list */ diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index 312645bd..e6a34f01 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -286,7 +286,7 @@ addListner(instanceConf_t *inst) CHKiRet(statsobj.SetName(newlcnfinfo->stats, dispname)); STATSCOUNTER_INIT(newlcnfinfo->ctrSubmit, newlcnfinfo->mutCtrSubmit); CHKiRet(statsobj.AddCounter(newlcnfinfo->stats, UCHAR_CONSTANT("submitted"), - ctrType_IntCtr, &(newlcnfinfo->ctrSubmit))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(newlcnfinfo->ctrSubmit))); CHKiRet(statsobj.ConstructFinalize(newlcnfinfo->stats)); /* link to list. Order must be preserved to take care for * conflicting matches. diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index c503852c..d1719d4a 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -1594,13 +1594,13 @@ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(statsobj.SetName(modStats, UCHAR_CONSTANT("imuxsock"))); STATSCOUNTER_INIT(ctrSubmit, mutCtrSubmit); CHKiRet(statsobj.AddCounter(modStats, UCHAR_CONSTANT("submitted"), - ctrType_IntCtr, &ctrSubmit)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &ctrSubmit)); STATSCOUNTER_INIT(ctrLostRatelimit, mutCtrLostRatelimit); CHKiRet(statsobj.AddCounter(modStats, UCHAR_CONSTANT("ratelimit.discarded"), - ctrType_IntCtr, &ctrLostRatelimit)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &ctrLostRatelimit)); STATSCOUNTER_INIT(ctrNumRatelimiters, mutCtrNumRatelimiters); CHKiRet(statsobj.AddCounter(modStats, UCHAR_CONSTANT("ratelimit.numratelimiters"), - ctrType_IntCtr, &ctrNumRatelimiters)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &ctrNumRatelimiters)); CHKiRet(statsobj.ConstructFinalize(modStats)); ENDmodInit diff --git a/runtime/queue.c b/runtime/queue.c index 935a8106..695dcae8 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -2172,26 +2172,26 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */ /* we need to save the queue size, as the stats module initializes it to 0! */ /* iQueueSize is a dual-use counter: no init, no mutex! */ CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("size"), - ctrType_Int, &pThis->iQueueSize)); + ctrType_Int, CTR_FLAG_NONE, &pThis->iQueueSize)); STATSCOUNTER_INIT(pThis->ctrEnqueued, pThis->mutCtrEnqueued); CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("enqueued"), - ctrType_IntCtr, &pThis->ctrEnqueued)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrEnqueued)); STATSCOUNTER_INIT(pThis->ctrFull, pThis->mutCtrFull); CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("full"), - ctrType_IntCtr, &pThis->ctrFull)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrFull)); STATSCOUNTER_INIT(pThis->ctrFDscrd, pThis->mutCtrFDscrd); CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("discarded.full"), - ctrType_IntCtr, &pThis->ctrFDscrd)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrFDscrd)); STATSCOUNTER_INIT(pThis->ctrNFDscrd, pThis->mutCtrNFDscrd); CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("discarded.nf"), - ctrType_IntCtr, &pThis->ctrNFDscrd)); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrNFDscrd)); pThis->ctrMaxqsize = 0; /* no mutex needed, thus no init call */ CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("maxqsize"), - ctrType_Int, &pThis->ctrMaxqsize)); + ctrType_Int, CTR_FLAG_NONE, &pThis->ctrMaxqsize)); CHKiRet(statsobj.ConstructFinalize(pThis->statsobj)); diff --git a/runtime/statsobj.c b/runtime/statsobj.c index 25275616..0f78ebba 100644 --- a/runtime/statsobj.c +++ b/runtime/statsobj.c @@ -142,7 +142,7 @@ finalize_it: * is called. */ static rsRetVal -addCounter(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, void *pCtr) +addCounter(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, int8_t flags, void *pCtr) { ctr_t *ctr; DEFiRet; @@ -151,6 +151,7 @@ addCounter(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, void *pCtr ctr->next = NULL; ctr->prev = NULL; CHKmalloc(ctr->name = ustrdup(ctrName)); + ctr->flags = flags; ctr->ctrType = ctrType; switch(ctrType) { case ctrType_IntCtr: @@ -241,9 +242,11 @@ getStatsLine(statsobj_t *pThis, cstr_t **ppcstr) switch(pCtr->ctrType) { case ctrType_IntCtr: rsCStrAppendInt(pcstr, *(pCtr->val.pIntCtr)); // TODO: OK????? + *(pCtr->val.pIntCtr) = 0; break; case ctrType_Int: rsCStrAppendInt(pcstr, *(pCtr->val.pInt)); + *(pCtr->val.pInt) = 0; break; } cstrAppendChar(pcstr, ' '); diff --git a/runtime/statsobj.h b/runtime/statsobj.h index 14b33215..ee120992 100644 --- a/runtime/statsobj.h +++ b/runtime/statsobj.h @@ -50,6 +50,9 @@ typedef enum statsFmtType_e { statsFmt_CEE } statsFmtType_t; +/* counter flags */ +#define CTR_FLAG_NONE 0 +#define CTR_FLAG_RESETTABLE 1 /* helper entity, the counter */ typedef struct ctr_s { @@ -59,6 +62,7 @@ typedef struct ctr_s { intctr_t *pIntCtr; int *pInt; } val; + int8_t flags; struct ctr_s *next, *prev; } ctr_t; @@ -84,13 +88,14 @@ BEGINinterface(statsobj) /* name must also be changed in ENDinterface macro! */ rsRetVal (*SetName)(statsobj_t *pThis, uchar *name); rsRetVal (*GetStatsLine)(statsobj_t *pThis, cstr_t **ppcstr); rsRetVal (*GetAllStatsLines)(rsRetVal(*cb)(void*, cstr_t*), void *usrptr, statsFmtType_t fmt); - rsRetVal (*AddCounter)(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, void *pCtr); + rsRetVal (*AddCounter)(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, int8_t flags, void *pCtr); rsRetVal (*EnableStats)(void); ENDinterface(statsobj) -#define statsobjCURR_IF_VERSION 10 /* increment whenever you change the interface structure! */ +#define statsobjCURR_IF_VERSION 11 /* increment whenever you change the interface structure! */ /* Changes * v2-v9 rserved for future use in "older" version branches * v10, 2012-04-01: GetAllStatsLines got fmt parameter + * v11, 2013-09-07: add "flags" to AddCounter API */ diff --git a/tcpsrv.c b/tcpsrv.c index a0a35d13..913ca5ce 100644 --- a/tcpsrv.c +++ b/tcpsrv.c @@ -158,7 +158,7 @@ addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort, int bSuppOctetFram) ratelimitSetThreadSafe(pEntry->ratelimiter); STATSCOUNTER_INIT(pEntry->ctrSubmit, pEntry->mutCtrSubmit); CHKiRet(statsobj.AddCounter(pEntry->stats, UCHAR_CONSTANT("submitted"), - ctrType_IntCtr, &(pEntry->ctrSubmit))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pEntry->ctrSubmit))); CHKiRet(statsobj.ConstructFinalize(pEntry->stats)); finalize_it: diff --git a/tools/omfile.c b/tools/omfile.c index ba9f7f70..c3b5fbe9 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -993,19 +993,19 @@ setupInstStatsCtrs(instanceData *pData) CHKiRet(statsobj.SetName(pData->stats, ctrName)); STATSCOUNTER_INIT(pData->ctrRequests, pData->mutCtrRequests); CHKiRet(statsobj.AddCounter(pData->stats, UCHAR_CONSTANT("requests"), - ctrType_IntCtr, &(pData->ctrRequests))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pData->ctrRequests))); STATSCOUNTER_INIT(pData->ctrLevel0, pData->mutCtrLevel0); CHKiRet(statsobj.AddCounter(pData->stats, UCHAR_CONSTANT("level0"), - ctrType_IntCtr, &(pData->ctrLevel0))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pData->ctrLevel0))); STATSCOUNTER_INIT(pData->ctrMiss, pData->mutCtrMiss); CHKiRet(statsobj.AddCounter(pData->stats, UCHAR_CONSTANT("missed"), - ctrType_IntCtr, &(pData->ctrMiss))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pData->ctrMiss))); STATSCOUNTER_INIT(pData->ctrEvict, pData->mutCtrEvict); CHKiRet(statsobj.AddCounter(pData->stats, UCHAR_CONSTANT("evicted"), - ctrType_IntCtr, &(pData->ctrEvict))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pData->ctrEvict))); STATSCOUNTER_INIT(pData->ctrMax, pData->mutCtrMax); CHKiRet(statsobj.AddCounter(pData->stats, UCHAR_CONSTANT("maxused"), - ctrType_IntCtr, &(pData->ctrMax))); + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pData->ctrMax))); CHKiRet(statsobj.ConstructFinalize(pData->stats)); finalize_it: -- cgit v1.2.3 From f573e116d8cd1a10eb3b21822a5b9b52bc682658 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 9 Sep 2013 15:21:29 +0200 Subject: impstats: reset stats counters no matter if CEE or regular mode is used --- runtime/statsobj.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/runtime/statsobj.c b/runtime/statsobj.c index 0f78ebba..fd091f8d 100644 --- a/runtime/statsobj.c +++ b/runtime/statsobj.c @@ -167,6 +167,21 @@ finalize_it: RETiRet; } +static inline void +resetResettableCtr(ctr_t *pCtr) +{ + if(pCtr->flags & CTR_FLAG_RESETTABLE) { + switch(pCtr->ctrType) { + case ctrType_IntCtr: + *(pCtr->val.pIntCtr) = 0; + break; + case ctrType_Int: + *(pCtr->val.pInt) = 0; + break; + } + } +} + /* get all the object's countes together as CEE. */ static rsRetVal getStatsLineCEE(statsobj_t *pThis, cstr_t **ppcstr, int cee_cookie) @@ -210,7 +225,7 @@ getStatsLineCEE(statsobj_t *pThis, cstr_t **ppcstr, int cee_cookie) } else { cstrAppendChar(pcstr, '}'); } - + resetResettableCtr(pCtr); } pthread_mutex_unlock(&pThis->mutCtr); @@ -242,14 +257,13 @@ getStatsLine(statsobj_t *pThis, cstr_t **ppcstr) switch(pCtr->ctrType) { case ctrType_IntCtr: rsCStrAppendInt(pcstr, *(pCtr->val.pIntCtr)); // TODO: OK????? - *(pCtr->val.pIntCtr) = 0; break; case ctrType_Int: rsCStrAppendInt(pcstr, *(pCtr->val.pInt)); - *(pCtr->val.pInt) = 0; break; } cstrAppendChar(pcstr, ' '); + resetResettableCtr(pCtr); } pthread_mutex_unlock(&pThis->mutCtr); -- cgit v1.2.3 From bd2bd5102a6ab4e206db98f441c8aaf94540cf4d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 9 Sep 2013 15:41:07 +0200 Subject: impstats: implement parameter "resetCounters" it provides the capability to make impstats emit deltas in contrast to accumulated counter values (see doc for details). Conflicts: plugins/impstats/impstats.c --- doc/impstats.html | 18 ++++++++++++++++-- plugins/impstats/impstats.c | 11 ++++++++--- runtime/statsobj.c | 22 +++++++++++----------- runtime/statsobj.h | 7 ++++--- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/doc/impstats.html b/doc/impstats.html index 8db9c6f6..a4f9187b 100644 --- a/doc/impstats.html +++ b/doc/impstats.html @@ -34,14 +34,28 @@ settings, this impact may be noticable (for high-load environments). interval is what is configured here plus the actual time required to generate messages. In general, the difference should not really matter.
-
  • facility [templateName]
    +
  • facility [facility number]
    The numerical syslog facility code to be used for generated messages. Default is 5 (syslog). This is useful for filtering messages.
  • -
  • severity [templateName]
    +
  • severity [severity number]
    The numerical syslog severity code to be used for generated messages. Default is 6 (info).This is useful for filtering messages.
  • +
  • resetCounters [off/on]
    + When set to "on", counters are automatically reset after they are emitted. In that + case, the contain only deltas to the last value emitted. When set + to "off", counters always accumulate their values. + Note that in auto-reset mode not all counters can be reset. Some counters (like queue size) + are directly obtained from internal object and cannot be modified. Also, auto-resetting + introduces some additional slight inaccuracies due to the multi-threaded nature of + rsyslog and the fact that for performance reasons it cannot serialize access + to counter variables.
    + As an alternative to auto-reset mode, you can use rsyslog's statistics + manipulation scripts to create delta values from the regular statistic + logs. This is the suggested method if deltas are not necessarily needed in + real-time. +
  • format [json/cee/legacy](rsyslog v6.3.8+ only)
    Specifies the format of emitted stats messages. The default of "legacy" is compatible with pre v6-rsyslog. The other options provide support for diff --git a/plugins/impstats/impstats.c b/plugins/impstats/impstats.c index 79749e21..b44461c5 100644 --- a/plugins/impstats/impstats.c +++ b/plugins/impstats/impstats.c @@ -76,6 +76,7 @@ struct modConfData_s { int logfd; /* fd if logging to file, or -1 if closed */ statsFmtType_t statsFmt; sbool bLogToSyslog; + sbool bResetCtrs; char *logfile; sbool configSetViaV2Method; }; @@ -92,6 +93,7 @@ static struct cnfparamdescr modpdescr[] = { { "facility", eCmdHdlrInt, 0 }, { "severity", eCmdHdlrInt, 0 }, { "log.syslog", eCmdHdlrBinary, 0 }, + { "resetcounters", eCmdHdlrBinary, 0 }, { "log.file", eCmdHdlrGetWord, 0 }, { "format", eCmdHdlrGetWord, 0 } }; @@ -222,7 +224,7 @@ doStatsLine(void __attribute__((unused)) *usrptr, cstr_t *cstr) static inline void generateStatsMsgs(void) { - statsobj.GetAllStatsLines(doStatsLine, NULL, runModConf->statsFmt); + statsobj.GetAllStatsLines(doStatsLine, NULL, runModConf->statsFmt, runModConf->bResetCtrs); } @@ -239,6 +241,7 @@ CODESTARTbeginCnfLoad loadModConf->logfd = -1; loadModConf->logfile = NULL; loadModConf->bLogToSyslog = 1; + loadModConf->bResetCtrs = 0; bLegacyCnfModGlobalsPermitted = 1; /* init legacy config vars */ initConfigSettings(); @@ -273,6 +276,8 @@ CODESTARTsetModCnf loadModConf->iSeverity = (int) pvals[i].val.d.n; } else if(!strcmp(modpblk.descr[i].name, "log.syslog")) { loadModConf->bLogToSyslog = (sbool) pvals[i].val.d.n; + } else if(!strcmp(modpblk.descr[i].name, "resetcounters")) { + loadModConf->bResetCtrs = (sbool) pvals[i].val.d.n; } else if(!strcmp(modpblk.descr[i].name, "log.file")) { loadModConf->logfile = es_str2cstr(pvals[i].val.d.estr, NULL); } else if(!strcmp(modpblk.descr[i].name, "format")) { @@ -335,8 +340,8 @@ BEGINactivateCnf rsRetVal localRet; CODESTARTactivateCnf runModConf = pModConf; - DBGPRINTF("impstats: stats interval %d seconds, logToSyslog %d, logFile %s\n", - runModConf->iStatsInterval, runModConf->bLogToSyslog, + DBGPRINTF("impstats: stats interval %d seconds, reset %d, logToSyslog %d, logFile %s\n", + runModConf->iStatsInterval, runModConf->bResetCtrs, runModConf->bLogToSyslog, runModConf->logfile == NULL ? "deactivated" : (char*)runModConf->logfile); localRet = statsobj.EnableStats(); if(localRet != RS_RET_OK) { diff --git a/runtime/statsobj.c b/runtime/statsobj.c index fd091f8d..edac7d48 100644 --- a/runtime/statsobj.c +++ b/runtime/statsobj.c @@ -168,9 +168,9 @@ finalize_it: } static inline void -resetResettableCtr(ctr_t *pCtr) +resetResettableCtr(ctr_t *pCtr, int8_t bResetCtrs) { - if(pCtr->flags & CTR_FLAG_RESETTABLE) { + if(bResetCtrs && (pCtr->flags & CTR_FLAG_RESETTABLE)) { switch(pCtr->ctrType) { case ctrType_IntCtr: *(pCtr->val.pIntCtr) = 0; @@ -184,7 +184,7 @@ resetResettableCtr(ctr_t *pCtr) /* get all the object's countes together as CEE. */ static rsRetVal -getStatsLineCEE(statsobj_t *pThis, cstr_t **ppcstr, int cee_cookie) +getStatsLineCEE(statsobj_t *pThis, cstr_t **ppcstr, int cee_cookie, int8_t bResetCtrs) { cstr_t *pcstr; ctr_t *pCtr; @@ -225,7 +225,7 @@ getStatsLineCEE(statsobj_t *pThis, cstr_t **ppcstr, int cee_cookie) } else { cstrAppendChar(pcstr, '}'); } - resetResettableCtr(pCtr); + resetResettableCtr(pCtr, bResetCtrs); } pthread_mutex_unlock(&pThis->mutCtr); @@ -239,7 +239,7 @@ finalize_it: /* get all the object's countes together with object name as one line. */ static rsRetVal -getStatsLine(statsobj_t *pThis, cstr_t **ppcstr) +getStatsLine(statsobj_t *pThis, cstr_t **ppcstr, int8_t bResetCtrs) { cstr_t *pcstr; ctr_t *pCtr; @@ -263,7 +263,7 @@ getStatsLine(statsobj_t *pThis, cstr_t **ppcstr) break; } cstrAppendChar(pcstr, ' '); - resetResettableCtr(pCtr); + resetResettableCtr(pCtr, bResetCtrs); } pthread_mutex_unlock(&pThis->mutCtr); @@ -282,7 +282,7 @@ finalize_it: * line. If the callback reports an error, processing is stopped. */ static rsRetVal -getAllStatsLines(rsRetVal(*cb)(void*, cstr_t*), void *usrptr, statsFmtType_t fmt) +getAllStatsLines(rsRetVal(*cb)(void*, cstr_t*), void *usrptr, statsFmtType_t fmt, int8_t bResetCtrs) { statsobj_t *o; cstr_t *cstr; @@ -291,13 +291,13 @@ getAllStatsLines(rsRetVal(*cb)(void*, cstr_t*), void *usrptr, statsFmtType_t fmt for(o = objRoot ; o != NULL ; o = o->next) { switch(fmt) { case statsFmt_Legacy: - CHKiRet(getStatsLine(o, &cstr)); + CHKiRet(getStatsLine(o, &cstr, bResetCtrs)); break; case statsFmt_CEE: - CHKiRet(getStatsLineCEE(o, &cstr, 1)); + CHKiRet(getStatsLineCEE(o, &cstr, 1, bResetCtrs)); break; case statsFmt_JSON: - CHKiRet(getStatsLineCEE(o, &cstr, 0)); + CHKiRet(getStatsLineCEE(o, &cstr, 0, bResetCtrs)); break; } CHKiRet(cb(usrptr, cstr)); @@ -365,7 +365,7 @@ CODESTARTobjQueryInterface(statsobj) pIf->Destruct = statsobjDestruct; pIf->DebugPrint = statsobjDebugPrint; pIf->SetName = setName; - pIf->GetStatsLine = getStatsLine; + //pIf->GetStatsLine = getStatsLine; pIf->GetAllStatsLines = getAllStatsLines; pIf->AddCounter = addCounter; pIf->EnableStats = enableStats; diff --git a/runtime/statsobj.h b/runtime/statsobj.h index ee120992..d56485de 100644 --- a/runtime/statsobj.h +++ b/runtime/statsobj.h @@ -86,8 +86,8 @@ BEGINinterface(statsobj) /* name must also be changed in ENDinterface macro! */ rsRetVal (*ConstructFinalize)(statsobj_t *pThis); rsRetVal (*Destruct)(statsobj_t **ppThis); rsRetVal (*SetName)(statsobj_t *pThis, uchar *name); - rsRetVal (*GetStatsLine)(statsobj_t *pThis, cstr_t **ppcstr); - rsRetVal (*GetAllStatsLines)(rsRetVal(*cb)(void*, cstr_t*), void *usrptr, statsFmtType_t fmt); + //rsRetVal (*GetStatsLine)(statsobj_t *pThis, cstr_t **ppcstr); + rsRetVal (*GetAllStatsLines)(rsRetVal(*cb)(void*, cstr_t*), void *usrptr, statsFmtType_t fmt, int8_t bResetCtr); rsRetVal (*AddCounter)(statsobj_t *pThis, uchar *ctrName, statsCtrType_t ctrType, int8_t flags, void *pCtr); rsRetVal (*EnableStats)(void); ENDinterface(statsobj) @@ -95,7 +95,8 @@ ENDinterface(statsobj) /* Changes * v2-v9 rserved for future use in "older" version branches * v10, 2012-04-01: GetAllStatsLines got fmt parameter - * v11, 2013-09-07: add "flags" to AddCounter API + * v11, 2013-09-07: - add "flags" to AddCounter API + * - GetAllStatsLines got parameter telling if ctrs shall be reset */ -- cgit v1.2.3 From 12e53bc326446549a32bb52ed8255e53277ec95b Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 9 Sep 2013 15:59:13 +0200 Subject: set custom branch version --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 017116ef..54260a5c 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[7.4.4],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[7.4.4.c9.1],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -- cgit v1.2.3 From 20aa2b535e641cba43cf9219619b6f4b626b1eed Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 9 Oct 2013 17:53:16 +0200 Subject: imudp: add "defaultTZ" input config parameter --- doc/imudp.html | 11 +++++++++++ plugins/imudp/imudp.c | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/doc/imudp.html b/doc/imudp.html index a8dbca31..5655b9e6 100644 --- a/doc/imudp.html +++ b/doc/imudp.html @@ -74,6 +74,17 @@ of "imudp514". The ability to append a port is most useful when multiple ports are defined for a single input and each of the inputnames shall be unique. Note that there currently is no differentiation between IPv4/v6 listeners on the same port. +
  • defaultTZ <timezone-info>
    +This is an experimental parameter; details may change at any time and it may +also be discoutinued without any early warning.
    +Permits to set a default timezone for this listener. This is useful when working with +legacy syslog (RFC3164 et al) residing in different timezones. If set it will be used as +timezone for all messages that do not contain timezone info. +Currently, the format must be "+/-hh:mm", e.g. "-05:00", "+01:30". Other formats, +including TZ names (like EST) are NOT yet supported. Note that consequently no daylight +saving settings are evaluated when working with timezones. If an invalid format is used, +"interesting" things can happen, among them malformed timestamps and rsyslogd segfaults. +This will obviously be changed at the time this feature becomes non-experimental.
  • Caveats/Known Bugs: diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index e6a34f01..312d069e 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -78,6 +78,7 @@ static struct lstn_s { prop_t *pInputName; statsobj_t *stats; /* listener stats */ ratelimit_t *ratelimiter; + uchar *dfltTZ; STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit) } *lcnfRoot = NULL, *lcnfLast = NULL; @@ -110,6 +111,7 @@ struct instanceConf_s { uchar *pszBindRuleset; /* name of ruleset to bind to */ uchar *inputname; ruleset_t *pBindRuleset; /* ruleset to bind listener to (use system default if unspecified) */ + uchar *dfltTZ; int ratelimitInterval; int ratelimitBurst; struct instanceConf_s *next; @@ -143,6 +145,7 @@ static struct cnfparamblk modpblk = /* input instance parameters */ static struct cnfparamdescr inppdescr[] = { { "port", eCmdHdlrArray, CNFPARAM_REQUIRED }, /* legacy: InputTCPServerRun */ + { "defaulttz", eCmdHdlrString, 0 }, { "inputname", eCmdHdlrGetWord, 0 }, { "inputname.appendport", eCmdHdlrBinary, 0 }, { "address", eCmdHdlrString, 0 }, @@ -177,6 +180,7 @@ createInstance(instanceConf_t **pinst) inst->bAppendPortToInpname = 0; inst->ratelimitBurst = 10000; /* arbitrary high limit */ inst->ratelimitInterval = 0; /* off */ + inst->dfltTZ = NULL; /* node created, let's add to config */ if(loadModConf->tail == NULL) { @@ -261,6 +265,7 @@ addListner(instanceConf_t *inst) newlcnfinfo->next = NULL; newlcnfinfo->sock = newSocks[iSrc]; newlcnfinfo->pRuleset = inst->pBindRuleset; + newlcnfinfo->dfltTZ = inst->dfltTZ; snprintf((char*)dispname, sizeof(dispname), "imudp(%s:%s)", bindName, port); dispname[sizeof(dispname)-1] = '\0'; /* just to be on the save side... */ CHKiRet(ratelimitNew(&newlcnfinfo->ratelimiter, (char*)dispname, NULL)); @@ -415,6 +420,8 @@ processSocket(thrdInfo_t *pThrd, struct lstn_s *lstn, struct sockaddr_storage *f MsgSetInputName(pMsg, lstn->pInputName); MsgSetRuleset(pMsg, lstn->pRuleset); MsgSetFlowControlType(pMsg, eFLOWCTL_NO_DELAY); + if(lstn->dfltTZ != NULL) + MsgSetDfltTZ(pMsg, (char*) lstn->dfltTZ); pMsg->msgFlags = NEEDS_PARSING | PARSE_HOSTNAME | NEEDS_DNSRESOL; if(*pbIsPermitted == 2) pMsg->msgFlags |= NEEDS_ACLCHK_U; /* request ACL check after resolution */ @@ -721,6 +728,8 @@ createListner(es_str_t *port, struct cnfparamvals *pvals) inst->inputname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); } else if(!strcmp(inppblk.descr[i].name, "inputname.appendport")) { inst->bAppendPortToInpname = (int) pvals[i].val.d.n; + } else if(!strcmp(inppblk.descr[i].name, "defaulttz")) { + inst->dfltTZ = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); } else if(!strcmp(inppblk.descr[i].name, "address")) { inst->pszBindAddr = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); } else if(!strcmp(inppblk.descr[i].name, "ruleset")) { @@ -896,6 +905,7 @@ CODESTARTfreeCnf free(inst->pszBindPort); free(inst->pszBindAddr); free(inst->inputname); + free(inst->dfltTZ); del = inst; inst = inst->next; free(del); -- cgit v1.2.3