Merge pull request #1407 from jvymazal/master

added logging name of source of rate-limited messages
This commit is contained in:
Rainer Gerhards 2017-03-16 11:08:21 +01:00 committed by GitHub
commit 7f6030e0ae

View File

@ -132,7 +132,7 @@ tellLostCnt(ratelimit_t *ratelimit)
* be called concurrently.
*/
static int
withinRatelimit(ratelimit_t *ratelimit, time_t tt)
withinRatelimit(ratelimit_t *ratelimit, time_t tt, char* appname)
{
int ret;
uchar msgbuf[1024];
@ -171,8 +171,8 @@ withinRatelimit(ratelimit_t *ratelimit, time_t tt)
ratelimit->missed++;
if(ratelimit->missed == 1) {
snprintf((char*)msgbuf, sizeof(msgbuf),
"%s: begin to drop messages due to rate-limiting",
ratelimit->name);
"%s from <%s>: begin to drop messages due to rate-limiting",
ratelimit->name, appname);
logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0);
}
ret = 0;
@ -215,7 +215,9 @@ ratelimitMsg(ratelimit_t *ratelimit, smsg_t *pMsg, smsg_t **ppRepMsg)
/* Only the messages having severity level at or below the
* treshold (the value is >=) are subject to ratelimiting. */
if(ratelimit->interval && (pMsg->iSeverity >= ratelimit->severity)) {
if(withinRatelimit(ratelimit, pMsg->ttGenTime) == 0) {
char namebuf[512]; /* 256 for FGDN adn 256 for APPNAME should be enough */
snprintf(namebuf, sizeof namebuf, "%s%s", getHOSTNAME(pMsg), getAPPNAME(pMsg, 0));
if(withinRatelimit(ratelimit, pMsg->ttGenTime, namebuf) == 0) {
msgDestruct(&pMsg);
ABORT_FINALIZE(RS_RET_DISCARDMSG);
}