summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--doc/imptcp.html15
-rw-r--r--plugins/imptcp/imptcp.c12
-rw-r--r--runtime/ratelimit.c7
-rw-r--r--runtime/ratelimit.h2
5 files changed, 22 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 307abceb..a3ab3f71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
---------------------------------------------------------------------------
Version 7.3.1 [devel] 2012-10-??
+- imptcp: support for Linux-Type ratelimiting added
- imudp: support for input batching added (performance improvement)
- change lumberjack cookie to "@cee:" from "@cee: "
CEE originally specified the cookie with SP, whereas other lumberjack
diff --git a/doc/imptcp.html b/doc/imptcp.html
index 7e712afa..33b8b13b 100644
--- a/doc/imptcp.html
+++ b/doc/imptcp.html
@@ -13,18 +13,12 @@
<p><b>Description</b>:</p>
<p>Provides the ability to receive syslog messages via plain TCP syslog.
This is a specialised input plugin tailored for high performance on Linux. It will
-probably not run on any other platform. Also, it does no provide TLS services.
+probably not run on any other platform. Also, it does not provide TLS services.
Encryption can be provided by using <a href="rsyslog_stunnel.html">stunnel</a>.
<p>This module has no limit on the number of listeners and sessions that can be used.
-<p>Multiple receivers may be configured by
-specifying $InputPTCPServerRun multiple times.
</p>
<p><b>Configuration Directives</b>:</p>
-<p>This plugin has config directives similar named as imtcp, but they all have <b>P</b>TCP in
-their name instead of just TCP. Note that only a subset of the parameters are supported.
-<ul>
-
<p><b>Global Directives</b>:</p>
<ul>
<li>Threads &lt;number&gt;<br>
@@ -91,6 +85,13 @@ the message was received from.
Binds specified ruleset to next server defined.
<li><b>Address</b> &lt;name&gt;<br>
On multi-homed machines, specifies to which local address the listerner should be bound.
+<li><b>RateLimit.Interval</b> [number] - (available since 7.3.1) specifies the rate-limiting
+interval in seconds. Default value is 0, which turns off rate limiting. Set it to a number
+of seconds (5 recommended) to activate rate-limiting.
+</li>
+<li><b>RateLimit.Burst</b> [number] - (available since 7.3.1) specifies the rate-limiting
+burst in number of messages. Default is 10,000.
+</li>
</ul>
<b>Caveats/Known Bugs:</b>
<ul>
diff --git a/plugins/imptcp/imptcp.c b/plugins/imptcp/imptcp.c
index aba4c439..0475e219 100644
--- a/plugins/imptcp/imptcp.c
+++ b/plugins/imptcp/imptcp.c
@@ -122,6 +122,8 @@ struct instanceConf_s {
uchar *pszBindRuleset; /* name of ruleset to bind to */
uchar *pszInputName; /* value for inputname property, NULL is OK and handled by core engine */
ruleset_t *pBindRuleset; /* ruleset to bind listener to (use system default if unspecified) */
+ int ratelimitInterval;
+ int ratelimitBurst;
struct instanceConf_s *next;
};
@@ -159,6 +161,8 @@ static struct cnfparamdescr inppdescr[] = {
{ "keepalive.time", eCmdHdlrInt, 0 },
{ "keepalive.interval", eCmdHdlrInt, 0 },
{ "addtlframedelimiter", eCmdHdlrInt, 0 },
+ { "ratelimit.interval", eCmdHdlrInt, 0 },
+ { "ratelimit.burst", eCmdHdlrInt, 0 }
};
static struct cnfparamblk inppblk =
{ CNFPARAMBLK_VERSION,
@@ -1042,6 +1046,8 @@ createInstance(instanceConf_t **pinst)
inst->bEmitMsgOnClose = 0;
inst->iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
inst->pBindRuleset = NULL;
+ inst->ratelimitBurst = 10000; /* arbitrary high limit */
+ inst->ratelimitInterval = 0; /* off */
/* node created, let's add to config */
if(loadModConf->tail == NULL) {
@@ -1122,7 +1128,7 @@ addListner(modConfData_t __attribute__((unused)) *modConf, instanceConf_t *inst)
pSrv->iKeepAliveTime = inst->iKeepAliveTime;
pSrv->bEmitMsgOnClose = inst->bEmitMsgOnClose;
CHKiRet(ratelimitNew(&pSrv->ratelimiter, "imtcp", (char*)inst->pszBindPort));
-//TODO: add!ratelimitSetLinuxLike(pSrv->ratelimiter, 3, 2);
+ ratelimitSetLinuxLike(pSrv->ratelimiter, inst->ratelimitInterval, inst->ratelimitBurst);
ratelimitSetThreadSafe(pSrv->ratelimiter);
CHKmalloc(pSrv->port = ustrdup(inst->pszBindPort));
pSrv->iAddtlFrameDelim = inst->iAddtlFrameDelim;
@@ -1452,6 +1458,10 @@ CODESTARTnewInpInst
inst->iAddtlFrameDelim = (int) pvals[i].val.d.n;
} else if(!strcmp(inppblk.descr[i].name, "notifyonconnectionclose")) {
inst->bEmitMsgOnClose = (int) pvals[i].val.d.n;
+ } else if(!strcmp(inppblk.descr[i].name, "ratelimit.burst")) {
+ inst->ratelimitBurst = (int) pvals[i].val.d.n;
+ } else if(!strcmp(inppblk.descr[i].name, "ratelimit.interval")) {
+ inst->ratelimitInterval = (int) pvals[i].val.d.n;
} else {
dbgprintf("imptcp: program error, non-handled "
"param '%s'\n", inppblk.descr[i].name);
diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c
index 22e785a8..24152e8d 100644
--- a/runtime/ratelimit.c
+++ b/runtime/ratelimit.c
@@ -193,7 +193,7 @@ ratelimitMsg(ratelimit_t *ratelimit, msg_t *pMsg, msg_t **ppRepMsg)
DEFiRet;
*ppRepMsg = NULL;
- if(ratelimit->bLinuxLike) {
+ if(ratelimit->interval) {
if(withinRatelimit(ratelimit, pMsg->ttGenTime) == 0)
ABORT_FINALIZE(RS_RET_DISCARDMSG);
}
@@ -208,7 +208,7 @@ finalize_it:
int
ratelimitChecked(ratelimit_t *ratelimit)
{
- return ratelimit->bLinuxLike || ratelimit->bReduceRepeatMsgs;
+ return ratelimit->interval || ratelimit->bReduceRepeatMsgs;
}
@@ -274,8 +274,6 @@ ratelimitNew(ratelimit_t **ppThis, char *modname, char *dynname)
pThis->name = strdup(namebuf);
}
pThis->bReduceRepeatMsgs = runConf->globals.bReduceRepeatMsgs;
- if(pThis->bReduceRepeatMsgs)
- pThis->bActive = 1;
*ppThis = pThis;
finalize_it:
RETiRet;
@@ -291,7 +289,6 @@ ratelimitSetLinuxLike(ratelimit_t *ratelimit, unsigned short interval, unsigned
ratelimit->done = 0;
ratelimit->missed = 0;
ratelimit->begin = 0;
- ratelimit->bLinuxLike = 1;
}
diff --git a/runtime/ratelimit.h b/runtime/ratelimit.h
index a7959dfe..820817bc 100644
--- a/runtime/ratelimit.h
+++ b/runtime/ratelimit.h
@@ -22,10 +22,8 @@
#define INCLUDED_RATELIMIT_H
struct ratelimit_s {
- int bActive; /**< any rate-limiting at all desired? */
char *name; /**< rate limiter name, e.g. for user messages */
/* support for Linux kernel-type ratelimiting */
- int bLinuxLike; /**< Linux-like rate limiting enabled? */
unsigned short interval;
unsigned short burst;
unsigned done;