[cvslog] [CVS] Module eggdrop1.8: Change committed

cvs at eggheads.org cvs at eggheads.org
Sun Oct 10 12:22:58 CST 2010


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.8
Commit time: 2010-10-10 18:22:57 UTC
Committer  : Rumen Stoyanov <pseudo at egg6.net>

Modified files:
     doc/Changes1.8 doc/tcl-commands.doc doc/html/tcl-commands.html
     src/chanprog.c src/patch.h src/proto.h src/tclmisc.c

Log message:

Added the process and parent pids to .status output. Increased the precision of cpu time reporting.
Added a new Tcl command status to provide access to cpu/memory/cache information now and some more in the future.

---------------------- diff included ----------------------
Index: eggdrop1.8/doc/Changes1.8
diff -u eggdrop1.8/doc/Changes1.8:1.15 eggdrop1.8/doc/Changes1.8:1.16
--- eggdrop1.8/doc/Changes1.8:1.15	Wed Oct  6 13:07:47 2010
+++ eggdrop1.8/doc/Changes1.8	Sun Oct 10 12:22:47 2010
@@ -1,4 +1,4 @@
-$Id: Changes1.8,v 1.15 2010/10/06 19:07:47 pseudo Exp $
+$Id: Changes1.8,v 1.16 2010/10/10 18:22:47 pseudo Exp $
 
 Eggdrop Changes (since version 1.8.0)
 
@@ -6,6 +6,12 @@
 
 1.8.0 (CVS):
 
+  - Added the process and parent pids to .status output. Increased the
+    precision of cpu time reporting.
+  - Added a new Tcl command 'status' to provide access to cpu/memory/cache
+    information now and some more in the future.
+    Patch by: pseudo
+
   - Fixed some problems with IPv6 autodetection and system headers.
     Patch by: pseudo
 
Index: eggdrop1.8/doc/html/tcl-commands.html
diff -u eggdrop1.8/doc/html/tcl-commands.html:1.3 eggdrop1.8/doc/html/tcl-commands.html:1.4
--- eggdrop1.8/doc/html/tcl-commands.html:1.3	Fri Oct  1 17:56:37 2010
+++ eggdrop1.8/doc/html/tcl-commands.html	Sun Oct 10 12:22:47 2010
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- $Id: tcl-commands.html,v 1.3 2010/10/01 23:56:37 thommey Exp $ -->
+<!-- $Id: tcl-commands.html,v 1.4 2010/10/10 18:22:47 pseudo Exp $ -->
 
 <html>
   <head>
@@ -3645,6 +3645,8 @@
           </blockquote>
 
           <p><strong>Returns:</strong> the stripped string</p>
+          
+          <p><strong>Module:</strong> core</p>
         </dd>
 
 
@@ -3691,6 +3693,64 @@
           
           <p><strong>Module:</strong> core</p>
         </dd>
+
+        <dt><strong><a name="cmd_status"></a>status [type]</strong></dt>*
+        <dd>
+          <p><strong>Description:</strong> provides eggdrop status
+          information similar to the .status command in partyline. The
+          available types of information are:</p>
+
+          <blockquote>
+            <table>
+              <tr valign="top">
+                <td>
+                  <p><strong>cpu</strong></p>
+                </td>
+
+                <td>
+                  <p>total cpu time spent by eggdrop</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>mem</strong></p>
+                </td>
+
+                <td>
+                  <p>dynamically allocated memory excluding the Tcl
+                  interpreter</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>cache</strong></p>
+                </td>
+
+                <td>
+                  <p>user entries cache hits (in %)</p>
+                </td>
+              </tr>
+
+              <tr valign="top">
+                <td>
+                  <p><strong>ipv6</strong></p>
+                </td>
+
+                <td>
+                  <p>shows whether IPv6 support was compiled in</p>
+                </td>
+              </tr>
+            </table>
+          </blockquote>
+
+          <p><strong>Returns:</strong> the requested information type or all
+          information if type isn't specified. The format is a flat list of
+          name-value pairs.</p>
+          
+          <p><strong>Module:</strong> core</p>
+        </dd>
       </dl>
     </blockquote>
 
Index: eggdrop1.8/doc/tcl-commands.doc
diff -u eggdrop1.8/doc/tcl-commands.doc:1.2 eggdrop1.8/doc/tcl-commands.doc:1.3
--- eggdrop1.8/doc/tcl-commands.doc:1.2	Tue Jul 27 15:49:41 2010
+++ eggdrop1.8/doc/tcl-commands.doc	Sun Oct 10 12:22:47 2010
@@ -1,4 +1,4 @@
-$Id: tcl-commands.doc,v 1.2 2010/07/27 21:49:41 pseudo Exp $
+$Id: tcl-commands.doc,v 1.3 2010/10/10 18:22:47 pseudo Exp $
 
 Eggdrop Tcl Commands
 Last revised: November 23, 2009
@@ -1596,6 +1596,18 @@
 |   Returns: 1 if the pattern matches the string, 0 if it doesn't.
 |   Module: core
 
+|  status [type]
+|    Description: provides eggdrop status information similar to the .status
+|      command in partyline. The available types of information are:
+|        cpu   - total cpu time spent by eggdrop
+|        mem   - dynamically allocated memory excluding the Tcl interpreter
+|        cache - user entries cache hits (in %)
+|        ipv6  - shows whether IPv6 support was compiled in
+|    Returns: the requested information type or all information if type
+|      isn't specified. The format is a flat list of name-value pairs.
+|    Module: core
+
+
 *** GLOBAL VARIABLES ***
 
   NOTE: All config file variables are also global.
Index: eggdrop1.8/src/chanprog.c
diff -u eggdrop1.8/src/chanprog.c:1.1.1.1 eggdrop1.8/src/chanprog.c:1.2
--- eggdrop1.8/src/chanprog.c:1.1.1.1	Mon Jul 26 15:11:06 2010
+++ eggdrop1.8/src/chanprog.c	Sun Oct 10 12:22:47 2010
@@ -7,7 +7,7 @@
  *   telling the current programmed settings
  *   initializing a lot of stuff and loading the tcl scripts
  *
- * $Id: chanprog.c,v 1.1.1.1 2010/07/26 21:11:06 simple Exp $
+ * $Id: chanprog.c,v 1.2 2010/10/10 18:22:47 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -225,6 +225,25 @@
   return tot;
 }
 
+float getcputime()
+{
+#ifdef HAVE_GETRUSAGE
+  float stime, utime;
+  struct rusage ru;
+  
+  getrusage(RUSAGE_SELF, &ru);
+  utime = ru.ru_utime.tv_sec + (ru.ru_utime.tv_usec / 1000000.00);
+  stime = ru.ru_stime.tv_sec + (ru.ru_stime.tv_usec / 1000000.00);
+  return (utime + stime);
+#else
+#  ifdef HAVE_CLOCK
+  return (clock() / (CLOCKS_PER_SEC * 1.00));
+#  else
+  return -1.00;
+#  endif
+#endif
+}
+
 /* Dump uptime info out to dcc (guppy 9Jan99)
  */
 void tell_verbose_uptime(int idx)
@@ -268,13 +287,7 @@
   char *vers_t, *uni_t;
   int i;
   time_t now2 = now - online_since, hr, min;
-#ifdef HAVE_GETRUSAGE
-  struct rusage ru;
-#else
-#  ifdef HAVE_CLOCK
-  clock_t cl;
-#  endif
-#endif
+  float cputime;
 #ifdef HAVE_UNAME
   struct utsname un;
 
@@ -318,21 +331,14 @@
     else
       strcpy(s1, MISC_LOGMODE);
   }
-#ifdef HAVE_GETRUSAGE
-  getrusage(RUSAGE_SELF, &ru);
-  hr = (int) ((ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) / 60);
-  min = (int) ((ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) - (hr * 60));
-  sprintf(s2, "CPU: %02d:%02d", (int) hr, (int) min);    /* Actally min/sec */
-#else
-#  ifdef HAVE_CLOCK
-  cl = (clock() / CLOCKS_PER_SEC);
-  hr = (int) (cl / 60);
-  min = (int) (cl - (hr * 60));
-  sprintf(s2, "CPU: %02d:%02d", (int) hr, (int) min);    /* Actually min/sec */
-#  else
-  sprintf(s2, "CPU: unknown");
-#  endif
-#endif
+  cputime = getcputime();
+  if (cputime < 0)
+    sprintf(s2, "CPU: unknown");
+  else {
+    hr = cputime / 60;
+    cputime -= hr * 60;
+    sprintf(s2, "CPU: %02d:%05.2f", (int) hr, cputime); /* Actally min/sec */
+  }
   dprintf(idx, "%s %s (%s) - %s - %s: %4.1f%%\n", MISC_ONLINEFOR,
           s, s1, s2, MISC_CACHEHIT,
           100.0 * ((float) cache_hit) / ((float) (cache_hit + cache_miss)));
@@ -342,6 +348,7 @@
 
   dprintf(idx, "Config file: %s\n", configfile);
   dprintf(idx, "OS: %s %s\n", uni_t, vers_t);
+  dprintf(idx, "Process ID: %d (parent %d)\n", getpid(), getppid());
 
   /* info library */
   dprintf(idx, "%s %s\n", MISC_TCLLIBRARY,
Index: eggdrop1.8/src/patch.h
diff -u eggdrop1.8/src/patch.h:1.8 eggdrop1.8/src/patch.h:1.9
--- eggdrop1.8/src/patch.h:1.8	Wed Oct  6 13:07:47 2010
+++ eggdrop1.8/src/patch.h	Sun Oct 10 12:22:47 2010
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.8 2010/10/06 19:07:47 pseudo Exp $
+ * $Id: patch.h,v 1.9 2010/10/10 18:22:47 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1286391628");            /* current unixtime */
+patch("1286657566");            /* current unixtime */
 /*
  *
  *
  */
-patch("v6fix");
+patch("tclstatus");
 /*
  *
  *
Index: eggdrop1.8/src/proto.h
diff -u eggdrop1.8/src/proto.h:1.2 eggdrop1.8/src/proto.h:1.3
--- eggdrop1.8/src/proto.h:1.2	Thu Aug  5 12:12:05 2010
+++ eggdrop1.8/src/proto.h	Sun Oct 10 12:22:47 2010
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  *
- * $Id: proto.h,v 1.2 2010/08/05 18:12:05 pseudo Exp $
+ * $Id: proto.h,v 1.3 2010/10/10 18:22:47 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -114,6 +114,7 @@
 void set_chanlist(const char *host, struct userrec *rec);
 void clear_chanlist(void);
 void clear_chanlist_member(const char *nick);
+float getcputime();
 
 /* cmds.c */
 int check_dcc_attrs(struct userrec *, int);
Index: eggdrop1.8/src/tclmisc.c
diff -u eggdrop1.8/src/tclmisc.c:1.2 eggdrop1.8/src/tclmisc.c:1.3
--- eggdrop1.8/src/tclmisc.c:1.2	Thu Aug  5 12:12:05 2010
+++ eggdrop1.8/src/tclmisc.c	Sun Oct 10 12:22:47 2010
@@ -2,7 +2,7 @@
  * tclmisc.c -- handles:
  *   Tcl stubs for everything else
  *
- * $Id: tclmisc.c,v 1.2 2010/08/05 18:12:05 pseudo Exp $
+ * $Id: tclmisc.c,v 1.3 2010/10/10 18:22:47 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -52,7 +52,7 @@
 extern struct userrec *userlist;
 extern time_t now;
 extern module_entry *module_list;
-extern int max_logs;
+extern int max_logs, cache_hit, cache_miss;
 extern log_t *logs;
 extern Tcl_Interp *interp;
 
@@ -763,6 +763,40 @@
   {NULL,     NULL}
 };
 
+static int tcl_status STDVAR
+{
+  char s[15];
+
+  BADARGS(1, 2, " ?type?");
+
+  if ((argc < 2) || !strcmp(argv[1], "cpu")) {
+    Tcl_AppendElement(irp, "cputime");
+    snprintf(s, sizeof s, "%f", getcputime());
+    Tcl_AppendElement(irp, s);
+  }
+  if ((argc < 2) || !strcmp(argv[1], "mem")) {
+    Tcl_AppendElement(irp, "expmem");
+    snprintf(s, sizeof s, "%d", expected_memory());
+    Tcl_AppendElement(irp, s);
+  }
+  if ((argc < 2) || !strcmp(argv[1], "ipv6")) {
+    Tcl_AppendElement(irp, "ipv6");
+#ifdef IPV6
+    Tcl_AppendElement(irp, "enabled");
+#else
+    Tcl_AppendElement(irp, "disabled");
+#endif
+  }
+  if ((argc < 2) || !strcmp(argv[1], "cache")) {
+    Tcl_AppendElement(irp, "usercache");
+    snprintf(s, sizeof s, "%4.1f", 100.0 *
+             ((float) cache_hit) / ((float) (cache_hit + cache_miss)));
+    Tcl_AppendElement(irp, s);
+  }
+  
+  return TCL_OK;
+}
+
 tcl_cmds tclmisc_cmds[] = {
   {"logfile",           tcl_logfile},
   {"putlog",             tcl_putlog},
@@ -804,5 +838,6 @@
   {"matchaddr",       tcl_matchaddr},
   {"matchcidr",       tcl_matchcidr},
   {"matchstr",         tcl_matchstr},
+  {"status",             tcl_status},
   {NULL,                       NULL}
 };
----------------------- End of diff -----------------------


More information about the Changes mailing list