From a53b019a4e9dea315ac750981f0f690a81b8f33f Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 14 Jan 2008 13:54:22 +0000 Subject: - implemented config file handlers for $MainMsgQueueHighWaterMark $MainMsgQueueLowWaterMark $MainMsgQueueDiscardMark $MainMsgQueueDiscardSeverity but did NOT yet implement the functionality behind these directives! --- doc/rsyslog_conf.html | 4 ++++ obj-types.h | 5 +++-- queue.c | 4 ++++ queue.h | 8 ++++++++ syslogd.c | 19 +++++++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/rsyslog_conf.html b/doc/rsyslog_conf.html index 0018ca50..6e8986a1 100644 --- a/doc/rsyslog_conf.html +++ b/doc/rsyslog_conf.html @@ -60,9 +60,13 @@ development and quite unstable...). So you have been warned ;)

-2 option
  • $klogSymbolsTwice (imklog) [on/off] -- former klogd -s option
  • $MainMsgQueueCheckpointInterval <number>
  • +
  • $MainMsgQueueDiscardMark <number> [default 9750]
  • +
  • $MainMsgQueueDiscardSeverity <number> [*numerical* severity! default 4 (warning)]
  • $MainMsgQueueFileName <name>
  • +
  • $MainMsgQueueHighWaterMark <number> [default 8000]
  • $MainMsgQueueImmediateShutdown [on/off]
  • $MainMsgQueueSize
  • +
  • $MainMsgQueueLowWaterMark <number> [default 2000]
  • $MainMsgQueueMaxFileSize <size_nbr>, default 1m
  • $MainMsgQueueTimeoutActionCompletion <number> [number is timeout in ms (1000ms is 1sec!), default 1000, 0 means immediate!]
  • $MainMsgQueueTimeoutEnqueue <number> [number is timeout in ms (1000ms is 1sec!), default 2000, 0 means indefinite]
  • diff --git a/obj-types.h b/obj-types.h index cd818228..350bc95b 100644 --- a/obj-types.h +++ b/obj-types.h @@ -71,9 +71,10 @@ typedef enum { /* IDs of base methods supported by all objects - used for jump t objMethod_DESERIALIZE = 3, objMethod_SETPROPERTY = 4, objMethod_CONSTRUCTION_FINALIZER = 5, - objMethod_DEBUGPRINT = 6 + objMethod_GETSEVERITY = 6, + objMethod_DEBUGPRINT = 7 } objMethod_t; -#define OBJ_NUM_METHODS 7 /* must be updated to contain the max number of methods supported */ +#define OBJ_NUM_METHODS 8 /* must be updated to contain the max number of methods supported */ typedef struct objInfo_s { objID_t objID; diff --git a/queue.c b/queue.c index 7851bb56..b9e6471f 100644 --- a/queue.c +++ b/queue.c @@ -1095,6 +1095,10 @@ DEFpropSetMeth(queue, iPersistUpdCnt, int); DEFpropSetMeth(queue, toQShutdown, long); DEFpropSetMeth(queue, toActShutdown, long); DEFpropSetMeth(queue, toEnq, long); +DEFpropSetMeth(queue, iHighWtrMrk, int); +DEFpropSetMeth(queue, iLowWtrMrk, int); +DEFpropSetMeth(queue, iDiscardMrk, int); +DEFpropSetMeth(queue, iDiscardSeverity, int); /* This function can be used as a generic way to set properties. Only the subset diff --git a/queue.h b/queue.h index a6d46990..1e3dc97f 100644 --- a/queue.h +++ b/queue.h @@ -83,6 +83,10 @@ typedef struct queue_s { qWrkThrd_t *pWrkThrds;/* array with control structure for the worker thread(s) associated with this queue */ int iUpdsSincePersist;/* nbr of queue updates since the last persist call */ int iPersistUpdCnt; /* persits queue info after this nbr of updates - 0 -> persist only on shutdown */ + int iHighWtrMrk; /* high water mark for disk-assisted memory queues */ + int iLowWtrMrk; /* low water mark for disk-assisted memory queues */ + int iDiscardMrk; /* if the queue is above this mark, low-severity messages are discarded */ + int iDiscardSeverity;/* messages of this severity above are discarded on too-full queue */ int bNeedDelQIF; /* does the QIF file need to be deleted when queue becomes empty? */ int toQShutdown; /* timeout for regular queue shutdown in ms */ int toActShutdown; /* timeout for long-running action shutdown in ms */ @@ -140,6 +144,10 @@ PROTOTYPEpropSetMeth(queue, iPersistUpdCnt, int); PROTOTYPEpropSetMeth(queue, toQShutdown, long); PROTOTYPEpropSetMeth(queue, toActShutdown, long); PROTOTYPEpropSetMeth(queue, toEnq, long); +PROTOTYPEpropSetMeth(queue, iHighWtrMrk, int); +PROTOTYPEpropSetMeth(queue, iLowWtrMrk, int); +PROTOTYPEpropSetMeth(queue, iDiscardMrk, int); +PROTOTYPEpropSetMeth(queue, iDiscardSeverity, int); #define queueGetID(pThis) ((unsigned long) pThis) #endif /* #ifndef QUEUE_H_INCLUDED */ diff --git a/syslogd.c b/syslogd.c index ca6aae68..c23c6512 100644 --- a/syslogd.c +++ b/syslogd.c @@ -1,3 +1,4 @@ +// TODO: $MainMsgQueueDiscardSeverity must accept textual severities! /** * \brief This is the main file of the rsyslogd daemon. * @@ -405,6 +406,10 @@ extern int errno; /* main message queue and its configuration parameters */ static queue_t *pMsgQueue = NULL; /* the main message queue */ static int iMainMsgQueueSize = 10000; /* size of the main message queue above */ +static int iMainMsgQHighWtrMark = 8000; /* high water mark for disk-assisted queues */ +static int iMainMsgQLowWtrMark = 2000; /* low water mark for disk-assisted queues */ +static int iMainMsgQDiscardMark = 9750; /* begin to discard messages */ +static int iMainMsgQDiscardSeverity = 4; /* discard warning and above */ static int iMainMsgQueueNumWorkers = 1; /* number of worker threads for the mm queue above */ static queueType_t MainMsgQueType = QUEUETYPE_FIXED_ARRAY; /* type of the main message queue above */ static uchar *pszMainMsgQFName = NULL; /* prefix for the main message queue file */ @@ -514,6 +519,10 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a pszMainMsgQFName = NULL; } iMainMsgQueueSize = 10000; + iMainMsgQHighWtrMark = 8000; + iMainMsgQLowWtrMark = 2000; + iMainMsgQDiscardMark = 9750; + iMainMsgQDiscardSeverity = 4; iMainMsgQueMaxFileSize = 1024 * 1024; iMainMsgQueueNumWorkers = 1; iMainMsgQPersistUpdCnt = 0; @@ -3123,6 +3132,8 @@ static void dbgPrintInitInfo(void) iMainMsgQueueNumWorkers, iMainMsgQPersistUpdCnt); dbgprintf("Main queue timeouts: shutdown: %d, action completion shutdown: %d, enq: %d\n", iMainMsgQtoQShutdown, iMainMsgQtoActShutdown, iMainMsgQtoEnq); + dbgprintf("Main queue watermarks: high: %d, low: %d, discard: %d, discard-severity: %d\n", + iMainMsgQHighWtrMark, iMainMsgQLowWtrMark, iMainMsgQDiscardMark, iMainMsgQDiscardSeverity); dbgprintf("Work Directory: '%s'.\n", pszWorkDir); } @@ -3384,6 +3395,10 @@ init(void) setQPROP(queueSettoQShutdown, "$MainMsgQueueTimeoutShutdown", iMainMsgQtoQShutdown ); setQPROP(queueSettoActShutdown, "$MainMsgQueueTimeoutActionCompletion", iMainMsgQtoActShutdown); setQPROP(queueSettoEnq, "$MainMsgQueueTimeoutEnqueue", iMainMsgQtoEnq); + setQPROP(queueSetiHighWtrMrk, "$MainMsgQueueHighWaterMark", iMainMsgQHighWtrMark); + setQPROP(queueSetiLowWtrMrk, "$MainMsgQueueLowWaterMark", iMainMsgQLowWtrMark); + setQPROP(queueSetiDiscardMrk, "$MainMsgQueueDiscardMark", iMainMsgQDiscardMark); + setQPROP(queueSetiDiscardSeverity, "$MainMsgQueueDiscardSeverity", iMainMsgQDiscardSeverity); # undef setQPROP # undef setQPROPstr @@ -4551,6 +4566,10 @@ static rsRetVal loadBuildInModules(void) CHKiRet(regCfSysLineHdlr((uchar *)"workdirectory", 0, eCmdHdlrGetWord, NULL, &pszWorkDir, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuefilename", 0, eCmdHdlrGetWord, NULL, &pszMainMsgQFName, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt, NULL, &iMainMsgQueueSize, NULL)); + CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuehighwatermark", 0, eCmdHdlrInt, NULL, &iMainMsgQHighWtrMark, NULL)); + CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuelowwatermark", 0, eCmdHdlrInt, NULL, &iMainMsgQLowWtrMark, NULL)); + CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuediscardmark", 0, eCmdHdlrInt, NULL, &iMainMsgQDiscardMark, NULL)); + CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuediscardseverity", 0, eCmdHdlrInt, NULL, &iMainMsgQDiscardSeverity, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuecheckpointinterval", 0, eCmdHdlrInt, NULL, &iMainMsgQPersistUpdCnt, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuetype", 0, eCmdHdlrGetWord, setMainMsgQueType, NULL, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueueworkerthreads", 0, eCmdHdlrInt, NULL, &iMainMsgQueueNumWorkers, NULL)); -- cgit