summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/impstats/impstats.c39
-rw-r--r--plugins/imuxsock/imuxsock.c18
2 files changed, 45 insertions, 12 deletions
diff --git a/plugins/impstats/impstats.c b/plugins/impstats/impstats.c
index a818d20c..1312a4e8 100644
--- a/plugins/impstats/impstats.c
+++ b/plugins/impstats/impstats.c
@@ -45,6 +45,7 @@
#include "srUtils.h"
#include "unicode-helper.h"
#include "glbl.h"
+#include "statsobj.h"
#include "prop.h"
MODULE_TYPE_INPUT
@@ -58,6 +59,9 @@ MODULE_TYPE_INPUT
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(glbl)
DEFobjCurrIf(prop)
+DEFobjCurrIf(statsobj)
+DEFobjCurrIf(errmsg)
+
typedef struct configSettings_s {
int iStatsInterval;
int iFacility;
@@ -112,22 +116,25 @@ finalize_it:
}
+/* callback for statsobj
+ * Note: usrptr exists only to satisfy requirements of statsobj callback interface!
+ */
+static rsRetVal
+doStatsLine(void __attribute__((unused)) *usrptr, cstr_t *cstr)
+{
+ DEFiRet;
+ doSubmitMsg(rsCStrGetSzStrNoNULL(cstr));
+ RETiRet;
+}
+
+
/* the function to generate the actual statistics messages
* rgerhards, 2010-09-09
*/
static inline void
generateStatsMsgs(void)
{
- int iMsgQueueSize;
- uchar msg[1024];
- rsRetVal iRet;
-
- CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize));
- snprintf((char*)msg, sizeof(msg), "mainqueue size=%d", iMsgQueueSize);
- doSubmitMsg(msg);
-
-finalize_it:
- /*empty statement needed per C syntax*/;
+ statsobj.GetAllStatsLines(doStatsLine, NULL);
}
@@ -138,9 +145,7 @@ CODESTARTrunInput
* right into the sleep below.
*/
while(1) {
-dbgprintf("impstats: stats interval %d seconds - going to sleep\n", cs.iStatsInterval);
srSleep(cs.iStatsInterval, 0); /* seconds, micro seconds */
-dbgprintf("impstats: woke up\n");
if(glbl.GetGlobalInputTermState() == 1)
break; /* terminate input! */
@@ -151,10 +156,16 @@ ENDrunInput
BEGINwillRun
+ rsRetVal localRet;
CODESTARTwillRun
DBGPRINTF("impstats: stats interval %d seconds\n", cs.iStatsInterval);
if(cs.iStatsInterval == 0)
ABORT_FINALIZE(RS_RET_NO_RUN);
+ localRet = statsobj.EnableStats();
+ if(localRet != RS_RET_OK) {
+ errmsg.LogError(0, localRet, "impstat: error enabling statistics gathering");
+ ABORT_FINALIZE(RS_RET_NO_RUN);
+ }
finalize_it:
ENDwillRun
@@ -171,6 +182,8 @@ CODESTARTmodExit
/* release objects we used */
objRelease(glbl, CORE_COMPONENT);
objRelease(prop, CORE_COMPONENT);
+ objRelease(errmsg, CORE_COMPONENT);
+ objRelease(statsobj, CORE_COMPONENT);
ENDmodExit
@@ -196,6 +209,8 @@ CODEmodInit_QueryRegCFSLineHdlr
initConfigSettings();
CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(prop, CORE_COMPONENT));
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ CHKiRet(objUse(statsobj, CORE_COMPONENT));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"pstatsinterval", 0, eCmdHdlrInt, NULL, &cs.iStatsInterval, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"pstatfacility", 0, eCmdHdlrInt, NULL, &cs.iFacility, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"pstatseverity", 0, eCmdHdlrInt, NULL, &cs.iSeverity, STD_LOADABLE_MODULE_ID));
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index db53fcb6..d976c676 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -48,6 +48,7 @@
#include "debug.h"
#include "unlimited_select.h"
#include "sd-daemon.h"
+#include "statsobj.h"
MODULE_TYPE_INPUT
@@ -72,6 +73,10 @@ DEF_IMOD_STATIC_DATA
DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(prop)
+DEFobjCurrIf(statsobj)
+
+statsobj_t *modStats;
+STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit)
static prop_t *pLocalHostIP = NULL; /* there is only one global IP for all internally-generated messages */
static prop_t *pInputName = NULL; /* our inputName currently is always "imudp", and this will hold it */
@@ -269,6 +274,7 @@ SubmitMsg(uchar *pRcv, int lenRcv, int iSock)
CHKiRet(MsgSetRcvFromIP(pMsg, pLocalHostIP));
CHKiRet(submitMsg(pMsg));
+ STATSCOUNTER_INC(ctrSubmit, mutCtrSubmit);
finalize_it:
RETiRet;
}
@@ -453,9 +459,12 @@ ENDafterRun
BEGINmodExit
CODESTARTmodExit
+ statsobj.Destruct(&modStats);
+
objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
objRelease(prop, CORE_COMPONENT);
+ objRelease(statsobj, CORE_COMPONENT);
ENDmodExit
@@ -502,6 +511,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(prop, CORE_COMPONENT));
+ CHKiRet(objUse(statsobj, CORE_COMPONENT));
dbgprintf("imuxsock version %s initializing\n", PACKAGE_VERSION);
@@ -547,6 +557,14 @@ CODEmodInit_QueryRegCFSLineHdlr
setSystemLogTimestampIgnore, NULL, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"systemlogsocketflowcontrol", 0, eCmdHdlrBinary,
setSystemLogFlowControl, NULL, STD_LOADABLE_MODULE_ID));
+
+ /* support statistics gathering */
+ CHKiRet(statsobj.Construct(&modStats));
+ CHKiRet(statsobj.SetName(modStats, UCHAR_CONSTANT("imuxsock")));
+ CHKiRet(statsobj.AddCounter(modStats, UCHAR_CONSTANT("submitted"),
+ ctrType_IntCtr, &ctrSubmit));
+ CHKiRet(statsobj.ConstructFinalize(modStats));
+
ENDmodInit
/* vim:set ai:
*/