summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogc
diff options
context:
space:
mode:
authormpf <mpf@openbsd.org>2007-01-03 13:25:20 +0000
committermpf <mpf@openbsd.org>2007-01-03 13:25:20 +0000
commitc5dd883e85f5e9863fc5841794a8db42b67804c4 (patch)
treeaeb04263a3b709a1c3c76be1c6c4dc2a70826cee /usr.sbin/syslogc
parentmanual page should not mention options which are not yet implemented. (diff)
downloadwireguard-openbsd-c5dd883e85f5e9863fc5841794a8db42b67804c4.tar.xz
wireguard-openbsd-c5dd883e85f5e9863fc5841794a8db42b67804c4.zip
Support for continuous reading of syslog memory buffers.
Works like ``tail -f'' on a log file. OK markus@, djm@
Diffstat (limited to 'usr.sbin/syslogc')
-rw-r--r--usr.sbin/syslogc/syslogc.814
-rw-r--r--usr.sbin/syslogc/syslogc.c21
2 files changed, 27 insertions, 8 deletions
diff --git a/usr.sbin/syslogc/syslogc.8 b/usr.sbin/syslogc/syslogc.8
index 730bb0242fd..a1769c48b70 100644
--- a/usr.sbin/syslogc/syslogc.8
+++ b/usr.sbin/syslogc/syslogc.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: syslogc.8,v 1.4 2005/09/24 02:09:54 djm Exp $
+.\" $OpenBSD: syslogc.8,v 1.5 2007/01/03 13:25:21 mpf Exp $
.\"
.\" Copyright (c) 2004 Damien Miller
.\"
@@ -21,7 +21,7 @@
.Nd collect messages from syslog memory buffer
.Sh SYNOPSIS
.Nm syslogc
-.Op Fl Ccoq
+.Op Fl Ccfoq
.Op Fl s Ar reporting_socket
.Ar logname
.Nm syslogc
@@ -59,6 +59,12 @@ The options are as follows:
Request that the log buffer be cleared without reading it.
.It Fl c
Request that the log buffer be cleared once it has been read.
+.It Fl f
+Print out the last 10 lines and read from the buffer continuously.
+Like
+.Ar -f
+in
+.Xr tail 1
.It Fl o
Check whether the specified log has overflowed.
If the log has overflowed, then a message will be printed to
@@ -73,6 +79,10 @@ will be appended to its name.
Specify alternate reporting socket location (the default is
.Pa /var/run/syslogd.sock ) .
.El
+.Sh CAVEATS
+The buffer space used for writing logs through the socket is limited.
+Thus it is possible to lose logs when running in continuous mode.
+Losses are reported on standard error.
.Sh SEE ALSO
.Xr syslog 3 ,
.Xr syslog.conf 5 ,
diff --git a/usr.sbin/syslogc/syslogc.c b/usr.sbin/syslogc/syslogc.c
index 7cf6d8c115c..42f54e0b3b3 100644
--- a/usr.sbin/syslogc/syslogc.c
+++ b/usr.sbin/syslogc/syslogc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogc.c,v 1.11 2005/09/28 08:49:28 stevesk Exp $ */
+/* $OpenBSD: syslogc.c,v 1.12 2007/01/03 13:25:21 mpf Exp $ */
/*
* Copyright (c) 2004 Damien Miller
@@ -33,7 +33,7 @@
/*
* Client protocol NB. all numeric fields in network byte order
*/
-#define CTL_VERSION 0
+#define CTL_VERSION 1
/* Request */
struct ctl_cmd {
@@ -43,6 +43,7 @@ struct ctl_cmd {
#define CMD_CLEAR 3 /* Clear log */
#define CMD_LIST 4 /* List available logs */
#define CMD_FLAGS 5 /* Query flags only */
+#define CMD_READ_CONT 6 /* Read out log continuously */
u_int32_t cmd;
char logname[MAX_MEMBUF_NAME];
};
@@ -60,7 +61,7 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "Usage: %s [-Ccoq] [-s ctlsock] logname\n", __progname);
+ fprintf(stderr, "Usage: %s [-Ccfhoq] [-s ctlsock] logname\n", __progname);
exit(1);
}
@@ -81,7 +82,7 @@ main(int argc, char **argv)
ctlsock_path = DEFAULT_CTLSOCK;
rval = oflag = 0;
- while ((ch = getopt(argc, argv, "Cchoqs:")) != -1) {
+ while ((ch = getopt(argc, argv, "Ccfhoqs:")) != -1) {
switch (ch) {
case 'C':
cc.cmd = CMD_CLEAR;
@@ -92,6 +93,9 @@ main(int argc, char **argv)
case 'h':
usage();
break;
+ case 'f':
+ cc.cmd = CMD_READ_CONT;
+ break;
case 'o':
cc.cmd = CMD_FLAGS;
oflag = 1;
@@ -149,8 +153,13 @@ main(int argc, char **argv)
errx(1, "unsupported syslogd version");
/* Write out reply */
- while ((fgets(buf, sizeof(buf), ctlf)) != NULL)
- fputs(buf, stdout);
+ while ((fgets(buf, sizeof(buf), ctlf)) != NULL) {
+ if (!strcmp(buf, "<ENOBUFS>\n"))
+ fprintf(stderr, "syslogc [%s]: Lines were dropped!\n",
+ cc.logname);
+ else
+ fputs(buf, stdout);
+ }
if (oflag && (ntohl(rr.flags) & CTL_HDR_FLAG_OVERFLOW)) {
printf("%s has overflowed\n", cc.logname);