diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-27 07:51:22 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-27 07:51:22 +0200 |
commit | 24c348bf5cb5fecfcb8e02518cece57d72dbdd58 (patch) | |
tree | d67b50e4eb16fbbe18aaa2b6930abfdc96253aff /plugins | |
parent | 9a1d7044b9d300dd957a046b79629ddd26a76a2c (diff) | |
download | rsyslog-24c348bf5cb5fecfcb8e02518cece57d72dbdd58.tar.gz rsyslog-24c348bf5cb5fecfcb8e02518cece57d72dbdd58.tar.xz rsyslog-24c348bf5cb5fecfcb8e02518cece57d72dbdd58.zip |
imfile: implement support for input()
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/imfile/imfile.c | 81 |
1 files changed, 78 insertions, 3 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index c2d0db51..4edd550d 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -130,6 +130,25 @@ static fileInfo_t files[MAX_INPUT_FILES]; static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this input */ +/* input instance parameters */ +static struct cnfparamdescr inppdescr[] = { + { "file", eCmdHdlrString, CNFPARAM_REQUIRED }, + { "statefile", eCmdHdlrString, CNFPARAM_REQUIRED }, + { "tag", eCmdHdlrString, CNFPARAM_REQUIRED }, + { "severity", eCmdHdlrSeverity, 0 }, + { "facility", eCmdHdlrFacility, 0 }, + { "ruleset", eCmdHdlrString, 0 }, + { "readmode", eCmdHdlrInt, 0 }, + { "maxlinesatonce", eCmdHdlrInt, 0 }, + { "maxsubmitatonce", eCmdHdlrInt, 0 }, + { "persiststateinterval", eCmdHdlrInt, 0 } +}; +static struct cnfparamblk inppblk = + { CNFPARAMBLK_VERSION, + sizeof(inppdescr)/sizeof(struct cnfparamdescr), + inppdescr + }; + #include "im-helper.h" /* must be included AFTER the type definitions! */ /* enqueue the read file line as a message. The provided string is @@ -358,7 +377,6 @@ static rsRetVal addInstance(void __attribute__((unused)) *pVal, uchar *pNewVal) inst->pszFileName = (uchar*) strdup((char*) cs.pszFileName); inst->pszTag = (uchar*) strdup((char*) cs.pszFileTag); inst->pszStateFile = (uchar*) strdup((char*) cs.pszStateFile); - inst->nMultiSub = NUM_MULTISUB; inst->iSeverity = cs.iSeverity; inst->iFacility = cs.iFacility; inst->maxLinesAtOnce = cs.maxLinesAtOnce; @@ -413,6 +431,61 @@ finalize_it: RETiRet; } + +BEGINnewInpInst + struct cnfparamvals *pvals; + instanceConf_t *inst; + int i; +CODESTARTnewInpInst + DBGPRINTF("newInpInst (imfile)\n"); + + pvals = nvlstGetParams(lst, &inppblk, NULL); + if(pvals == NULL) { + errmsg.LogError(0, RS_RET_MISSING_CNFPARAMS, + "imfile: required parameter are missing\n"); + ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS); + } + + if(Debug) { + dbgprintf("input param blk in imfile:\n"); + cnfparamsPrint(&inppblk, pvals); + } + + CHKiRet(createInstance(&inst)); + + for(i = 0 ; i < inppblk.nParams ; ++i) { + if(!pvals[i].bUsed) + continue; + if(!strcmp(inppblk.descr[i].name, "file")) { + inst->pszFileName = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); + } else if(!strcmp(inppblk.descr[i].name, "statefile")) { + inst->pszStateFile = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); + } else if(!strcmp(inppblk.descr[i].name, "tag")) { + inst->pszTag = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); + } else if(!strcmp(inppblk.descr[i].name, "ruleset")) { + inst->pszBindRuleset = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); + } else if(!strcmp(inppblk.descr[i].name, "severity")) { + inst->iSeverity = pvals[i].val.d.n; + } else if(!strcmp(inppblk.descr[i].name, "facility")) { + inst->iSeverity = pvals[i].val.d.n; + } else if(!strcmp(inppblk.descr[i].name, "readmode")) { + inst->readMode = pvals[i].val.d.n; + } else if(!strcmp(inppblk.descr[i].name, "maxlinesatonce")) { + inst->maxLinesAtOnce = pvals[i].val.d.n; + } else if(!strcmp(inppblk.descr[i].name, "persistStateInterval")) { + inst->iPersistStateInterval = pvals[i].val.d.n; + } else if(!strcmp(inppblk.descr[i].name, "maxsubmitatonce")) { + inst->nMultiSub = pvals[i].val.d.n; + } else { + dbgprintf("imfile: program error, non-handled " + "param '%s'\n", inppblk.descr[i].name); + } + } +finalize_it: +CODE_STD_FINALIZERnewInpInst + cnfparamvalsDestruct(pvals, &inppblk); +ENDnewInpInst + BEGINbeginCnfLoad CODESTARTbeginCnfLoad loadModConf = pModConf; @@ -474,7 +547,6 @@ CODESTARTactivateCnf addListner(inst); } /* if we could not set up any listners, there is no point in running... */ - //if(lcnfRoot == NULL) { if(iFilPtr == 0) { errmsg.LogError(0, NO_ERRCODE, "imfile: no file monitors could be started, " "input not activated.\n"); @@ -488,7 +560,9 @@ BEGINfreeCnf instanceConf_t *inst, *del; CODESTARTfreeCnf for(inst = pModConf->root ; inst != NULL ; ) { - // free(inst->pszBindPort); + free(inst->pszBindRuleset); + free(inst->pszFileName); + free(inst->pszTag); del = inst; inst = inst->next; free(del); @@ -678,6 +752,7 @@ BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_IMOD_QUERIES CODEqueryEtryPt_STD_CONF2_QUERIES +CODEqueryEtryPt_STD_CONF2_IMOD_QUERIES CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES ENDqueryEtryPt |