summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/impstats/impstats.c60
-rw-r--r--plugins/imptcp/imptcp.c2
-rw-r--r--plugins/imrelp/imrelp.c9
-rw-r--r--plugins/omelasticsearch/omelasticsearch.c4
-rw-r--r--plugins/omlibdbi/omlibdbi.c16
-rw-r--r--plugins/omrelp/omrelp.c17
6 files changed, 98 insertions, 10 deletions
diff --git a/plugins/impstats/impstats.c b/plugins/impstats/impstats.c
index 79749e21..c288381d 100644
--- a/plugins/impstats/impstats.c
+++ b/plugins/impstats/impstats.c
@@ -1,7 +1,7 @@
/* impstats.c
* A module to periodically output statistics gathered by rsyslog.
*
- * Copyright 2010-2012 Adiscon GmbH.
+ * Copyright 2010-2013 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -32,6 +32,9 @@
#if defined(__FreeBSD__)
#include <sys/stat.h>
#endif
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include "dirty.h"
#include "cfsysline.h"
@@ -101,6 +104,19 @@ static struct cnfparamblk modpblk =
modpdescr
};
+
+/* resource use stats counters */
+static intctr_t st_ru_utime;
+static intctr_t st_ru_stime;
+static int st_ru_maxrss;
+static int st_ru_minflt;
+static int st_ru_majflt;
+static int st_ru_inblock;
+static int st_ru_oublock;
+static int st_ru_nvcsw;
+static int st_ru_nivcsw;
+static statsobj_t *statsobj_resources;
+
BEGINmodExit
CODESTARTmodExit
prop.Destruct(&pInputName);
@@ -222,6 +238,22 @@ doStatsLine(void __attribute__((unused)) *usrptr, cstr_t *cstr)
static inline void
generateStatsMsgs(void)
{
+ struct rusage ru;
+ int r;
+ r = getrusage(RUSAGE_SELF, &ru);
+ if(r != 0) {
+ dbgprintf("impstats: getrusage() failed with error %d, zeroing out\n", errno);
+ memset(&ru, 0, sizeof(ru));
+ }
+ st_ru_utime = ru.ru_utime.tv_sec * 1000000 + ru.ru_utime.tv_usec;
+ st_ru_stime = ru.ru_stime.tv_sec * 1000000 + ru.ru_stime.tv_usec;
+ st_ru_maxrss = ru.ru_maxrss;
+ st_ru_minflt = ru.ru_minflt;
+ st_ru_majflt = ru.ru_majflt;
+ st_ru_inblock = ru.ru_inblock;
+ st_ru_oublock = ru.ru_oublock;
+ st_ru_nvcsw = ru.ru_nvcsw;
+ st_ru_nivcsw = ru.ru_nivcsw;
statsobj.GetAllStatsLines(doStatsLine, NULL, runModConf->statsFmt);
}
@@ -343,7 +375,33 @@ CODESTARTactivateCnf
errmsg.LogError(0, localRet, "impstats: error enabling statistics gathering");
ABORT_FINALIZE(RS_RET_NO_RUN);
}
+ /* initialize our own counters */
+ CHKiRet(statsobj.Construct(&statsobj_resources));
+ CHKiRet(statsobj.SetName(statsobj_resources, (uchar*)"resource-usage"));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("utime"),
+ ctrType_IntCtr, &st_ru_utime));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("stime"),
+ ctrType_IntCtr, &st_ru_stime));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("maxrss"),
+ ctrType_Int, &st_ru_maxrss));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("minflt"),
+ ctrType_Int, &st_ru_minflt));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("majflt"),
+ ctrType_Int, &st_ru_majflt));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("inblock"),
+ ctrType_Int, &st_ru_inblock));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("oublock"),
+ ctrType_Int, &st_ru_oublock));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("nvcsw"),
+ ctrType_Int, &st_ru_nvcsw));
+ CHKiRet(statsobj.AddCounter(statsobj_resources, UCHAR_CONSTANT("nivcsw"),
+ ctrType_Int, &st_ru_nivcsw));
+ CHKiRet(statsobj.ConstructFinalize(statsobj_resources));
finalize_it:
+ if(iRet != RS_RET_OK) {
+ errmsg.LogError(0, iRet, "impstats: error activating module");
+ iRet = RS_RET_NO_RUN;
+ }
ENDactivateCnf
diff --git a/plugins/imptcp/imptcp.c b/plugins/imptcp/imptcp.c
index d3a29470..a8910a07 100644
--- a/plugins/imptcp/imptcp.c
+++ b/plugins/imptcp/imptcp.c
@@ -863,8 +863,6 @@ DataRcvdCompressed(ptcpsess_t *pThis, char *buf, size_t len)
// by simply updating the input and output sizes?
uint64_t outtotal;
- assert(iLen > 0);
-
datetime.getCurrTime(&stTime, &ttGenTime);
outtotal = 0;
diff --git a/plugins/imrelp/imrelp.c b/plugins/imrelp/imrelp.c
index 74cfeb72..d04e41e1 100644
--- a/plugins/imrelp/imrelp.c
+++ b/plugins/imrelp/imrelp.c
@@ -157,6 +157,13 @@ onErr(void *pUsr, char *objinfo, char* errmesg, __attribute__((unused)) relpRetV
}
static void
+onGenericErr(char *objinfo, char* errmesg, __attribute__((unused)) relpRetVal errcode)
+{
+ errmsg.LogError(0, RS_RET_RELP_ERR, "imrelp: librelp error '%s', object "
+ " '%s' - input may not work as intended", errmesg, objinfo);
+}
+
+static void
onAuthErr(void *pUsr, char *authinfo, char* errmesg, __attribute__((unused)) relpRetVal errcode)
{
instanceConf_t *inst = (instanceConf_t*) pUsr;
@@ -288,6 +295,7 @@ addListner(modConfData_t __attribute__((unused)) *modConf, instanceConf_t *inst)
CHKiRet(relpEngineSetEnableCmd(pRelpEngine, (uchar*) "syslog", eRelpCmdState_Required));
CHKiRet(relpEngineSetSyslogRcv2(pRelpEngine, onSyslogRcv));
CHKiRet(relpEngineSetOnErr(pRelpEngine, onErr));
+ CHKiRet(relpEngineSetOnGenericErr(pRelpEngine, onGenericErr));
CHKiRet(relpEngineSetOnAuthErr(pRelpEngine, onAuthErr));
if (!glbl.GetDisableDNS()) {
CHKiRet(relpEngineSetDnsLookupMode(pRelpEngine, 1));
@@ -516,6 +524,7 @@ CODESTARTfreeCnf
inst = inst->next;
free(del);
}
+ free(pModConf->pszBindRuleset);
ENDfreeCnf
/* This is used to terminate the plugin. Note that the signal handler blocks
diff --git a/plugins/omelasticsearch/omelasticsearch.c b/plugins/omelasticsearch/omelasticsearch.c
index 33e58c1a..cb96fb6b 100644
--- a/plugins/omelasticsearch/omelasticsearch.c
+++ b/plugins/omelasticsearch/omelasticsearch.c
@@ -483,13 +483,11 @@ writeDataError(instanceData *pData, cJSON **pReplyRoot, uchar *reqmsg)
DBGPRINTF("omelasticsearch: error %d writing error file, write returns %lld\n",
errno, (long long) wrRet);
}
- free(rendered);
cJSON_Delete(errRoot);
*pReplyRoot = NULL; /* tell caller not to delete once again! */
finalize_it:
- if(rendered != NULL)
- free(rendered);
+ free(rendered);
RETiRet;
}
diff --git a/plugins/omlibdbi/omlibdbi.c b/plugins/omlibdbi/omlibdbi.c
index 6e27ad22..3beba4f0 100644
--- a/plugins/omlibdbi/omlibdbi.c
+++ b/plugins/omlibdbi/omlibdbi.c
@@ -10,7 +10,7 @@
*
* File begun on 2008-02-14 by RGerhards (extracted from syslogd.c)
*
- * Copyright 2008-2012 Adiscon GmbH.
+ * Copyright 2008-2013 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -340,8 +340,12 @@ CODESTARTbeginTransaction
# if HAVE_DBI_TXSUPP
if (pData->txSupport == 1) {
if (dbi_conn_transaction_begin(pData->conn) != 0) {
- dbgprintf("libdbi server error: begin transaction not successful\n");
- iRet = RS_RET_SUSPENDED;
+ const char *emsg;
+ dbi_conn_error(pData->conn, &emsg);
+ dbgprintf("libdbi server error: begin transaction "
+ "not successful: %s\n", emsg);
+ closeConn(pData);
+ ABORT_FINALIZE(RS_RET_SUSPENDED);
}
}
# endif
@@ -365,7 +369,11 @@ BEGINendTransaction
CODESTARTendTransaction
# if HAVE_DBI_TXSUPP
if (dbi_conn_transaction_commit(pData->conn) != 0) {
- dbgprintf("libdbi server error: transaction not committed\n");
+ const char *emsg;
+ dbi_conn_error(pData->conn, &emsg);
+ dbgprintf("libdbi server error: transaction not committed: %s\n",
+ emsg);
+ closeConn(pData);
iRet = RS_RET_SUSPENDED;
}
# endif
diff --git a/plugins/omrelp/omrelp.c b/plugins/omrelp/omrelp.c
index d41b46a6..34511e46 100644
--- a/plugins/omrelp/omrelp.c
+++ b/plugins/omrelp/omrelp.c
@@ -65,6 +65,7 @@ typedef struct _instanceData {
uchar *port;
int bInitialConnect; /* is this the initial connection request of our module? (0-no, 1-yes) */
int bIsConnected; /* currently connected to server? 0 - no, 1 - yes */
+ int sizeWindow; /**< the RELP window size - 0=use default */
unsigned timeout;
unsigned rebindInterval;
unsigned nSent;
@@ -104,6 +105,7 @@ static struct cnfparamdescr actpdescr[] = {
{ "tls.permittedpeer", eCmdHdlrArray, 0 },
{ "port", eCmdHdlrGetWord, 0 },
{ "rebindinterval", eCmdHdlrInt, 0 },
+ { "windowsize", eCmdHdlrInt, 0 },
{ "timeout", eCmdHdlrInt, 0 },
{ "template", eCmdHdlrGetWord, 0 }
};
@@ -140,6 +142,14 @@ onErr(void *pUsr, char *objinfo, char* errmesg, __attribute__((unused)) relpRetV
}
static void
+onGenericErr(char *objinfo, char* errmesg, __attribute__((unused)) relpRetVal errcode)
+{
+ errmsg.LogError(0, RS_RET_RELP_ERR, "omrelp: librelp error '%s', object "
+ "'%s' - action may not work as intended",
+ errmesg, objinfo);
+}
+
+static void
onAuthErr(void *pUsr, char *authinfo, char* errmesg, __attribute__((unused)) relpRetVal errcode)
{
instanceData *pData = (instanceData*) pUsr;
@@ -157,6 +167,8 @@ doCreateRelpClient(instanceData *pData)
ABORT_FINALIZE(RS_RET_RELP_ERR);
if(relpCltSetTimeout(pData->pRelpClt, pData->timeout) != RELP_RET_OK)
ABORT_FINALIZE(RS_RET_RELP_ERR);
+ if(relpCltSetWindowSize(pData->pRelpClt, pData->sizeWindow) != RELP_RET_OK)
+ ABORT_FINALIZE(RS_RET_RELP_ERR);
if(relpCltSetUsrPtr(pData->pRelpClt, pData) != RELP_RET_OK)
ABORT_FINALIZE(RS_RET_RELP_ERR);
if(pData->bEnableTLS) {
@@ -195,6 +207,7 @@ finalize_it:
BEGINcreateInstance
CODESTARTcreateInstance
+ pData->sizeWindow = 0;
pData->timeout = 90;
pData->rebindInterval = 0;
pData->bEnableTLS = DFLT_ENABLE_TLS;
@@ -233,6 +246,7 @@ setInstParamDefaults(instanceData *pData)
pData->port = NULL;
pData->tplName = NULL;
pData->timeout = 90;
+ pData->sizeWindow = 0;
pData->rebindInterval = 0;
pData->bEnableTLS = DFLT_ENABLE_TLS;
pData->bEnableTLSZip = DFLT_ENABLE_TLSZIP;
@@ -269,6 +283,8 @@ CODESTARTnewActInst
pData->timeout = (unsigned) pvals[i].val.d.n;
} else if(!strcmp(actpblk.descr[i].name, "rebindinterval")) {
pData->rebindInterval = (unsigned) pvals[i].val.d.n;
+ } else if(!strcmp(actpblk.descr[i].name, "windowsize")) {
+ pData->sizeWindow = (int) pvals[i].val.d.n;
} else if(!strcmp(actpblk.descr[i].name, "tls")) {
pData->bEnableTLS = (unsigned) pvals[i].val.d.n;
} else if(!strcmp(actpblk.descr[i].name, "tls.compression")) {
@@ -546,6 +562,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(relpEngineConstruct(&pRelpEngine));
CHKiRet(relpEngineSetDbgprint(pRelpEngine, dbgprintf));
CHKiRet(relpEngineSetOnAuthErr(pRelpEngine, onAuthErr));
+ CHKiRet(relpEngineSetOnGenericErr(pRelpEngine, onGenericErr));
CHKiRet(relpEngineSetOnErr(pRelpEngine, onErr));
CHKiRet(relpEngineSetEnableCmd(pRelpEngine, (uchar*) "syslog", eRelpCmdState_Required));