On Thu, Jun 13, 2013 at 1:55 PM, Milan Bartos <[email protected]> wrote:
> Hi, > > there are two patches for imjournal. First one renames imjournal config > options > for old config format to have "imjournal" prepended. > given that this is a totaly new plugin, do we need the legacy parameters at all? Removing them would definitely streamline the code - and it is early enough to do this without causing confusion... Opinions? Rainer The second one adds option IgnorePreviousMessages (default off) to ignore > messages in journal and start reading from the current message. This > option is only > applicable when there is no state file. It's purpose is to avoid reading > whole > journal database when there is no saved state. > Could you please take a look? > > Thanks, > Milan Bartos > > > > From 65794ea227e6102d980f20bae42bee9b65222ba2 Mon Sep 17 00:00:00 2001 > From: Milan Bartos <[email protected]> > Date: Thu, 13 Jun 2013 10:27:59 +0200 > Subject: [PATCH 1/2] Rename legacy imjournal configs to have "imjournal" > prepended. > > modified: doc/imjournal.html > modified: plugins/imjournal/imjournal.c > --- > doc/imjournal.html | 11 +++++++++++ > plugins/imjournal/imjournal.c | 6 +++--- > 2 files changed, 14 insertions(+), 3 deletions(-) > > diff --git a/doc/imjournal.html b/doc/imjournal.html > index e3f6450..dbf9279 100644 > --- a/doc/imjournal.html > +++ b/doc/imjournal.html > @@ -41,5 +41,16 @@ $template CEETemplate,"%TIMESTAMP% %HOSTNAME% > %syslogtag% @cee: %$!all-json%\n" > *.* :mmjsonparse: > *.* /var/log/ceelog;CEETemplate > </textarea> > + > +<p><b>Legacy Configuration Directoves</b>:</p> > +<ul> > +<li><strong>$ImjournalPersistStateInterval [lines]</strong><br> > +It specifies how often should the journal state be persisted. This option > is useful for rsyslog to start reading from the last journal message it > read. > +</li> > +<li><strong>$ImjournalStateFile /path/to/file</strong><br> > +It specifies where the state file for persisting journal state is located. > +</li> > +</ul> > + > </body> > </html> > diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c > index cce45b9..ee741b4 100755 > --- a/plugins/imjournal/imjournal.c > +++ b/plugins/imjournal/imjournal.c > @@ -79,7 +79,7 @@ static struct cnfparamblk modpblk = > > #define DFLT_persiststateinterval 10 > > -static int bLegacyCnfModGlobalsPermitted = 0;/* are legacy module-global > config parameters permitted? */ > +static int bLegacyCnfModGlobalsPermitted = 1;/* are legacy module-global > config parameters permitted? */ > > static prop_t *pInputName = NULL; /* there is only one global > inputName for all messages generated by this module */ > static prop_t *pLocalHostIP = NULL; /* a pseudo-constant propterty for > 127.0.0.1 */ > @@ -639,9 +639,9 @@ CODEmodInit_QueryRegCFSLineHdlr > CHKiRet(prop.CreateStringProp(&pInputName, > UCHAR_CONSTANT("imjournal"), sizeof("imjournal") - 1)); > CHKiRet(prop.CreateStringProp(&pLocalHostIP, > UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 1)); > > - CHKiRet(omsdRegCFSLineHdlr((uchar *)"persiststateinterval", 0, > eCmdHdlrInt, > + CHKiRet(omsdRegCFSLineHdlr((uchar > *)"imjournalpersiststateinterval", 0, eCmdHdlrInt, > NULL, &cs.iPersistStateInterval, STD_LOADABLE_MODULE_ID)); > - CHKiRet(omsdRegCFSLineHdlr((uchar *)"statefile", 0, > eCmdHdlrGetWord, > + CHKiRet(omsdRegCFSLineHdlr((uchar *)"imjournalstatefile", 0, > eCmdHdlrGetWord, > NULL, &cs.stateFile, STD_LOADABLE_MODULE_ID)); > > > -- > 1.8.1.4 > > > From b3ccd3c5931d80aca919bb4feb34902be2323fb3 Mon Sep 17 00:00:00 2001 > From: Milan Bartos <[email protected]> > Date: Thu, 13 Jun 2013 12:17:00 +0200 > Subject: [PATCH 2/2] Add IgnorePreviousMessages option to imjournal. > > This option specifies whether imjournal should ignore messages > that are currently in journal. This option is only used when there > is no StateFile to avoid message loss. > > modified: doc/imjournal.html > modified: plugins/imjournal/imjournal.c > --- > doc/imjournal.html | 12 ++++++++++-- > plugins/imjournal/imjournal.c | 36 +++++++++++++++++++++++++++++++----- > 2 files changed, 41 insertions(+), 7 deletions(-) > > diff --git a/doc/imjournal.html b/doc/imjournal.html > index dbf9279..5726a59 100644 > --- a/doc/imjournal.html > +++ b/doc/imjournal.html > @@ -16,7 +16,7 @@ to syslog.</p> > <p><b>Module Directives</b></p> > <ul> > <li><span style="font-weight: bold;">PersistStateInterval > -messages</span><br> > +number</span><br> > This is a global setting. It specifies how often should the journal state > be persisted. > This option is useful for rsyslog to start reding from the last journal > message it read. > > @@ -24,7 +24,12 @@ This option is useful for rsyslog to start reding from > the last journal message > /path/to/file</span><br> > This is a global setting. It specifies where the state file for persisting > journal state is located. > + > +<li><span style="font-weight: bold;">IgnorePreviousMessages</span> > +[<b>off</b>/on]<br> > +This option specifies whether imjournal should ignore messages currently > in journal and read only new messages. This option is only used when there > is no StateFile to avoid message lost. > </ul> > + > <b>Caveats/Known Bugs:</b> > <p> > </p> > @@ -44,12 +49,15 @@ $template CEETemplate,"%TIMESTAMP% %HOSTNAME% > %syslogtag% @cee: %$!all-json%\n" > > <p><b>Legacy Configuration Directoves</b>:</p> > <ul> > -<li><strong>$ImjournalPersistStateInterval [lines]</strong><br> > +<li><strong>$ImjournalPersistStateInterval</strong> number<br> > It specifies how often should the journal state be persisted. This option > is useful for rsyslog to start reading from the last journal message it > read. > </li> > <li><strong>$ImjournalStateFile /path/to/file</strong><br> > It specifies where the state file for persisting journal state is located. > </li> > +<li><strong>$ImjournalIgnorePreviousMessages</strong> [<b>off</b>/on]<br> > +This option specifies whether imjournal should ignore messages currently > in journal and read only new messages. This option is only used when there > is no StateFile to avoid message lost. > +</li> > </ul> > > </body> > diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c > index ee741b4..7d57fb2 100755 > --- a/plugins/imjournal/imjournal.c > +++ b/plugins/imjournal/imjournal.c > @@ -64,12 +64,14 @@ DEFobjCurrIf(errmsg) > static struct configSettings_s { > char *stateFile; > int iPersistStateInterval; > + int bIgnorePrevious; > } cs; > > /* module-gloval parameters */ > static struct cnfparamdescr modpdescr[] = { > { "statefile", eCmdHdlrGetWord, 0 }, > - { "persiststateinterval", eCmdHdlrInt, 0 } > + { "persiststateinterval", eCmdHdlrInt, 0 }, > + { "ignorepreviousmessages", eCmdHdlrBinary, 0 } > }; > static struct cnfparamblk modpblk = > { CNFPARAMBLK_VERSION, > @@ -247,9 +249,8 @@ readjournal() { > > /* ... but we know better than to trust the specs */ > if (equal_sign == NULL) { > - errmsg.LogError(0, > RS_RET_ERR,"SD_JOURNAL_FOREACH_DATA()" > - " returned a malformed field (has no '='): > '%s'", > - get); > + errmsg.LogError(0, RS_RET_ERR, > "SD_JOURNAL_FOREACH_DATA()" > + "returned a malformed field (has no '='): > '%s'", get); > continue; /* skip the entry */ > } > > @@ -477,7 +478,28 @@ CODESTARTrunInput > errmsg.LogError(0, RS_RET_FOPEN_FAILURE, > "imjournal: " > "open on state file `%s' > failed\n", cs.stateFile); > } > - } > + } else { > + /* when IgnorePrevious, seek to the end of journal */ > + if (cs.bIgnorePrevious) { > + if (sd_journal_seek_tail(j) < 0) { > + char errStr[256]; > + > + rs_strerror_r(errno, errStr, > sizeof(errStr)); > + errmsg.LogError(0, RS_RET_ERR, > + "sd_journal_seek_tail() failed: > '%s'", errStr); > + ABORT_FINALIZE(RS_RET_ERR); > + } > + > + if (sd_journal_previous(j) < 0) { > + char errStr[256]; > + > + rs_strerror_r(errno, errStr, > sizeof(errStr)); > + errmsg.LogError(0, RS_RET_ERR, > + "sd_journal_previous() failed: > '%s'", errStr); > + ABORT_FINALIZE(RS_RET_ERR); > + } > + } > + } > > while (glbl.GetGlobalInputTermState() == 0) { > int count = 0, r; > @@ -596,6 +618,8 @@ CODESTARTsetModCnf > cs.iPersistStateInterval = (int) pvals[i].val.d.n; > } else if (!strcmp(modpblk.descr[i].name, "statefile")) { > cs.stateFile = (char > *)es_str2cstr(pvals[i].val.d.estr, NULL); > + } else if (!strcmp(modpblk.descr[i].name, > "ignorepreviousmessages")) { > + cs.bIgnorePrevious = (int) pvals[i].val.d.n; > } else { > dbgprintf("imjournal: program error, non-handled " > "param '%s' in beginCnfLoad\n", > modpblk.descr[i].name); > @@ -643,6 +667,8 @@ CODEmodInit_QueryRegCFSLineHdlr > NULL, &cs.iPersistStateInterval, STD_LOADABLE_MODULE_ID)); > CHKiRet(omsdRegCFSLineHdlr((uchar *)"imjournalstatefile", 0, > eCmdHdlrGetWord, > NULL, &cs.stateFile, STD_LOADABLE_MODULE_ID)); > + CHKiRet(omsdRegCFSLineHdlr((uchar > *)"imjournalignorepreviousmessages", 0, eCmdHdlrBinary, > + NULL, &cs.bIgnorePrevious, STD_LOADABLE_MODULE_ID)); > > > ENDmodInit > -- > 1.8.1.4 > > > _______________________________________________ > rsyslog mailing list > http://lists.adiscon.net/mailman/listinfo/rsyslog > http://www.rsyslog.com/professional-services/ > What's up with rsyslog? Follow https://twitter.com/rgerhards > NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad > of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you > DON'T LIKE THAT. > _______________________________________________ rsyslog mailing list http://lists.adiscon.net/mailman/listinfo/rsyslog http://www.rsyslog.com/professional-services/ What's up with rsyslog? Follow https://twitter.com/rgerhards NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.

