RFE: Better logging

Mattias.Gronlund Mattias.Gronlund at sa.erisoft.se
Wed Jun 2 21:22:11 GMT 1999


Hi,

I administrate three SUN-servers which have >500 clients connected
we have had som problems with Samba from time to time. The current
release seems very stable, but we still need an improved log-files
to find all the bugs. I'm not saying that the current logging is
bad (havent seen much better), but there is still some improvments
that I think could be done.

1. For sites with lots of clients you don't allways whant to split
   the log into one log per client. But you still whant to be able
   to identify which messages relates to which machine. There may
   even be intresting to see which process they relate to if it is
   a multiuser client whith one smbd per user.
   My proposal is to add a process-ID  attribute to the log-header
   and to write one level 0 message whenever a new process forks.

2. We have had some problems with "Slow network detected" and was
   able to track it down and implement a "hack" that was reported
   and the "Samba team" was able to implement a nice patch. The
   tool we used was an extra microsecond attribute in the log-
   header. The current implementation a cached time to the header,
   it may be write a time stamp at least one second wrong.

3. Before we installed version 2 of samba we had some strange
   "Failed to set socket option" entrys in our log, they appeared
   infrequently but they where there. Sadly enought the log-entry
   didn't specify errno so we had a hard time debugging it any
   futher.

Our problem at the time is that we are running Samba in full
production an we can't even "restart" samba other then one
weekend a month or we get lots of Netscape crashes and who knows
what else, so we are extreamly log-dependent for debugging...

I will include some "hack" patches that might explain what I
would like. If it they will get better acceptance I'm more then
willing to clean them up.

BTW: Thanks for an Extreamly stable and debuggable product!

Regard
  Mattias
-------------- next part --------------
--- lib/time.c.orig	Tue May 25 14:14:30 1999
+++ lib/time.c	Wed Jun  2 23:13:41 1999
@@ -509,16 +509,19 @@
 char *timestring(void )
 {
 	static fstring TimeBuf;
-	time_t t = time(NULL);
-	struct tm *tm = LocalTime(&t);
-
+	struct timeval tp;
+	struct tm *tm;
+	GetTimeOfDay(&tp);
+	
+	tm = LocalTime(&(time_t)tp.tv_sec);
 	if (!tm) {
-		slprintf(TimeBuf,sizeof(TimeBuf)-1,"%ld seconds since the Epoch",(long)t);
+		slprintf(TimeBuf,sizeof(TimeBuf)-1,"%ld.%06ld seconds since the Epoch",(long)tp.tv_sec, (long)tp.tv_usec);
 	} else {
 #ifdef HAVE_STRFTIME
-		strftime(TimeBuf,100,"%Y/%m/%d %H:%M:%S",tm);
+		strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm);
+		slprintf(TimeBuf+strlen(TimeBuf), sizeof(TimeBuf)-1 - strlen(TimeBuf), ".%06ld", (long)tp.tv_usec);
 #else
-		fstrcpy(TimeBuf, asctime(tm));
+		slprintf(TimeBuf, sizeof(TimeBuf)-1, "%s.%06ld", asctime(tm), (long)tp.tv_usec);
 #endif
 	}
 	return(TimeBuf);
--- smbd/server.c.old	Wed Apr 28 23:44:59 1999
+++ smbd/server.c	Wed Jun  2 22:58:19 1999
@@ -232,7 +232,8 @@
 				   descriptors */
 				close_low_fds();
 				am_parent = 0;
-				
+
+				DEBUG(0, ("open_sockets: Recieved new connection"));
 				set_socket_options(Client,"SO_KEEPALIVE");
 				set_socket_options(Client,user_socket_options);
 				
--- lib/debug.c.orig	Tue May 25 14:14:34 1999
+++ lib/debug.c	Tue May 25 14:22:53 1999
@@ -544,8 +544,8 @@
   if( lp_timestamp_logs() || !(lp_loaded()) )
     {
     /* Print it all out at once to prevent split syslog output. */
-    (void)Debug1( "[%s, %d] %s:%s(%d)\n",
-                  timestring(), level, file, func, line );
+    (void)Debug1( "[%s, %d, %d] %s:%s(%d)\n",
+                  timestring(), level, getpid(), file, func, line );
     }
 
   return( True );
--- lib/util_sock.c.orig	Tue May 18 00:28:11 1999
+++ lib/util_sock.c	Tue May 25 14:25:48 1999
@@ -152,7 +152,8 @@
 	}
       
       if (ret != 0)
-	DEBUG(0,("Failed to set socket option %s\n",tok));
+	DEBUG(0,("Failed to set socket option %s, %s\n",
+	       tok,strerror(errno)));
     }
 }
 


More information about the samba-technical mailing list