From 1dcd16b3d93ba91ba0bc0ba7560f7b3bb815ea1c Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 14 Apr 2011 12:25:22 +0200 Subject: bugfix: $myhostname not available in RainerScript (and no error message) closes: http://bugzilla.adiscon.com/show_bug.cgi?id=233 --- ChangeLog | 4 ++++ runtime/rule.c | 4 ++-- runtime/sysvar.c | 4 ++++ runtime/vm.c | 18 +++++++++++++++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3300c730..f558301d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ --------------------------------------------------------------------------- +Version 5.8.1 [V5-stable] (rgerhards), 2011-04-?? +- bugfix: $myhostname not available in RainerScript (and no error message) + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=233 +--------------------------------------------------------------------------- Version 5.8.0 [V5-stable] (rgerhards), 2011-04-12 This is the new v5-stable branch, importing all feature from the 5.7.x diff --git a/runtime/rule.c b/runtime/rule.c index 42773768..d5f18e71 100644 --- a/runtime/rule.c +++ b/runtime/rule.c @@ -173,7 +173,7 @@ shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, sbool *bProcessMsg) if(pRule->f_filter_type == FILTER_PRI) { /* skip messages that are incorrect priority */ -dbgprintf("testing filter, f_pmask %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility]); + dbgprintf("testing filter, f_pmask %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility]); if ( (pRule->f_filterData.f_pmask[pMsg->iFacility] == TABLE_NOPRI) || \ ((pRule->f_filterData.f_pmask[pMsg->iFacility] & (1<iSeverity)) == 0) ) bRet = 0; @@ -185,7 +185,7 @@ dbgprintf("testing filter, f_pmask %d\n", pRule->f_filterData.f_pmask[pMsg->iFac CHKiRet(vm.SetMsg(pVM, pMsg)); CHKiRet(vm.ExecProg(pVM, pRule->f_filterData.f_expr->pVmprg)); CHKiRet(vm.PopBoolFromStack(pVM, &pResult)); - dbgprintf("result of expression evaluation: %lld\n", pResult->val.num); + dbgprintf("result of rainerscript filter evaluation: %lld\n", pResult->val.num); /* VM is destructed on function exit */ bRet = (pResult->val.num) ? 1 : 0; } else { diff --git a/runtime/sysvar.c b/runtime/sysvar.c index 4a6ace19..ecc31e2d 100644 --- a/runtime/sysvar.c +++ b/runtime/sysvar.c @@ -41,6 +41,7 @@ DEFobjStaticHelpers DEFobjCurrIf(var) DEFobjCurrIf(datetime) +DEFobjCurrIf(glbl) /* Standard-Constructor @@ -146,6 +147,8 @@ GetVar(cstr_t *pstrVarName, var_t **ppVar) CHKiRet(getNOW(NOW_HOUR, &pstrProp)); } else if(!rsCStrSzStrCmp(pstrVarName, (uchar*)"minute", sizeof("minute") - 1)) { CHKiRet(getNOW(NOW_MINUTE, &pstrProp)); + } else if(!rsCStrSzStrCmp(pstrVarName, (uchar*)"myhostname", sizeof("myhostname") - 1)) { + CHKiRet(rsCStrConstructFromszStr(&pstrProp, glbl.GetLocalHostName())); } else { ABORT_FINALIZE(RS_RET_SYSVAR_NOT_FOUND); } @@ -191,6 +194,7 @@ BEGINObjClassInit(sysvar, 1, OBJ_IS_CORE_MODULE) /* class, version */ /* request objects we use */ CHKiRet(objUse(var, CORE_COMPONENT)); CHKiRet(objUse(datetime, CORE_COMPONENT)); + CHKiRet(objUse(glbl, CORE_COMPONENT)); /* set our own handlers */ OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, sysvarConstructFinalize); diff --git a/runtime/vm.c b/runtime/vm.c index 0ed174d1..84ba4bcf 100644 --- a/runtime/vm.c +++ b/runtime/vm.c @@ -288,7 +288,7 @@ BEGINCMPOP(CMP_NEQ) /* remember to change the name also in the END macro! */ case VARTYPE_STR: bRes = rsCStrCStrCmp(operand1->val.pStr, operand2->val.pStr); break; -ENDCMPOP(CMP_EQ) +ENDCMPOP(CMP_NEQ) BEGINCMPOP(CMP_LT) /* remember to change the name also in the END macro! */ case VARTYPE_NUMBER: @@ -474,6 +474,15 @@ CODESTARTop(PUSHSYSVAR) CHKiRet(sysvar.GetVar(pOp->operand.pVar->val.pStr, &pVal)); vmstk.Push(pThis->pStk, pVal); finalize_it: + if(Debug && iRet != RS_RET_OK) { + if(iRet == RS_RET_SYSVAR_NOT_FOUND) { + DBGPRINTF("rainerscript: sysvar '%s' not found\n", + rsCStrGetSzStrNoNULL(pOp->operand.pVar->val.pStr)); + } else { + DBGPRINTF("rainerscript: error %d trying to obtain sysvar '%s'\n", + iRet, rsCStrGetSzStrNoNULL(pOp->operand.pVar->val.pStr)); + } + } ENDop(PUSHSYSVAR) /* The function call operation is only very roughly implemented. While the plumbing @@ -666,9 +675,11 @@ execProg(vm_t *pThis, vmprg_t *pProg) ISOBJ_TYPE_assert(pThis, vm); ISOBJ_TYPE_assert(pProg, vmprg); -#define doOP(OP) case opcode_##OP: CHKiRet(op##OP(pThis, pCurrOp)); break +#define doOP(OP) case opcode_##OP: DBGPRINTF("rainerscript: opcode %s\n", #OP); \ + CHKiRet(op##OP(pThis, pCurrOp)); break pCurrOp = pProg->vmopRoot; /* TODO: do this via a method! */ while(pCurrOp != NULL && pCurrOp->opcode != opcode_END_PROG) { + DBGPRINTF("rainerscript: executing step, opcode %d...\n", pCurrOp->opcode); switch(pCurrOp->opcode) { doOP(OR); doOP(AND); @@ -695,8 +706,8 @@ execProg(vm_t *pThis, vmprg_t *pProg) doOP(UNARY_MINUS); doOP(FUNC_CALL); default: - ABORT_FINALIZE(RS_RET_INVALID_VMOP); dbgoprint((obj_t*) pThis, "invalid instruction %d in vmprg\n", pCurrOp->opcode); + ABORT_FINALIZE(RS_RET_INVALID_VMOP); break; } /* so far, we have plain sequential execution, so on to next... */ @@ -709,6 +720,7 @@ execProg(vm_t *pThis, vmprg_t *pProg) */ finalize_it: + DBGPRINTF("rainerscript: script execution terminated with state %d\n", iRet); RETiRet; } -- cgit v1.2.3 From 27866eddb99885b6617fde0ee91ea7b1cd4873fb Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 14 Apr 2011 12:30:45 +0200 Subject: bugfix: doc for impstats had wrong config statements also, config statements were named a bit inconsistent, resolved that problem by introducing an alias and only documenting the consistent statements Thanks to Marcin for bringing up this problem. --- ChangeLog | 5 +++++ doc/impstats.html | 10 +++++----- plugins/impstats/impstats.c | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f558301d..2d25cb53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ Version 5.8.1 [V5-stable] (rgerhards), 2011-04-?? - bugfix: $myhostname not available in RainerScript (and no error message) closes: http://bugzilla.adiscon.com/show_bug.cgi?id=233 +- bugfix: doc for impstats had wrong config statements + also, config statements were named a bit inconsistent, resolved that + problem by introducing an alias and only documenting the consistent + statements + Thanks to Marcin for bringing up this problem. --------------------------------------------------------------------------- Version 5.8.0 [V5-stable] (rgerhards), 2011-04-12 diff --git a/doc/impstats.html b/doc/impstats.html index 3b4191e8..cede4874 100644 --- a/doc/impstats.html +++ b/doc/impstats.html @@ -22,16 +22,16 @@ settings, this impact may be severe (for high-load environments).

Configuration Directives:

    -
  • $PStatsInterval <Seconds>
    +
  • $PStatInterval <Seconds>
    Sets the interval, in seconds at which messages are generated. Please note that the actual interval may be a bit longer. We do not try to be precise and so the interval is actually a sleep period which is entered after generating all messages. So the actual interval is what is configured here plus the actual time required to generate messages. In general, the difference should not really matter. -
  • $PStatsFacility <numerical facility>
    +
  • $PStatFacility <numerical facility>
    The numerical syslog facility code to be used for generated messages. Default is 5 (syslog).This is useful for filtering messages.
  • -
  • $PStatsSeverity <numerical severity>
    +
  • $PStatSeverity <numerical severity>
    The numerical syslog severity code to be used for generated messages. Default is 6 (info).This is useful for filtering messages.
@@ -45,8 +45,8 @@ stats may not get turned on in all places.

This activates the module and records messages to /var/log/rsyslog-stats in 10 minute intervals:

diff --git a/plugins/impstats/impstats.c b/plugins/impstats/impstats.c index aa98ae9d..cfbbad76 100644 --- a/plugins/impstats/impstats.c +++ b/plugins/impstats/impstats.c @@ -212,7 +212,9 @@ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(prop, CORE_COMPONENT)); CHKiRet(objUse(errmsg, CORE_COMPONENT)); CHKiRet(objUse(statsobj, CORE_COMPONENT)); + /* the pstatsinverval is an alias to support a previous screwed-up syntax... */ CHKiRet(omsdRegCFSLineHdlr((uchar *)"pstatsinterval", 0, eCmdHdlrInt, NULL, &cs.iStatsInterval, STD_LOADABLE_MODULE_ID)); + CHKiRet(omsdRegCFSLineHdlr((uchar *)"pstatinterval", 0, eCmdHdlrInt, NULL, &cs.iStatsInterval, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"pstatfacility", 0, eCmdHdlrInt, NULL, &cs.iFacility, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"pstatseverity", 0, eCmdHdlrInt, NULL, &cs.iSeverity, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID)); -- cgit v1.2.3 From e7deab65dcad38a613c749e44e36c6c795000867 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 14 Apr 2011 12:47:04 +0200 Subject: bugfix: IPv6-address could not be specified in omrelp this was due to improper parsing of ":" closes: http://bugzilla.adiscon.com/show_bug.cgi?id=250 --- ChangeLog | 3 +++ doc/omrelp.html | 1 + plugins/omrelp/omrelp.c | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 917ce51f..e63c5d72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ --------------------------------------------------------------------------- Version 4.6.6 [v4-stable] (rgerhards), 2010-11-?? +- bugfix: IPv6-address could not be specified in omrelp + this was due to improper parsing of ":" + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=250 - bugfix: imfile potentially duplicates lines This can happen when 0 bytes are read from the input file, and some writer appends data to the file BEFORE we check if a rollover happens. diff --git a/doc/omrelp.html b/doc/omrelp.html index b3132d78..22e6845f 100644 --- a/doc/omrelp.html +++ b/doc/omrelp.html @@ -44,6 +44,7 @@ special "RSYSLOG_ForwardFormat" (case sensitive!) template is used.
# port 2514 *.* :omrelp:centralserv:2514;RSYSLOG_ForwardFormat +Note: to use IPv6 addresses, encode them in [::1] format.

[rsyslog.conf overview] [manual index] [rsyslog site]

This documentation is part of the diff --git a/plugins/omrelp/omrelp.c b/plugins/omrelp/omrelp.c index d5ef8b4f..4a21627d 100644 --- a/plugins/omrelp/omrelp.c +++ b/plugins/omrelp/omrelp.c @@ -249,8 +249,18 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1) /* extract the host first (we do a trick - we replace the ';' or ':' with a '\0') * now skip to port and then template name. rgerhards 2005-07-06 */ - for(q = p ; *p && *p != ';' && *p != ':' ; ++p) - /* JUST SKIP */; + if(*p == '[') { /* everything is hostname upto ']' */ + ++p; /* skip '[' */ + for(q = p ; *p && *p != ']' ; ++p) + /* JUST SKIP */; + if(*p == ']') { + *p = '\0'; /* trick to obtain hostname (later)! */ + ++p; /* eat it */ + } + } else { /* traditional view of hostname */ + for(q = p ; *p && *p != ';' && *p != ':' && *p != '#' ; ++p) + /* JUST SKIP */; + } pData->port = NULL; if(*p == ':') { /* process port */ -- cgit v1.2.3 From f31e2b3b66b6ed21c96cfe3526c9c8b4aee309ed Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 15 Apr 2011 10:01:22 +0200 Subject: sm_cust_bindcdr: updated field mapping according to spec received today --- plugins/sm_cust_bindcdr/sm_cust_bindcdr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/sm_cust_bindcdr/sm_cust_bindcdr.c b/plugins/sm_cust_bindcdr/sm_cust_bindcdr.c index 3fe96ac4..baad667e 100644 --- a/plugins/sm_cust_bindcdr/sm_cust_bindcdr.c +++ b/plugins/sm_cust_bindcdr/sm_cust_bindcdr.c @@ -122,7 +122,8 @@ finalize_it: * An actual message sample for what we intend to parse is (one line): <30>Mar 24 13:01:51 named[6085]: 24-Mar-2011 13:01:51.865 queries: info: client 10.0.0.96#39762: view trusted: query: 8.6.0.9.9.4.1.4.6.1.8.3.mobilecrawler.com IN TXT + (10.0.0.96) */ -#define SQL_STMT "INSERT INTO CDR(`Date`,`Time`, timeMS, client, view, query, ip) VALUES ('" +//previos dev: #define SQL_STMT "INSERT INTO CDR(`Date`,`Time`, timeMS, client, view, query, ip) VALUES ('" +#define SQL_STMT "INSERT INTO CDR(`date`,ip,user,dest) VALUES ('" #define ADD_SQL_DELIM \ memcpy(*ppBuf + iBuf, "', '", sizeof("', '") - 1); \ iBuf += sizeof("', '") - 1; @@ -316,16 +317,21 @@ CODESTARTstrgen memcpy(*ppBuf + iBuf, szDate, lenDate); iBuf += lenDate; - ADD_SQL_DELIM + /* prviously: ADD_SQL_DELIM */ + *(*ppBuf + iBuf) = ' '; + ++iBuf; memcpy(*ppBuf + iBuf, szTime, lenTime); iBuf += lenTime; ADD_SQL_DELIM + /* we shall now discard this part memcpy(*ppBuf + iBuf, szMSec, lenMSec); iBuf += lenMSec; ADD_SQL_DELIM + */ + /* Note that this seem to be the IP to use */ memcpy(*ppBuf + iBuf, szClient, lenClient); iBuf += lenClient; ADD_SQL_DELIM @@ -336,10 +342,12 @@ CODESTARTstrgen memcpy(*ppBuf + iBuf, szQuery, lenQuery); iBuf += lenQuery; - ADD_SQL_DELIM + /* this is now the last field, so we dont need: ADD_SQL_DELIM */ + /* no longer to be included memcpy(*ppBuf + iBuf, szIP, lenIP); iBuf += lenIP; + */ /* end of SQL statement/trailer (NUL is contained in string!) */ memcpy(*ppBuf + iBuf, SQL_STMT_END, sizeof(SQL_STMT_END)); -- cgit v1.2.3 From 254dc643c260c0f4a489188b2277811a4104063e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 15 Apr 2011 10:07:18 +0200 Subject: added imported bugfix to changelog --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6d431d8b..e44d042d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ Version 5.8.1 [V5-stable] (rgerhards), 2011-04-?? problem by introducing an alias and only documenting the consistent statements Thanks to Marcin for bringing up this problem. +- bugfix: IPv6-address could not be specified in omrelp + this was due to improper parsing of ":" + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=250 --------------------------------------------------------------------------- Version 5.8.0 [V5-stable] (rgerhards), 2011-04-12 -- cgit v1.2.3