summaryrefslogtreecommitdiffstats
path: root/plugins/imkmsg
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/imkmsg')
-rw-r--r--plugins/imkmsg/imkmsg.c25
-rw-r--r--plugins/imkmsg/imkmsg.h10
-rw-r--r--plugins/imkmsg/kmsg.c26
3 files changed, 21 insertions, 40 deletions
diff --git a/plugins/imkmsg/imkmsg.c b/plugins/imkmsg/imkmsg.c
index 035624c3..dc8c1b93 100644
--- a/plugins/imkmsg/imkmsg.c
+++ b/plugins/imkmsg/imkmsg.c
@@ -1,22 +1,9 @@
/* The kernel log module.
*
- * This is an abstracted module. As Linux and BSD kernel log is conceptually the
- * same, we do not do different input plugins for them but use
- * imklog in both cases, just with different "backend drivers" for
- * the different platforms. This also enables a rsyslog.conf to
- * be used on multiple platforms without the need to take care of
- * what the kernel log is coming from.
- *
- * See platform-specific files (e.g. linux.c, bsd.c) in the plugin's
- * working directory. For other systems with similar kernel logging
- * functionality, no new input plugin shall be written but rather a
- * driver be developed for imklog. Please note that imklog itself is
- * mostly concerned with handling the interface. Any real action happens
- * in the drivers, as things may be pretty different on different
- * platforms.
- *
- * Please note that this file replaces the klogd daemon that was
- * also present in pre-v3 versions of rsyslog.
+ * This is rsyslog Linux only module for reading structured kernel logs.
+ * Module is based on imklog module so it retains its structure
+ * and other part is currently in kmsg.c file instead of this (imkmsg.c)
+ * For more information see that file.
*
* To test under Linux:
* echo test1 > /dev/kmsg
@@ -154,10 +141,10 @@ finalize_it:
}
-/* log an imklog-internal message
+/* log an imkmsg-internal message
* rgerhards, 2008-04-14
*/
-rsRetVal imklogLogIntMsg(int priority, char *fmt, ...)
+rsRetVal imkmsgLogIntMsg(int priority, char *fmt, ...)
{
DEFiRet;
va_list ap;
diff --git a/plugins/imkmsg/imkmsg.h b/plugins/imkmsg/imkmsg.h
index acfb50ab..d33186b0 100644
--- a/plugins/imkmsg/imkmsg.h
+++ b/plugins/imkmsg/imkmsg.h
@@ -1,9 +1,5 @@
-/* imklog.h
- * These are the definitions for the klog message generation module.
- *
- * File begun on 2007-12-17 by RGerhards
- * Major change: 2008-04-09: switched to a driver interface for
- * several platforms
+/* imkmsg.h
+ * These are the definitions for the kmsg message generation module.
*
* Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH.
*
@@ -51,7 +47,7 @@ rsRetVal klogAfterRun(modConfData_t *pModConf);
int klogFacilIntMsg();
/* the functions below may be called by the drivers */
-rsRetVal imklogLogIntMsg(int priority, char *fmt, ...) __attribute__((format(printf,2, 3)));
+rsRetVal imkmsgLogIntMsg(int priority, char *fmt, ...) __attribute__((format(printf,2, 3)));
rsRetVal Syslog(int priority, uchar *msg, struct timeval *tp);
/* prototypes */
diff --git a/plugins/imkmsg/kmsg.c b/plugins/imkmsg/kmsg.c
index 2513b2ad..88e00502 100644
--- a/plugins/imkmsg/kmsg.c
+++ b/plugins/imkmsg/kmsg.c
@@ -1,11 +1,8 @@
/* imkmsg driver for Linux /dev/kmsg structured logging
*
- * This contains OS-specific functionality to read the BSD
- * or Linux kernel log. For a general overview, see head comment in
- * imklog.c. This started out as the BSD-specific drivers, but it
- * turned out that on modern Linux the implementation details
- * are very small, and so we use a single driver for both OS's with
- * a little help of conditional compilation.
+ * This contains Linux-specific functionality to read /dev/kmsg
+ * For a general overview, see head comment in imkmsg.c.
+ * This is heavily based on imklog bsd.c file.
*
* Copyright 2008-2012 Adiscon GmbH
*
@@ -49,7 +46,7 @@ static int fklog = -1; /* kernel log fd */
# define _PATH_KLOG "/dev/kmsg"
#endif
-/* submit a message to imklog Syslog() API. In this function, we parse
+/* submit a message to imkmsg Syslog() API. In this function, we parse
* necessary information from kernel log line, and make json string
* from the rest.
*/
@@ -129,8 +126,7 @@ static uchar *GetPath(modConfData_t *pModConf)
return pModConf->pszPath ? pModConf->pszPath : (uchar*) _PATH_KLOG;
}
-/* open the kernel log - will be called inside the willRun() imklog
- * entry point. -- rgerhards, 2008-04-09
+/* open the kernel log - will be called inside the willRun() imkmsg entry point
*/
rsRetVal
klogWillRun(modConfData_t *pModConf)
@@ -141,7 +137,7 @@ klogWillRun(modConfData_t *pModConf)
fklog = open((char*)GetPath(pModConf), O_RDONLY, 0);
if (fklog < 0) {
- imklogLogIntMsg(RS_RET_ERR_OPEN_KLOG, "imkmsg: cannot open kernel log(%s): %s.",
+ imkmsgLogIntMsg(RS_RET_ERR_OPEN_KLOG, "imkmsg: cannot open kernel log(%s): %s.",
GetPath(pModConf), rs_strerror_r(errno, errmsg, sizeof(errmsg)));
ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
}
@@ -150,7 +146,7 @@ klogWillRun(modConfData_t *pModConf)
if(pModConf->console_log_level != -1) {
r = klogctl(8, NULL, pModConf->console_log_level);
if(r != 0) {
- imklogLogIntMsg(LOG_WARNING, "imkmsg: cannot set console log level: %s",
+ imkmsgLogIntMsg(LOG_WARNING, "imkmsg: cannot set console log level: %s",
rs_strerror_r(errno, errmsg, sizeof(errmsg)));
/* make sure we do not try to re-set! */
pModConf->console_log_level = -1;
@@ -161,7 +157,8 @@ finalize_it:
RETiRet;
}
-/* Read kernel log while data are available, split into lines.
+/* Read kernel log while data are available, each read() reads one
+ * record of printk buffer.
*/
static void
readklog(void)
@@ -195,7 +192,7 @@ XXX not sure if LOG_LINE_MAX is 1024
#endif
for (;;) {
- dbgprintf("imklog(BSD/Linux) waiting for kernel log line\n");
+ dbgprintf("imkmsg waiting for kernel log line\n");
/* every read() from the opened device node receives one record of the printk buffer */
i = read(fklog, pRcv, 1024);
@@ -207,7 +204,7 @@ XXX not sure if LOG_LINE_MAX is 1024
/* something went wrong - error or zero length message */
if (i < 0 && errno != EINTR && errno != EAGAIN) {
/* error occured */
- imklogLogIntMsg(LOG_ERR,
+ imkmsgLogIntMsg(LOG_ERR,
"imkmsg: error reading kernel log - shutting down: %s",
rs_strerror_r(errno, errmsg, sizeof(errmsg)));
fklog = -1;
@@ -255,3 +252,4 @@ klogFacilIntMsg(void)
{
return LOG_SYSLOG;
}
+