Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Nov 2001 00:49:16 +0000
From:      Dima Dorfman <dima@trit.org>
To:        Peter Wemm <peter@wemm.org>
Cc:        Bruce Evans <bde@zeta.org.au>, hackers@freebsd.org
Subject:   Reducing syslogd output bloat (was: cvs commit: src/sys/conf Makefile.i386)
Message-ID:  <20011125004921.93AD54020@bazooka.trit.org>
In-Reply-To: <20011021183958.24ABB3803@overcee.netplex.com.au>; from peter@wemm.org on "Sun, 21 Oct 2001 11:39:58 -0700"

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Wemm <peter@wemm.org> wrote:
> Bruce Evans wrote:
> > - syslogd: the name of the kernel file is used as a prefix.  If I kept
> >   kernels in the standard place, then I would have complained about the
> >   bloatage of syslogd output caused by renaming the kernel from /kernel
> >   to /boot/${NAME_OF_MY_KERNEL}/kernel
> 
> It used to print "kernel" always, even when the kernel was /vmunix
> and on other systems when it is /bsd or /netbsd.  I'd much rather that
> we went back.
> 
> When syslogd starts up, it could log the value of kern.bootfile and 
> kern.module_path once in the kernel log and just use "kernel:" for identifying
> kernel originated messages.

The attached patch implements something like this:

	Make the default kernel prefix "kernel:" instead of the boot file,
	with the old behavior available via the -o option (it might still be
	useful if one has many kernels and cares which messages came from
	which).  If the boot file is not used as the prefix, it is still
	logged once at startup.

	This change is prompted by the fact that the boot file is now much
	longer ("/boot/kernel/kernel" vs. "/kernel"), which significanlty
	bloats the syslogd output.

Please review and comment.

Thanks.

Index: syslogd.8
===================================================================
RCS file: /ref/cvsf/src/usr.sbin/syslogd/syslogd.8,v
retrieving revision 1.41
diff -u -r1.41 syslogd.8
--- syslogd.8	2001/09/01 08:42:49	1.41
+++ syslogd.8	2001/11/24 23:32:25
@@ -32,7 +32,7 @@
 .\"     @(#)syslogd.8	8.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd October 12, 1995
+.Dd November 24, 2001
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -40,7 +40,7 @@
 .Nd log systems messages
 .Sh SYNOPSIS
 .Nm
-.Op Fl 46Adknsuv
+.Op Fl 46Adknosuv
 .Op Fl a Ar allowed_peer
 .Op Fl b Ar bind_address
 .Op Fl f Ar config_file
@@ -181,6 +181,12 @@
 messages; the default is 20 minutes.
 .It Fl n
 Disable dns query for every request.
+.It Fl o
+Prefix kernel messages with the full kernel boot file as determined by
+.Xr getbootfile 3 .
+Without this,
+the kernel message prefix is always
+.Dq kernel: .
 .It Fl p
 Specify the pathname of an alternate log socket to be used instead;
 the default is
Index: syslogd.c
===================================================================
RCS file: /ref/cvsf/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.92
diff -u -r1.92 syslogd.c
--- syslogd.c	2001/11/14 09:20:24	1.92
+++ syslogd.c	2001/11/25 00:42:26
@@ -273,6 +273,7 @@
 int	family = PF_INET;	/* protocol family (IPv4 only) */
 #endif
 int	send_to_all = 0;	/* send message to all IPv4/IPv6 addresses */
+int	use_bootfile = 0;	/* log entire bootfile for every kern msg */
 
 char	bootfile[MAXLINE+1];	/* booted kernel file */
 
@@ -333,7 +334,7 @@
 	socklen_t len;
 
 	bindhostname = NULL;
-	while ((ch = getopt(argc, argv, "46Aa:b:df:kl:m:np:P:suv")) != -1)
+	while ((ch = getopt(argc, argv, "46Aa:b:df:kl:m:nop:P:suv")) != -1)
 		switch (ch) {
 		case '4':
 			family = PF_INET;
@@ -375,6 +376,9 @@
 		case 'n':
 			resolve = 0;
 			break;
+		case 'o':
+			use_bootfile = 1;
+			break;
 		case 'p':		/* path */
 			funixn[0] = optarg;
 			break;
@@ -807,7 +811,8 @@
 
 	/* add kernel prefix for kernel messages */
 	if (flags & ISKERNEL) {
-		snprintf(buf, sizeof(buf), "%s: %s", bootfile, msg);
+		snprintf(buf, sizeof(buf), "%s: %s",
+		    use_bootfile ? bootfile : "kernel", msg);
 		msg = buf;
 		msglen = strlen(buf);
 	}
@@ -1337,6 +1342,7 @@
 	char host[MAXHOSTNAMELEN];
 	char oldLocalHostName[MAXHOSTNAMELEN];
 	char hostMsg[2*MAXHOSTNAMELEN+40];
+	char bootfileMsg[LINE_MAX];
 
 	dprintf("init\n");
 
@@ -1525,6 +1531,16 @@
 		    oldLocalHostName, LocalHostName);
 		logmsg(LOG_SYSLOG|LOG_INFO, hostMsg, LocalHostName, ADDDATE);
 		dprintf("%s\n", hostMsg);
+	}
+	/*
+	 * Log the kernel boot file if we aren't going to use it as
+	 * the prefix, and if this is *not* a restart.
+	 */
+	if (signo == 0 && !use_bootfile) {
+		(void)snprintf(bootfileMsg, sizeof(bootfileMsg),
+		    "syslogd: kernel boot file is %s", bootfile);
+		logmsg(LOG_KERN|LOG_INFO, bootfileMsg, LocalHostName, ADDDATE);
+		dprintf("%s\n", bootfileMsg);
 	}
 }
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011125004921.93AD54020>