diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-12-19 11:32:14 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-12-19 11:32:14 +0000 |
commit | 6a660d870211e75ce64be7ce66fa433e419afc84 (patch) | |
tree | 7931e79c7b1cc3c4d8804c39da6dc6cf9fb667ab | |
parent | 5ae5927d26427118c333f2615f79e386d89988e1 (diff) | |
download | busybox-w32-6a660d870211e75ce64be7ce66fa433e419afc84.tar.gz busybox-w32-6a660d870211e75ce64be7ce66fa433e419afc84.tar.bz2 busybox-w32-6a660d870211e75ce64be7ce66fa433e419afc84.zip |
Patch from Fillod Stephane:
You will find in the attached file "syslog.patch" a patch which adds
config options to set at compile time the size of the circular buffer,
and some documentation update.
git-svn-id: svn://busybox.net/trunk/busybox@8129 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | docs/busybox.sgml | 34 | ||||
-rw-r--r-- | include/usage.h | 8 | ||||
-rw-r--r-- | sysklogd/Config.in | 19 | ||||
-rw-r--r-- | sysklogd/logread.c | 7 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 14 |
5 files changed, 70 insertions, 12 deletions
diff --git a/docs/busybox.sgml b/docs/busybox.sgml index 1d2e9268a..ac400c7c8 100644 --- a/docs/busybox.sgml +++ b/docs/busybox.sgml | |||
@@ -1976,6 +1976,38 @@ | |||
1976 | </para> | 1976 | </para> |
1977 | </sect1> | 1977 | </sect1> |
1978 | 1978 | ||
1979 | <sect1 id="logread"> | ||
1980 | <title>logread</title> | ||
1981 | |||
1982 | <para> | ||
1983 | Usage: logread [OPTION]... | ||
1984 | </para> | ||
1985 | |||
1986 | <para> | ||
1987 | Shows the messages from syslogd (using circular buffer). | ||
1988 | </para> | ||
1989 | |||
1990 | <para> | ||
1991 | Options: | ||
1992 | </para> | ||
1993 | |||
1994 | <para> | ||
1995 | <screen> | ||
1996 | -f Output data as the log grows. | ||
1997 | </screen> | ||
1998 | </para> | ||
1999 | |||
2000 | <para> | ||
2001 | Example: | ||
2002 | </para> | ||
2003 | |||
2004 | <para> | ||
2005 | <screen> | ||
2006 | $ logread | ||
2007 | </screen> | ||
2008 | </para> | ||
2009 | </sect1> | ||
2010 | |||
1979 | <sect1 id="ls"> | 2011 | <sect1 id="ls"> |
1980 | <title>ls</title> | 2012 | <title>ls</title> |
1981 | 2013 | ||
@@ -3110,7 +3142,7 @@ | |||
3110 | -O FILE Use an alternate log file (default=/var/log/messages) | 3142 | -O FILE Use an alternate log file (default=/var/log/messages) |
3111 | -R HOST[:PORT] Log remotely to IP or hostname on PORT (default PORT=514/UDP) | 3143 | -R HOST[:PORT] Log remotely to IP or hostname on PORT (default PORT=514/UDP) |
3112 | -L Log locally as well as network logging (default is network only) | 3144 | -L Log locally as well as network logging (default is network only) |
3113 | -C Log to a circular buffer. Read this buffer using 'logread' | 3145 | -C [size(KiB)] Log to a circular buffer. Read this buffer using 'logread' |
3114 | </screen> | 3146 | </screen> |
3115 | </para> | 3147 | </para> |
3116 | 3148 | ||
diff --git a/include/usage.h b/include/usage.h index 6db0385fb..ea1b5d5fe 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -1458,10 +1458,12 @@ | |||
1458 | "root\n" | 1458 | "root\n" |
1459 | 1459 | ||
1460 | #define logread_trivial_usage \ | 1460 | #define logread_trivial_usage \ |
1461 | "" | 1461 | "[OPTION]..." |
1462 | 1462 | ||
1463 | #define logread_full_usage \ | 1463 | #define logread_full_usage \ |
1464 | "Shows the messages from syslogd (using circular buffer)." | 1464 | "Shows the messages from syslogd (using circular buffer).\n\n" |
1465 | "Options:\n" \ | ||
1466 | "\t-f\t\toutput data as the log grows" | ||
1465 | 1467 | ||
1466 | #define losetup_trivial_usage \ | 1468 | #define losetup_trivial_usage \ |
1467 | "[OPTION]... LOOPDEVICE FILE\n" \ | 1469 | "[OPTION]... LOOPDEVICE FILE\n" \ |
@@ -2280,7 +2282,7 @@ | |||
2280 | "\n\t-R HOST[:PORT]\tLog to IP or hostname on PORT (default PORT=514/UDP)\n" \ | 2282 | "\n\t-R HOST[:PORT]\tLog to IP or hostname on PORT (default PORT=514/UDP)\n" \ |
2281 | "\t-L\t\tLog locally and via network logging (default is network only)") \ | 2283 | "\t-L\t\tLog locally and via network logging (default is network only)") \ |
2282 | USAGE_IPC_LOG( \ | 2284 | USAGE_IPC_LOG( \ |
2283 | "\n\t-C\t\tLog to a circular buffer (read the buffer using logread)") | 2285 | "\n\t-C [size(KiB)]\tLog to a circular buffer (read the buffer using logread)") |
2284 | #define syslogd_example_usage \ | 2286 | #define syslogd_example_usage \ |
2285 | "$ syslogd -R masterlog:514\n" \ | 2287 | "$ syslogd -R masterlog:514\n" \ |
2286 | "$ syslogd -R 192.168.1.1:601\n" | 2288 | "$ syslogd -R 192.168.1.1:601\n" |
diff --git a/sysklogd/Config.in b/sysklogd/Config.in index cb2ee0865..a671f59f1 100644 --- a/sysklogd/Config.in +++ b/sysklogd/Config.in | |||
@@ -56,6 +56,14 @@ config CONFIG_FEATURE_IPC_SYSLOG | |||
56 | entire filesystem, which may cause your system to | 56 | entire filesystem, which may cause your system to |
57 | break badly. | 57 | break badly. |
58 | 58 | ||
59 | config CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE | ||
60 | int " Circular buffer size in Kbytes (minimum 4KB)" | ||
61 | default 16 | ||
62 | depends on CONFIG_FEATURE_IPC_SYSLOG | ||
63 | help | ||
64 | This option sets the size of the circular buffer | ||
65 | used to record system log messages. | ||
66 | |||
59 | config CONFIG_LOGREAD | 67 | config CONFIG_LOGREAD |
60 | bool " logread" | 68 | bool " logread" |
61 | default y | 69 | default y |
@@ -66,6 +74,17 @@ config CONFIG_LOGREAD | |||
66 | utility will allow you to read the messages that are | 74 | utility will allow you to read the messages that are |
67 | stored in the syslogd circular buffer. | 75 | stored in the syslogd circular buffer. |
68 | 76 | ||
77 | config CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING | ||
78 | bool " logread double buffering" | ||
79 | default n | ||
80 | depends on CONFIG_LOGREAD | ||
81 | help | ||
82 | 'logread' ouput to slow serial terminals can have | ||
83 | side effects on syslog because of the semaphore. | ||
84 | This option make logread to double buffer copy | ||
85 | from circular buffer, minimizing semaphore | ||
86 | contention at some minor memory expense. | ||
87 | |||
69 | config CONFIG_KLOGD | 88 | config CONFIG_KLOGD |
70 | bool "klogd" | 89 | bool "klogd" |
71 | default n | 90 | default n |
diff --git a/sysklogd/logread.c b/sysklogd/logread.c index 524178fe8..207e78b57 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c | |||
@@ -108,8 +108,7 @@ extern int logread_main(int argc, char **argv) | |||
108 | i = follow ? buf->tail : buf->head; | 108 | i = follow ? buf->tail : buf->head; |
109 | 109 | ||
110 | do { | 110 | do { |
111 | #undef RC_LOGREAD | 111 | #ifdef CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING |
112 | #ifdef RC_LOGREAD | ||
113 | char *buf_data; | 112 | char *buf_data; |
114 | int log_len,j; | 113 | int log_len,j; |
115 | #endif | 114 | #endif |
@@ -128,7 +127,7 @@ extern int logread_main(int argc, char **argv) | |||
128 | } | 127 | } |
129 | 128 | ||
130 | // Read Memory | 129 | // Read Memory |
131 | #ifdef RC_LOGREAD | 130 | #ifdef CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING |
132 | log_len = buf->tail - i; | 131 | log_len = buf->tail - i; |
133 | if (log_len < 0) | 132 | if (log_len < 0) |
134 | log_len += buf->size; | 133 | log_len += buf->size; |
@@ -155,7 +154,7 @@ extern int logread_main(int argc, char **argv) | |||
155 | // release the lock on the log chain | 154 | // release the lock on the log chain |
156 | sem_up(log_semid); | 155 | sem_up(log_semid); |
157 | 156 | ||
158 | #ifdef RC_LOGREAD | 157 | #ifdef CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING |
159 | for (j=0; j < log_len; j+=strlen(buf_data+j)+1) { | 158 | for (j=0; j < log_len; j+=strlen(buf_data+j)+1) { |
160 | printf("%s", buf_data+j); | 159 | printf("%s", buf_data+j); |
161 | if (follow) | 160 | if (follow) |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 622500e48..42426ed80 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -94,6 +94,12 @@ static int local_logging = FALSE; | |||
94 | 94 | ||
95 | /* circular buffer variables/structures */ | 95 | /* circular buffer variables/structures */ |
96 | #ifdef CONFIG_FEATURE_IPC_SYSLOG | 96 | #ifdef CONFIG_FEATURE_IPC_SYSLOG |
97 | |||
98 | #if CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE < 4 | ||
99 | #error Sorry, you must set the syslogd buffer size to at least 4KB. | ||
100 | #error Please check CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE | ||
101 | #endif | ||
102 | |||
97 | #include <sys/ipc.h> | 103 | #include <sys/ipc.h> |
98 | #include <sys/sem.h> | 104 | #include <sys/sem.h> |
99 | #include <sys/shm.h> | 105 | #include <sys/shm.h> |
@@ -114,7 +120,7 @@ static struct sembuf SMwdn[3] = { {0, 0}, {1, 0}, {1, +1} }; // set SMwdn | |||
114 | 120 | ||
115 | static int shmid = -1; // ipc shared memory id | 121 | static int shmid = -1; // ipc shared memory id |
116 | static int s_semid = -1; // ipc semaphore id | 122 | static int s_semid = -1; // ipc semaphore id |
117 | static int data_size = 16000; // default data size | 123 | static int shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024); // default shm size |
118 | static int circular_logging = FALSE; | 124 | static int circular_logging = FALSE; |
119 | 125 | ||
120 | /* | 126 | /* |
@@ -156,7 +162,7 @@ void ipcsyslog_cleanup(void) | |||
156 | void ipcsyslog_init(void) | 162 | void ipcsyslog_init(void) |
157 | { | 163 | { |
158 | if (buf == NULL) { | 164 | if (buf == NULL) { |
159 | if ((shmid = shmget(KEY_ID, data_size, IPC_CREAT | 1023)) == -1) { | 165 | if ((shmid = shmget(KEY_ID, shm_size, IPC_CREAT | 1023)) == -1) { |
160 | bb_perror_msg_and_die("shmget"); | 166 | bb_perror_msg_and_die("shmget"); |
161 | } | 167 | } |
162 | 168 | ||
@@ -164,7 +170,7 @@ void ipcsyslog_init(void) | |||
164 | bb_perror_msg_and_die("shmat"); | 170 | bb_perror_msg_and_die("shmat"); |
165 | } | 171 | } |
166 | 172 | ||
167 | buf->size = data_size - sizeof(*buf); | 173 | buf->size = shm_size - sizeof(*buf); |
168 | buf->head = buf->tail = 0; | 174 | buf->head = buf->tail = 0; |
169 | 175 | ||
170 | // we'll trust the OS to set initial semval to 0 (let's hope) | 176 | // we'll trust the OS to set initial semval to 0 (let's hope) |
@@ -654,7 +660,7 @@ extern int syslogd_main(int argc, char **argv) | |||
654 | if (optarg) { | 660 | if (optarg) { |
655 | int buf_size = atoi(optarg); | 661 | int buf_size = atoi(optarg); |
656 | if (buf_size >= 4) { | 662 | if (buf_size >= 4) { |
657 | data_size = buf_size; | 663 | shm_size = buf_size; |
658 | } | 664 | } |
659 | } | 665 | } |
660 | circular_logging = TRUE; | 666 | circular_logging = TRUE; |