[OpenAFS-devel] syslog support for vl,pt,vol,file servers
Nathan Neulinger
nneul@umr.edu
Thu, 15 Mar 2001 14:27:39 -0600
--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Also has a fix for a typo in the -help output for ptserver.
This adds same support as for bosserver: -syslog or -syslog=FACILITY.
-- Nathan
------------------------------------------------------------
Nathan Neulinger EMail: nneul@umr.edu
University of Missouri - Rolla Phone: (573) 341-4841
Computing Services Fax: (573) 341-4216
--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="syslog-vlvolptfile-servers.diff"
Index: util/afsutil.h
===================================================================
RCS file: /cvs/openafs/src/util/afsutil.h,v
retrieving revision 1.2
diff -u -r1.2 afsutil.h
--- util/afsutil.h 2000/11/04 10:06:02 1.2
+++ util/afsutil.h 2001/03/15 20:24:55
@@ -25,6 +25,10 @@
#include <stdio.h>
#include <stdarg.h>
extern int LogLevel;
+#ifndef AFS_NT40_ENV
+extern int serverLogSyslog;
+extern int serverLogSyslogFacility;
+#endif
extern void FSLog(const char *format, ...);
#define ViceLog(level, str) if ((level) <= LogLevel) (FSLog str)
Index: util/serverLog.c
===================================================================
RCS file: /cvs/openafs/src/util/serverLog.c,v
retrieving revision 1.3
diff -u -r1.3 serverLog.c
--- util/serverLog.c 2001/02/12 20:29:20 1.3
+++ util/serverLog.c 2001/03/15 20:24:55
@@ -27,6 +27,7 @@
#endif
#include <sys/param.h>
#include <sys/time.h>
+#include <syslog.h>
#endif
#include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
#include <fcntl.h>
@@ -64,6 +65,11 @@
static int serverLogFD = -1;
+#ifndef AFS_NT40_ENV
+int serverLogSyslog = 0;
+int serverLogSyslogFacility = LOG_DAEMON;
+#endif
+
#include <stdarg.h>
int LogLevel;
int mrafsStyleLogs = 0;
@@ -110,8 +116,13 @@
len = strlen(tbuffer);
LOCK_SERVERLOG();
- if (serverLogFD > 0)
- write(serverLogFD, tbuffer, len);
+#ifndef AFS_NT40_ENV
+ if ( serverLogSyslog ) {
+ syslog(LOG_INFO, "%s", info);
+ } else
+#endif
+ if (serverLogFD > 0)
+ write(serverLogFD, tbuffer, len);
UNLOCK_SERVERLOG();
#if !defined(AFS_PTHREAD_ENV)
@@ -189,6 +200,13 @@
struct tm *TimeFields;
char FileName[MAXPATHLEN];
+ if ( serverLogSyslog ) {
+#ifndef AFS_NT40_ENV
+ openlog(NULL, LOG_PID, serverLogSyslogFacility);
+ return;
+#endif
+ }
+
if (mrafsStyleLogs) {
TM_GetTimeOfDay(&Start, 0);
TimeFields = localtime(&Start.tv_sec);
@@ -240,6 +258,10 @@
#if !defined(AFS_PTHREAD_ENV)
int tempfd;
#endif
+
+ if ( serverLogSyslog ) {
+ return 0;
+ }
if (access(fileName, F_OK)==0)
return 0; /* exists, no need to reopen. */
Index: ptserver/ptserver.c
===================================================================
RCS file: /cvs/openafs/src/ptserver/ptserver.c,v
retrieving revision 1.3
diff -u -r1.3 ptserver.c
--- ptserver/ptserver.c 2001/02/12 17:37:59 1.3
+++ ptserver/ptserver.c 2001/03/15 20:24:55
@@ -143,13 +143,26 @@
else if (strncmp (arg, "-enable_process_stats", alen) == 0) {
rx_enableProcessRPCStats();
}
+#ifndef AFS_NT40_ENV
+ else if (strncmp(arg, "-syslog", alen)==0) {
+ /* set syslog logging flag */
+ serverLogSyslog = 1;
+ }
+ else if (strncmp(arg, "-syslog=", MIN(8,alen))==0) {
+ serverLogSyslog = 1;
+ serverLogSyslogFacility = atoi(arg+8);
+ }
+#endif
else if (*arg == '-') {
usage:
/* hack in help flag support */
printf ("Usage: ptserver [-database <db path>] "
- "[-p <number of processes>] [-rebuildDB] "
+#ifndef AFS_NT40_ENV
+ "[-syslog[=FACILITY]] "
+#endif
+ "[-p <number of processes>] [-rebuild] "
/* "[-enable_peer_stats] [-enable_process_stats] " */
"[-help]\n");
fflush(stdout);
Index: viced/viced.c
===================================================================
RCS file: /cvs/openafs/src/viced/viced.c,v
retrieving revision 1.2
diff -u -r1.2 viced.c
--- viced/viced.c 2000/11/04 10:06:17 1.2
+++ viced/viced.c 2001/03/15 20:24:55
@@ -1177,6 +1177,16 @@
if (!strcmp(argv[i], "-enable_process_stats")) {
rx_enableProcessRPCStats();
}
+#ifndef AFS_NT40_ENV
+ else if (strcmp(argv[i], "-syslog")==0) {
+ /* set syslog logging flag */
+ serverLogSyslog = 1;
+ }
+ else if (strncmp(argv[i], "-syslog=", 8)==0) {
+ serverLogSyslog = 1;
+ serverLogSyslogFacility = atoi(argv[i]+8);
+ }
+#endif
else {
return(-1);
}
Index: volser/volmain.c
===================================================================
RCS file: /cvs/openafs/src/volser/volmain.c,v
retrieving revision 1.3
diff -u -r1.3 volmain.c
--- volser/volmain.c 2000/12/24 00:52:03 1.3
+++ volser/volmain.c 2001/03/15 20:24:55
@@ -274,11 +274,24 @@
else if (strcmp(argv[code], "-enable_process_stats")==0) {
rx_enableProcessRPCStats();
}
+#ifndef AFS_NT40_ENV
+ else if (strcmp(argv[code], "-syslog")==0) {
+ /* set syslog logging flag */
+ serverLogSyslog = 1;
+ }
+ else if (strncmp(argv[code], "-syslog=", 8)==0) {
+ serverLogSyslog = 1;
+ serverLogSyslogFacility = atoi(argv[code]+8);
+ }
+#endif
else {
printf("volserver: unrecognized flag '%s'\n", argv[code]);
usage:
printf("Usage: volserver [-log] [-p <number of processes>] "
"[-udpsize <size of socket buffer in bytes>] "
+#ifndef AFS_NT40_ENV
+ "[-syslog[=FACILITY]] "
+#endif
/* "[-enable_peer_stats] [-enable_process_stats] " */
"[-help]\n");
VS_EXIT(1);
Index: vlserver/vlserver.c
===================================================================
RCS file: /cvs/openafs/src/vlserver/vlserver.c,v
retrieving revision 1.4
diff -u -r1.4 vlserver.c
--- vlserver/vlserver.c 2001/02/12 20:33:15 1.4
+++ vlserver/vlserver.c 2001/03/15 20:24:55
@@ -164,9 +164,20 @@
rx_enablePeerRPCStats();
} else if (strcmp(argv[index], "-enable_process_stats") == 0) {
rx_enableProcessRPCStats();
+#ifndef AFS_NT40_ENV
+ } else if (strcmp(argv[index], "-syslog")==0) {
+ /* set syslog logging flag */
+ serverLogSyslog = 1;
+ } else if (strncmp(argv[index], "-syslog=", 8)==0) {
+ serverLogSyslog = 1;
+ serverLogSyslogFacility = atoi(argv[index]+8);
+#endif
} else {
/* support help flag */
printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
+#ifndef AFS_NT40_ENV
+ "[-syslog[=FACILITY]] "
+#endif
/*" [-enable_peer_stats] [-enable_process_stats] " */
"[-help]\n");
fflush(stdout);
--LZvS9be/3tNcYl/X--