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. Reviewed by: peter
This commit is contained in:
parent
0d4bef5dd4
commit
a53dffb774
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87000
@ -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,11 @@ Select the number of minutes between
|
||||
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
|
||||
|
@ -273,6 +273,7 @@ int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */
|
||||
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 @@ main(argc, argv)
|
||||
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 @@ main(argc, argv)
|
||||
case 'n':
|
||||
resolve = 0;
|
||||
break;
|
||||
case 'o':
|
||||
use_bootfile = 1;
|
||||
break;
|
||||
case 'p': /* path */
|
||||
funixn[0] = optarg;
|
||||
break;
|
||||
@ -807,7 +811,8 @@ logmsg(pri, msg, from, flags)
|
||||
|
||||
/* 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 @@ init(signo)
|
||||
char host[MAXHOSTNAMELEN];
|
||||
char oldLocalHostName[MAXHOSTNAMELEN];
|
||||
char hostMsg[2*MAXHOSTNAMELEN+40];
|
||||
char bootfileMsg[LINE_MAX];
|
||||
|
||||
dprintf("init\n");
|
||||
|
||||
@ -1526,6 +1532,16 @@ init(signo)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user