From 4dce63486fbb197522e11c5644cdf7aef5d7bbbc Mon Sep 17 00:00:00 2001 From: Milan Bartos Date: Thu, 14 Mar 2013 11:52:21 +0100 Subject: Fix trailing '-' in kernel messages. modified: plugins/imkmsg/kmsg.c --- plugins/imkmsg/kmsg.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/imkmsg/kmsg.c') diff --git a/plugins/imkmsg/kmsg.c b/plugins/imkmsg/kmsg.c index b771d68a..c531f941 100644 --- a/plugins/imkmsg/kmsg.c +++ b/plugins/imkmsg/kmsg.c @@ -89,6 +89,10 @@ submitSyslog(uchar *buf) for (; isdigit(*buf); buf++) { timestamp += (timestamp * 10) + (*buf - '0'); } + + while (*buf != ';') { + buf++; /* skip everything till the first ; */ + } buf++; /* skip ; */ /* get message */ -- cgit v1.2.3 From 838046ca312b555459b5632f584345b16eda1e7e Mon Sep 17 00:00:00 2001 From: Milan Bartos Date: Thu, 14 Mar 2013 11:54:30 +0100 Subject: "Fix" timestamp in imkmsg module. It's still 5-6 seconds late and this happens also in dmesg from util-linux. modified: plugins/imkmsg/kmsg.c --- plugins/imkmsg/kmsg.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'plugins/imkmsg/kmsg.c') diff --git a/plugins/imkmsg/kmsg.c b/plugins/imkmsg/kmsg.c index f1815f25..822d3dbd 100644 --- a/plugins/imkmsg/kmsg.c +++ b/plugins/imkmsg/kmsg.c @@ -32,9 +32,8 @@ #include #include #include -#ifdef OS_LINUX #include -#endif +#include #include #include "rsyslog.h" @@ -58,9 +57,8 @@ submitSyslog(uchar *buf) { long offs = 0; struct timeval tv; - long int timestamp = 0; - struct timespec monotonic; - struct timespec realtime; + struct sysinfo info; + unsigned long int timestamp = 0; char name[1024]; char value[1024]; char msg[1024]; @@ -87,12 +85,12 @@ submitSyslog(uchar *buf) /* get timestamp */ for (; isdigit(*buf); buf++) { - timestamp += (timestamp * 10) + (*buf - '0'); + timestamp = (timestamp * 10) + (*buf - '0'); } while (*buf != ';') { buf++; /* skip everything till the first ; */ - } + } buf++; /* skip ; */ /* get message */ @@ -131,10 +129,24 @@ submitSyslog(uchar *buf) } /* calculate timestamp */ - clock_gettime(CLOCK_MONOTONIC, &monotonic); - clock_gettime(CLOCK_REALTIME, &realtime); - tv.tv_sec = realtime.tv_sec + ((timestamp / 1000000l) - monotonic.tv_sec); - tv.tv_usec = (realtime.tv_nsec + ((timestamp / 1000000000l) - monotonic.tv_nsec)) / 1000; + sysinfo(&info); + gettimeofday(&tv, NULL); + + /* get boot time */ + tv.tv_sec -= info.uptime; + + tv.tv_sec += timestamp / 1000000; + tv.tv_usec += timestamp % 1000000; + + while (tv.tv_usec < 0) { + tv.tv_sec--; + tv.tv_usec += 1000000; + } + + while (tv.tv_usec >= 1000000) { + tv.tv_sec++; + tv.tv_usec -= 1000000; + } Syslog(priority, (uchar *)msg, &tv, json); } @@ -146,7 +158,6 @@ rsRetVal klogWillRun(modConfData_t *pModConf) { char errmsg[2048]; - int r; DEFiRet; fklog = open(_PATH_KLOG, O_RDONLY, 0); @@ -156,17 +167,6 @@ klogWillRun(modConfData_t *pModConf) ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG); } - /* Set level of kernel console messaging.. */ - if(pModConf->console_log_level != -1) { - r = klogctl(8, NULL, pModConf->console_log_level); - if(r != 0) { - 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; - } - } - finalize_it: RETiRet; } -- cgit v1.2.3 From 1c71b9628b08cfe867f94a7f35e6bd74db5a9673 Mon Sep 17 00:00:00 2001 From: hwoarang Date: Tue, 3 Sep 2013 11:38:01 +0200 Subject: make rsyslog use the new json-c pkgconfig file if available --- plugins/imkmsg/kmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/imkmsg/kmsg.c') diff --git a/plugins/imkmsg/kmsg.c b/plugins/imkmsg/kmsg.c index 822d3dbd..172ff4d1 100644 --- a/plugins/imkmsg/kmsg.c +++ b/plugins/imkmsg/kmsg.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include "rsyslog.h" #include "srUtils.h" -- cgit v1.2.3