summaryrefslogtreecommitdiffstats
path: root/plugins/imuxsock/imuxsock.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-09-29 14:31:44 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2010-09-29 14:31:44 +0200
commit33888b84e7dc6ec4341e066c68c7077cade24a7b (patch)
tree4467aeecc3b543d9dd5b193a05813187ca3a2349 /plugins/imuxsock/imuxsock.c
parent829a446c9f00e2f7016f09e18358458e2cc02189 (diff)
downloadrsyslog-33888b84e7dc6ec4341e066c68c7077cade24a7b.tar.gz
rsyslog-33888b84e7dc6ec4341e066c68c7077cade24a7b.tar.xz
rsyslog-33888b84e7dc6ec4341e066c68c7077cade24a7b.zip
imuxsock: indicate when rate limiting begins, include pid in rl messages
also improved test tool
Diffstat (limited to 'plugins/imuxsock/imuxsock.c')
-rw-r--r--plugins/imuxsock/imuxsock.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index b4ee8db0..24bcebb7 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -180,7 +180,7 @@ initRatelimitState(struct rs_ratelimit_state *rs, unsigned short interval, unsig
* be called concurrently.
*/
static inline int
-withinRatelimit(struct rs_ratelimit_state *rs, time_t tt)
+withinRatelimit(struct rs_ratelimit_state *rs, time_t tt, pid_t pid)
{
int ret;
uchar msgbuf[1024];
@@ -199,7 +199,8 @@ withinRatelimit(struct rs_ratelimit_state *rs, time_t tt)
if(tt > rs->begin + rs->interval) {
if(rs->missed) {
snprintf((char*)msgbuf, sizeof(msgbuf),
- "imuxsock lost %u messages due to rate-limiting", rs->missed);
+ "imuxsock lost %u messages from pid %lu due to rate-limiting",
+ rs->missed, (unsigned long) pid);
logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0);
rs->missed = 0;
}
@@ -212,6 +213,12 @@ withinRatelimit(struct rs_ratelimit_state *rs, time_t tt)
rs->done++;
ret = 1;
} else {
+ if(rs->missed == 0) {
+ snprintf((char*)msgbuf, sizeof(msgbuf),
+ "imuxsock begins to drop messages from pid %lu due to rate-limiting",
+ (unsigned long) pid);
+ logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0);
+ }
rs->missed++;
ret = 0;
}
@@ -533,7 +540,7 @@ SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *cred)
findRatelimiter(pLstn, cred, &ratelimiter); /* ignore error, better so than others... */
datetime.getCurrTime(&st, &tt);
- if(ratelimiter != NULL && !withinRatelimit(ratelimiter, tt)) {
+ if(ratelimiter != NULL && !withinRatelimit(ratelimiter, tt, cred->pid)) {
STATSCOUNTER_INC(ctrLostRatelimit, mutCtrLostRatelimit);
FINALIZE;
}