From 1ea869ec5460806841ab4feacf24e25c288a5760 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 29 Nov 2013 09:16:03 +0100 Subject: use const keyword at (some) appropriate places --- action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'action.c') diff --git a/action.c b/action.c index d46e1af8..71b114d0 100644 --- a/action.c +++ b/action.c @@ -605,7 +605,7 @@ static void actionDisable(action_t *pThis) } -/* Suspend action, this involves changing the acton state as well +/* Suspend action, this involves changing the action state as well * as setting the next retry time. * if we have more than 10 retries, we prolong the * retry interval. If something is really stalled, it will -- cgit v1.2.3 From 245cc02934384d80feb5325b6f6b5e40276761f3 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 29 Nov 2013 11:10:41 +0100 Subject: emit internal message when action is suspended and resumed --- action.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'action.c') diff --git a/action.c b/action.c index 71b114d0..1a9d3702 100644 --- a/action.c +++ b/action.c @@ -616,6 +616,7 @@ static void actionDisable(action_t *pThis) static inline void actionSuspend(action_t *pThis) { time_t ttNow; + char timebuf[32]; /* note: we can NOT use a cached timestamp, as time may have evolved * since caching, and this would break logic (and it actually did so!) @@ -623,7 +624,12 @@ static inline void actionSuspend(action_t *pThis) datetime.GetTime(&ttNow); pThis->ttResumeRtry = ttNow + pThis->iResumeInterval * (pThis->iNbrResRtry / 10 + 1); actionSetState(pThis, ACT_STATE_SUSP); - DBGPRINTF("action suspended, earliest retry=%d\n", (int) pThis->ttResumeRtry); + DBGPRINTF("action '%s' suspended, earliest retry=%lld (now %lld)\n", + pThis->pszName, (long long) pThis->ttResumeRtry, (long long) ttNow); + ctime_r(&pThis->ttResumeRtry, timebuf); + errmsg.LogMsg(0, RS_RET_NOT_FOUND, LOG_WARNING, + "action '%s' suspended, next retry is %s", + pThis->pszName, timebuf); } @@ -654,9 +660,9 @@ actionDoRetry(action_t *pThis, int *pbShutdownImmediate) iRetries = 0; while((*pbShutdownImmediate == 0) && pThis->eState == ACT_STATE_RTRY) { - DBGPRINTF("actionDoRetry: enter loop, iRetries=%d\n", iRetries); + DBGPRINTF("actionDoRetry: %s enter loop, iRetries=%d\n", pThis->pszName, iRetries); iRet = pThis->pMod->tryResume(pThis->pModData); - DBGPRINTF("actionDoRetry: action->tryResume returned %d\n", iRet); + DBGPRINTF("actionDoRetry: %s action->tryResume returned %d\n", pThis->pszName, iRet); if((pThis->iResumeOKinRow > 9) && (pThis->iResumeOKinRow % 10 == 0)) { bTreatOKasSusp = 1; pThis->iResumeOKinRow = 0; @@ -664,12 +670,16 @@ actionDoRetry(action_t *pThis, int *pbShutdownImmediate) bTreatOKasSusp = 0; } if((iRet == RS_RET_OK) && (!bTreatOKasSusp)) { - DBGPRINTF("actionDoRetry: had success RDY again (iRet=%d)\n", iRet); + DBGPRINTF("actionDoRetry: %s had success RDY again (iRet=%d)\n", + pThis->pszName, iRet); + errmsg.LogMsg(0, RS_RET_OK, LOG_INFO, "action '%s' resumed", + pThis->pszName); actionSetState(pThis, ACT_STATE_RDY); } else if(iRet == RS_RET_SUSPENDED || bTreatOKasSusp) { /* max retries reached? */ - DBGPRINTF("actionDoRetry: check for max retries, iResumeRetryCount %d, iRetries %d\n", - pThis->iResumeRetryCount, iRetries); + DBGPRINTF("actionDoRetry: %s check for max retries, iResumeRetryCount " + "%d, iRetries %d\n", + pThis->pszName, pThis->iResumeRetryCount, iRetries); if((pThis->iResumeRetryCount != -1 && iRetries >= pThis->iResumeRetryCount)) { actionSuspend(pThis); } else { -- cgit v1.2.3 From 487ef81de618e46e7fe5e072c127ce9d8bc4fca6 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 29 Nov 2013 14:25:08 +0100 Subject: bugfix: action suspend timeout was not increased --- action.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'action.c') diff --git a/action.c b/action.c index 1a9d3702..6a0db2e1 100644 --- a/action.c +++ b/action.c @@ -624,9 +624,11 @@ static inline void actionSuspend(action_t *pThis) datetime.GetTime(&ttNow); pThis->ttResumeRtry = ttNow + pThis->iResumeInterval * (pThis->iNbrResRtry / 10 + 1); actionSetState(pThis, ACT_STATE_SUSP); - DBGPRINTF("action '%s' suspended, earliest retry=%lld (now %lld)\n", - pThis->pszName, (long long) pThis->ttResumeRtry, (long long) ttNow); + DBGPRINTF("action '%s' suspended, earliest retry=%lld (now %lld), iNbrResRtry %d\n", + pThis->pszName, (long long) pThis->ttResumeRtry, (long long) ttNow, + pThis->iNbrResRtry); ctime_r(&pThis->ttResumeRtry, timebuf); + timebuf[strlen(timebuf)-1] = '\0'; /* strip LF */ errmsg.LogMsg(0, RS_RET_NOT_FOUND, LOG_WARNING, "action '%s' suspended, next retry is %s", pThis->pszName, timebuf); @@ -682,8 +684,9 @@ actionDoRetry(action_t *pThis, int *pbShutdownImmediate) pThis->pszName, pThis->iResumeRetryCount, iRetries); if((pThis->iResumeRetryCount != -1 && iRetries >= pThis->iResumeRetryCount)) { actionSuspend(pThis); + if(pThis->iNbrResRtry < 20) + ++pThis->iNbrResRtry; } else { - ++pThis->iNbrResRtry; ++iRetries; iSleepPeriod = pThis->iResumeInterval; srSleep(iSleepPeriod, 0); -- cgit v1.2.3 From c3d80cd3b0060a37e15e8e323b5a3535ab1933c0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 29 Nov 2013 15:13:22 +0100 Subject: add new impstats action counters: * suspended * suspended.duration * resumed --- action.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'action.c') diff --git a/action.c b/action.c index 6a0db2e1..23b70885 100644 --- a/action.c +++ b/action.c @@ -389,6 +389,17 @@ actionConstructFinalize(action_t *pThis, struct nvlst *lst) CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("failed"), ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrFail)); + STATSCOUNTER_INIT(pThis->ctrSuspend, pThis->mutCtrSuspend); + CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("suspended"), + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrSuspend)); + STATSCOUNTER_INIT(pThis->ctrSuspendDuration, pThis->mutCtrSuspendDuration); + CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("suspended.duration"), + ctrType_IntCtr, 0, &pThis->ctrSuspendDuration)); + + STATSCOUNTER_INIT(pThis->ctrResume, pThis->mutCtrResume); + CHKiRet(statsobj.AddCounter(pThis->statsobj, UCHAR_CONSTANT("resumed"), + ctrType_IntCtr, CTR_FLAG_RESETTABLE, &pThis->ctrResume)); + CHKiRet(statsobj.ConstructFinalize(pThis->statsobj)); /* create our queue */ @@ -613,17 +624,24 @@ static void actionDisable(action_t *pThis) * CPU time. TODO: maybe a config option for that? * rgerhards, 2007-08-02 */ -static inline void actionSuspend(action_t *pThis) +static inline void +actionSuspend(action_t * const pThis) { time_t ttNow; + int suspendDuration; char timebuf[32]; /* note: we can NOT use a cached timestamp, as time may have evolved * since caching, and this would break logic (and it actually did so!) */ datetime.GetTime(&ttNow); - pThis->ttResumeRtry = ttNow + pThis->iResumeInterval * (pThis->iNbrResRtry / 10 + 1); + suspendDuration = pThis->iResumeInterval * (pThis->iNbrResRtry / 10 + 1); + pThis->ttResumeRtry = ttNow + suspendDuration; actionSetState(pThis, ACT_STATE_SUSP); + pThis->ctrSuspendDuration += suspendDuration; + if(pThis->iNbrResRtry == 0) { + STATSCOUNTER_INC(pThis->ctrSuspend, pThis->mutCtrSuspend); + } DBGPRINTF("action '%s' suspended, earliest retry=%lld (now %lld), iNbrResRtry %d\n", pThis->pszName, (long long) pThis->ttResumeRtry, (long long) ttNow, pThis->iNbrResRtry); -- cgit v1.2.3 From 8bf869fafbcc53a134e2842e4fc894ee27ee1c7f Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 29 Nov 2013 15:43:23 +0100 Subject: actions now report if they suspend and resume themselves --- action.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'action.c') diff --git a/action.c b/action.c index 23b70885..145856eb 100644 --- a/action.c +++ b/action.c @@ -180,6 +180,7 @@ configSettings_t cs_save; /* our saved (scope!) config settings */ * counting. -- rgerhards, 2008-01-29 */ static int iActionNbr = 0; +int bActionReportSuspension = 1; /* tables for interfacing with the v6 config system */ static struct cnfparamdescr cnfparamdescr[] = { @@ -645,11 +646,13 @@ actionSuspend(action_t * const pThis) DBGPRINTF("action '%s' suspended, earliest retry=%lld (now %lld), iNbrResRtry %d\n", pThis->pszName, (long long) pThis->ttResumeRtry, (long long) ttNow, pThis->iNbrResRtry); - ctime_r(&pThis->ttResumeRtry, timebuf); - timebuf[strlen(timebuf)-1] = '\0'; /* strip LF */ - errmsg.LogMsg(0, RS_RET_NOT_FOUND, LOG_WARNING, - "action '%s' suspended, next retry is %s", - pThis->pszName, timebuf); + if(bActionReportSuspension) { + ctime_r(&pThis->ttResumeRtry, timebuf); + timebuf[strlen(timebuf)-1] = '\0'; /* strip LF */ + errmsg.LogMsg(0, RS_RET_NOT_FOUND, LOG_WARNING, + "action '%s' suspended, next retry is %s", + pThis->pszName, timebuf); + } } @@ -692,8 +695,10 @@ actionDoRetry(action_t *pThis, int *pbShutdownImmediate) if((iRet == RS_RET_OK) && (!bTreatOKasSusp)) { DBGPRINTF("actionDoRetry: %s had success RDY again (iRet=%d)\n", pThis->pszName, iRet); - errmsg.LogMsg(0, RS_RET_OK, LOG_INFO, "action '%s' resumed", - pThis->pszName); + if(bActionReportSuspension) { + errmsg.LogMsg(0, RS_RET_OK, LOG_INFO, "action '%s' resumed", + pThis->pszName); + } actionSetState(pThis, ACT_STATE_RDY); } else if(iRet == RS_RET_SUSPENDED || bTreatOKasSusp) { /* max retries reached? */ -- cgit v1.2.3