syslogd counting repeated messages - next iteration
michael.kutter at lawo.de
michael.kutter at lawo.de
Sun Apr 9 11:34:37 UTC 2006
Gifted with Lotus Notes.... and wrapping was set to 70 chars per line...
damnit... sorry guys.
Sorry, my fault... so here's the correct format diff...
--- snip ---
--- initial_busybox-1.1.0/sysklogd/syslogd.c 2006-01-11
06:43:56.000000000 +0100
+++ busybox-1.1.0/sysklogd/syslogd.c 2006-02-17 17:59:25.000000000
+0100
@@ -94,9 +94,10 @@
/* Make loging output smaller. */
static bool small = false;
-
#define MAXLINE 1024 /* maximum line length */
+static int repetition_counter = 0;
+static char last_line[MAXLINE+1] = "\0";
/* circular buffer variables/structures */
#ifdef CONFIG_FEATURE_IPC_SYSLOG
@@ -333,7 +334,10 @@
if(logFileRotate > 0) {
int i;
char
oldFile[(strlen(logFilePath)+4)], newFile[(strlen(logFilePath)+4)];
- for(i=logFileRotate-1;i>0;i--) {
+ char rotateMsg[] = "!!! syslogd
logfile rotate !!!\n";
+ /* write rotate message to
logfile */
+ write(fd, rotateMsg,
strlen(rotateMsg));
+ for(i=logFileRotate-1;i>0;i--) {
sprintf(oldFile, "%s.%d",
logFilePath, i-1);
sprintf(newFile, "%s.%d",
logFilePath, i);
rename(oldFile, newFile);
@@ -428,6 +432,24 @@
}
/* todo: supress duplicates */
+ if (strncmp(last_line, msg, MAXLINE) == 0)
+ {
+ repetition_counter+=1;
+ return;
+ }
+ else if (repetition_counter)
+ {
+ if (small)
+ message("%s Last line repeated %d time(s).\n", timestamp,
repetition_counter);
+ else
+ message("%s %s %s Last line repeated %d time(s).\n",
timestamp, LocalHostName, res, repetition_counter);
+ repetition_counter = 0;
+ }
+ int message_length = strlen(msg);
+ if (message_length > MAXLINE) message_length = MAXLINE;
+ strncpy(last_line, msg, message_length);
+ memset(last_line+message_length, 0, MAXLINE-message_length);
+
#ifdef CONFIG_FEATURE_REMOTE_LOG
if (doRemoteLog == TRUE) {
--- snip ---
Lawo AG
Dipl. Ing. Michael Kutter
Software Development
Rob Landley <rob at landley.net>
08.04.2006 03:52
An
busybox at busybox.net
Kopie
michael.kutter at lawo.de
Thema
Re: syslogd counting repeated entries
On Thursday 06 April 2006 9:34 pm, michael.kutter at lawo.de wrote:
> Hi all,
>
> as our head of service department in the company constantly made me mad
> about the fact that the logfile on a busybox driven system contains
> multiple consecutive equal messages instead of printing the message once
> and counting the number of occurences I decided to do a quick fix for
> that. As I mentioned that version 1.1.1 still marks this as a ToDo issue
> I'd like to make a little contribution to busybox. It's not a
masterpiece
> of course but it solves the problem.
>
> I also added a message when syslogd rotates the logfile.
>
> So here's the diff for sysklogd/syslogd.c:
Diffs that can be applied with patch are "unified format" diffs, created
with
"diff -u". Could you resend it in that format, please?
Thanks,
Rob
--
Never bet against the cheap plastic solution.
_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
More information about the busybox
mailing list