[distcc] Patch to distccmon-text (a.k.a, mon-text.c)

eparker at mail.kickingdragon.com eparker at mail.kickingdragon.com
Mon Sep 13 20:17:19 GMT 2004


Hello!

I'm using distcc to set up my gentoo servers at home, and man it's awesome!
(Wish I didn't have such flakey hardware, that I have to restart it all the
time, but that's another matter.. :)).

Anyhow, I'm quite a fan of the console, so I put together a tiny patch to
make the distccmon-text output look a little nicer. Basically this is what
it does:

*.- Refrains from printing out a newline, if nothing new was displayed
(different compiler 'batches' are still separated by spaces, tho').
*.- Prints the time/date. 

So, pretty simple - ideally I suppose there should be command line options
to toggle some of these on and off, but I figured some people might like
this, as I know I have!

Anyhow, to apply this patch, run patch -Np1 [path-to-"mon-text.c"]
[patch-file-name].

Save the following output to a file, something like
distcc-2.16-nicer-output.patch, and use it as the second parameter to the
above command.

If there's any questions, suggestions, comments, let me know (I'm not on
this list, so please e-mail me directly. eparker @ freeshell . org).

If I get the time, I'm thinking an ncurses-based monitor would be nice..
Something to toggle these settings easily, etc.

(I by no means say my code is the be-all-end-all... :) No warranties, etc,
etc. :))

Here's the patch, copy everything between the lines:
-------------------BEGIN-----------------
--- distcc-2.16/src/mon-text.c  2004-07-08 06:02:15.000000000 +0000
+++ ../distcc-2.16/src/mon-text.c       2004-09-13 19:53:39.000000000 +0000
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <time.h>

 #include "types.h"
 #include "distcc.h"
@@ -88,25 +89,33 @@
      * other program, so make sure we're always line buffered. */
     setvbuf (stdout, NULL, _IOLBF, BUFSIZ);

+    char currentTime[9];
+
     do {
         struct dcc_history *i;

         if ((ret = dcc_mon_poll(&list)))
             return ret;
-
+       unsigned dirty=0;
         for (i = list; i; i = i->next) {
+           dirty = 1;
 #if 1
             if (i->curr_state == DCC_STATE_DONE)
                 continue;
 #endif
+           time_t cTime;
+           time(&cTime);
+           strftime(currentTime, 9, "%H:%M:%S", localtime(&cTime));
             /* Assume 80 cols = */
-            printf("%6ld  %-10.10s  %-30.30s %24.24s[%d]\n",
-                   (long) i->cpid,
+            printf("[%8s] %6ld  %-10.10s  %-30.30s %24.24s[%d]\n",
+                   currentTime,
+                  (long) i->cpid,
                    dcc_get_state_name(i->curr_state),
                    i->file, i->host, i->slot);
         }

-        printf("\n");
+        if(dirty)
+                printf("\n");

         /* XXX: usleep() is probably not very portable */
         usleep(delay * 1000000);
------------------- END -----------------

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .





More information about the distcc mailing list