diff -uNrd ircd-hybrid-6.orig/include/config.h ircd-hybrid-6/include/config.h
--- ircd-hybrid-6.orig/include/config.h	Wed Jan 17 19:44:38 2001
+++ ircd-hybrid-6/include/config.h	Wed Jan 17 19:45:50 2001
@@ -188,6 +188,16 @@
 #define FNAME_USERLOG "/usr/local/ircd/users" /* */
 #define FNAME_OPERLOG "/usr/local/ircd/opers" /* */
 
+/* SAVE_MAXCLIENT - store the max local and global client connections
+ * into the file specified by MXPATH at the interval specified by 
+ * SAVE_TIME
+ */
+#define SAVE_MAXCLIENT
+#ifdef SAVE_MAXCLIENT
+# define MXPATH "ircd.max"
+# define SAVE_TIME 3600
+#endif 
+
 /* RFC1035_ANAL
  * Defining this causes ircd to reject hostnames with non-compliant chars.
  * undef'ing it will allow hostnames with _ or / to connect
diff -uNrd ircd-hybrid-6.orig/include/ircd.h ircd-hybrid-6/include/ircd.h
--- ircd-hybrid-6.orig/include/ircd.h	Wed Jan 17 19:44:38 2001
+++ ircd-hybrid-6/include/ircd.h	Wed Jan 17 19:45:50 2001
@@ -150,4 +150,9 @@
  * complain
  */
 #define MAX_SETBACK_TIME 1800
+
+#ifdef SAVE_MAXCLIENT
+extern void write_stats(void);
+#endif
+
 #endif
diff -uNrd ircd-hybrid-6.orig/src/ircd.c ircd-hybrid-6/src/ircd.c
--- ircd-hybrid-6.orig/src/ircd.c	Wed Jan 17 19:44:25 2001
+++ ircd-hybrid-6/src/ircd.c	Wed Jan 17 19:45:50 2001
@@ -637,6 +637,23 @@
     log(L_ERROR, "Error opening pid file %s", PPATH);
 }
 
+#ifdef SAVE_MAXCLIENT
+void write_stats(void)
+{
+  int fd;
+  char buff[20];
+  if ((fd = open(MXPATH, O_CREAT|O_WRONLY, 0600))>=0)
+    {
+      ircsprintf(buff,"%d\n%d\n", Count.max_loc, Count.max_tot);
+      if (write(fd, buff, strlen(buff)) == -1)
+        log(L_ERROR,"Error writing to max clients file %s", MXPATH);
+      close(fd);
+      return;
+    }
+  else
+    log(L_ERROR, "Error opening max clients file %s", MXPATH);
+}
+#endif /* SAVE_MAXCLIENT */
 
 int main(int argc, char *argv[])
 {
@@ -644,6 +661,11 @@
   uid_t       euid;
   time_t      delay = 0;
   aConfItem*  aconf;
+#ifdef SAVE_MAXCLIENT
+  FBFILE* file;
+  char mline[20];
+  int m1;
+#endif
 
   /*
    * save server boot time right away, so getrusage works correctly
@@ -838,6 +860,22 @@
 
   check_class();
   write_pidfile();
+
+#ifdef SAVE_MAXCLIENT
+  if ((file = fbopen(MXPATH, "r")))
+    {
+      if (fbgets(mline, sizeof(mline), file))
+        {
+          m1 = atoi(mline);
+          if (fbgets(mline, sizeof(mline), file))
+            {
+              Count.max_loc = m1;
+              Count.max_tot = atoi(mline);
+            }
+        }
+      fbclose(file);
+    }
+#endif
 
   log(L_NOTICE, "Server Ready");
 
diff -uNrd ircd-hybrid-6.orig/src/ircd_signal.c ircd-hybrid-6/src/ircd_signal.c
--- ircd-hybrid-6.orig/src/ircd_signal.c	Wed Jan 17 19:44:25 2001
+++ ircd-hybrid-6/src/ircd_signal.c	Wed Jan 17 19:45:51 2001
@@ -42,6 +42,9 @@
 static void sigterm_handler(int sig)  
 {
   flush_connections(0);
+#ifdef SAVE_MAXCLIENT
+  write_stats();
+#endif
   log(L_CRIT, "Server killed By SIGTERM");
   exit(-1);
 }
diff -uNrd ircd-hybrid-6.orig/src/m_die.c ircd-hybrid-6/src/m_die.c
--- ircd-hybrid-6.orig/src/m_die.c	Wed Jan 17 19:44:25 2001
+++ ircd-hybrid-6/src/m_die.c	Wed Jan 17 19:45:51 2001
@@ -146,6 +146,9 @@
                    me.name, get_client_name(sptr, MASK_IP));
     }
   flush_connections(0);
+#ifdef SAVE_MAXCLIENT
+  write_stats();
+#endif
   log(L_NOTICE, "Server terminated by %s", get_client_name(sptr, HIDE_IP));
   /* 
    * this is a normal exit, tell the os it's ok 
diff -uNrd ircd-hybrid-6.orig/src/restart.c ircd-hybrid-6/src/restart.c
--- ircd-hybrid-6.orig/src/restart.c	Wed Jan 17 19:44:31 2001
+++ ircd-hybrid-6/src/restart.c	Wed Jan 17 19:45:51 2001
@@ -38,6 +38,9 @@
 
   log(L_NOTICE, "Restarting server...");
   flush_connections(0);
+#ifdef SAVE_MAXCLIENT
+  write_stats();
+#endif
 
   for (i = 0; i < MAXCONNECTIONS; ++i)
     close(i);
diff -uNrd ircd-hybrid-6.orig/src/s_user.c ircd-hybrid-6/src/s_user.c
--- ircd-hybrid-6.orig/src/s_user.c	Wed Jan 17 19:44:32 2001
+++ ircd-hybrid-6/src/s_user.c	Wed Jan 17 19:45:51 2001
@@ -241,6 +241,9 @@
   static int    o_count = 0, m_client = 0, m_server = 0;
   int forced;
   struct Client *acptr;
+#ifdef SAVE_MAXCLIENT
+  static time_t last_stat_save = 0;
+#endif
 
 /*  forced = (parc >= 2); */
   forced = (IsAnOper(sptr) && (parc > 3));
@@ -356,6 +359,14 @@
           Count.unknown = u_count;
         } /* Complain & reset loop */
     } /* Recount loop */
+
+#ifdef SAVE_MAXCLIENT
+  if ((CurrentTime - last_stat_save) > SAVE_TIME)
+    {
+      write_stats();
+      last_stat_save = CurrentTime;
+    }
+#endif
   
 #ifndef SHOW_INVISIBLE_LUSERS
   if (IsAnOper(sptr) && i_count)
