Update of /cvsroot/monetdb/MonetDB5/src/tools
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15018/src/tools

Modified Files:
      Tag: GDK-2
        merovingian.mx monetdb.mx prog.c 
Log Message:
propagated changes of Friday Aug 24 2007 - Tuesday Aug 28 2007
from the development trunk to the GDK-2 branch

There were inexplicable conflicts in src/modules/mal/batxml.mx and
src/modules/mal/Tests/inspect05.stable.out, neither of which had been
changed on the branch.  I just copied the HEAD version to the branch
to resolve the conflicts.


Index: prog.c
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/prog.c,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -u -d -r1.7 -r1.7.4.1
--- prog.c      27 Apr 2007 09:45:40 -0000      1.7
+++ prog.c      28 Aug 2007 13:15:59 -0000      1.7.4.1
@@ -101,7 +101,7 @@
        if (!(setlen = mo_builtin_settings(&set)))
                usage(prog);
 
-       /* needed, to prevent the MonetDB config file to be used */  
+       /* needed, to prevent the MonetDB config file from being used */  
        setlen = mo_add_option(&set, setlen, opt_config, "prefix", 
MONETDBPREFIX);
        setlen = mo_add_option(&set, setlen, opt_config, "config", 
MONETDBCONFIG);
        setlen = mo_system_config(&set, setlen);

Index: merovingian.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/merovingian.mx,v
retrieving revision 1.27.2.1
retrieving revision 1.27.2.2
diff -u -d -r1.27.2.1 -r1.27.2.2
--- merovingian.mx      21 Aug 2007 13:24:46 -0000      1.27.2.1
+++ merovingian.mx      28 Aug 2007 13:15:56 -0000      1.27.2.2
@@ -386,7 +386,7 @@
         * one here. */
 
        /* retrieve uplog information to print a short conclusion */
-       er = SABAOTHgetUplogInfo(&info, database);
+       er = SABAOTHgetUplogInfo(&info, *stats);
        if (er != MAL_SUCCEED) {
                err e = newErr("could not retrieve uplog information: %s", er);
                GDKfree(er);
@@ -705,7 +705,7 @@
                stat = top;
        }
 
-       /* need to send a redirect */
+       /* if we can't redirect, our mission ends here */
        if (stat->conns == NULL || stat->conns->val == NULL) {
                err e = newErr("database '%s' does not allow connections", 
stat->dbname);
                stream_printf(fout, "!database '%s' does not allow 
connections\n", stat->dbname);
@@ -719,6 +719,7 @@
        merlog("redirecting client for database '%s' to %s",
                        stat->dbname, stat->conns->val);
 
+       /* need to send a redirect */
        stream_printf(fout, "^%s%s\n",
                        stat->conns->val, stat->dbname);
        /* flush redirect and return */

Index: monetdb.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/monetdb.mx,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -u -d -r1.8.2.2 -r1.8.2.3
--- monetdb.mx  21 Aug 2007 13:24:52 -0000      1.8.2.2
+++ monetdb.mx  28 Aug 2007 13:15:58 -0000      1.8.2.3
@@ -49,6 +49,8 @@
 #define getErrMsg(X) X
 #define NO_ERR (err)0
 
+static str dbfarm = NULL;
+
 static str
 replacePrefix(str s)
 {
@@ -115,17 +117,38 @@
 }
 
 static void
-secondsToString(char *buf, time_t t)
+secondsToString(char *buf, time_t t, int printlong)
 {
-       if (t > 1 * 60 * 60 * 24) {
-               snprintf(buf, 8, "%dd", (int)(t / (1 * 60 * 60 * 24)));
-       } else if (t > 1 * 60 * 60) {
-               snprintf(buf, 8, "%dh", (int)(t / (1 * 60 * 60)));
-       } else if (t > 1 * 60) {
-               snprintf(buf, 8, "%dm", (int)(t / (1 * 60)));
-       } else {
-               snprintf(buf, 8, "%ds", (int)(t));
+       time_t p;
+       size_t i = 0;
+
+       p = 1 * 60 * 60 * 24;
+       if (t > p) {
+               i += sprintf(buf, "%dd", (int)(t / p));
+               t -= (t / p) * p;
+               if (printlong == 0)
+                       return;
+               buf[i++] = ' ';
+       }
+       p = 1 * 60 * 60;
+       if (t > p) {
+               i += sprintf(buf + i, "%dh", (int)(t / p));
+               t -= (t / p) * p;
+               if (printlong == 0)
+                       return;
+               buf[i++] = ' ';
+       }
+       p = 1 * 60;
+       if (t > p) {
+               i += sprintf(buf + i, "%dm", (int)(t / p));
+               t -= (t / p) * p;
+               if (printlong == 0)
+                       return;
+               buf[i++] = ' ';
        }
+
+       /* t must be < 60 */
+       sprintf(buf + i, "%ds", (int)(t));
 }
 
 static void
@@ -134,7 +157,7 @@
        sabuplog uplog;
        str e;
 
-       if ((e = SABAOTHgetUplogInfo(&uplog, stats->dbname)) != MAL_SUCCEED) {
+       if ((e = SABAOTHgetUplogInfo(&uplog, stats)) != MAL_SUCCEED) {
                fprintf(stderr, "status: internal error: %s\n", e);
                GDKfree(e);
                return;
@@ -161,7 +184,7 @@
                        break;
                }
 
-               secondsToString(avg, uplog.avguptime);
+               secondsToString(avg, uplog.avguptime, 0);
 
                if (uplog.lastcrash == -1) {
                        crash = "no crash";
@@ -180,20 +203,96 @@
                                uplog.crashcntr, crash);
        } else if (mode == 2) {
                /* long mode */
-               /* path to database */
+               char *state;
+               sablist *entry;
+               char up[32];
+               struct tm *t;
+
+               switch (stats->state) {
+                       case SABdbRunning:
+                               state = "running";
+                       break;
+                       case SABdbCrashed:
+                               state = "crashed";
+                       break;
+                       case SABdbInactive:
+                               state = "stopped";
+                       break;
+                       default:
+                               state = "unknown";
+                       break;
+               }
+
+               printf("%s:\n", stats->dbname);
+               printf("  location: %s/%s\n", dbfarm, stats->dbname);
+               printf("  database name: %s\n", stats->dbname);
+               printf("  state: %s\n", state);
+               entry = stats->scens;
+               printf("  available scenarios:");
+               if (entry == NULL) {
+                       printf(" (none)");
+               } else while (entry != NULL) {
+                       printf(" %s", entry->val);
+                       entry = entry->next;
+               }
+               printf("\n");
+               entry = stats->conns;
+               printf("  listening connections:");
+               if (entry == NULL) {
+                       printf(" (none)");
+               } else while (entry != NULL) {
+                       printf(" %s", entry->val);
+                       entry = entry->next;
+               }
+               printf("\n");
+               printf("  start count: %d\n  stop count: %d\n  crash count: 
%d\n",
+                               uplog.startcntr, uplog.stopcntr, 
uplog.crashcntr);
+               if (stats->state == SABdbRunning) {
+                       secondsToString(up, time(NULL) - uplog.laststart, 1);
+                       printf("  current uptime: %s\n", up);
+               }
+               secondsToString(up, uplog.avguptime, 1);
+               printf("  average uptime: %s\n", up);
+               secondsToString(up, uplog.maxuptime, 1);
+               printf("  maximum uptime: %s\n", up);
+               secondsToString(up, uplog.minuptime, 1);
+               printf("  minimum uptime: %s\n", up);
+               if (uplog.lastcrash != -1) {
+                       t = localtime(&uplog.lastcrash);
+                       strftime(up, 32, "%Y-%m-%d %H:%M:%S", t);
+               } else {
+                       sprintf(up, "(unknown)");
+               }
+               printf("  last crash: %s\n", up);
+               if (uplog.laststart != -1) {
+                       t = localtime(&uplog.laststart);
+                       strftime(up, 32, "%Y-%m-%d %H:%M:%S", t);
+               } else {
+                       sprintf(up, "(unknown)");
+               }
+               printf("  last start: %s\n", up);
+               printf("  average of crashes in the last start attempt: %d\n",
+                               uplog.crashavg1);
+               printf("  average of crashes in the last 10 start attempts: 
%.2f\n",
+                               uplog.crashavg10);
+               printf("  average of crashes in the last 30 start attempts: 
%.2f\n",
+                               uplog.crashavg30);
        } else {
                /* this is the default, also for modes that are added but we
-                * don't understand */
+                * don't understand (yet) */
                char buf[64];
                char min[8], avg[8], max[8];
                struct tm *t;
                /* dbname, status -- since, crash averages */
 
                switch (stats->state) {
-                       case SABdbRunning:
+                       case SABdbRunning: {
+                               char up[32];
                                t = localtime(&uplog.laststart);
-                               strftime(buf, 64, "up since %Y-%m-%d %H:%M:%S", 
t);
-                       break;
+                               strftime(buf, 64, "up since %Y-%m-%d %H:%M:%S, 
", t);
+                               secondsToString(up, time(NULL) - 
uplog.laststart, 1);
+                               strcat(buf, up);
+                       } break;
                        case SABdbCrashed:
                                t = localtime(&uplog.lastcrash);
                                strftime(buf, 64, "crashed on %Y-%m-%d 
%H:%M:%S", t);
@@ -210,9 +309,9 @@
                                "in total %d crashes\n",
                                uplog.crashavg1, uplog.crashavg10, 
uplog.crashavg30,
                                uplog.crashcntr);
-               secondsToString(min, uplog.minuptime);
-               secondsToString(avg, uplog.avguptime);
-               secondsToString(max, uplog.maxuptime);
+               secondsToString(min, uplog.minuptime, 0);
+               secondsToString(avg, uplog.avguptime, 0);
+               secondsToString(max, uplog.maxuptime, 0);
                printf("  uptime stats (min/avg/max): %s/%s/%s over %d runs\n",
                                min, avg, max, uplog.stopcntr);
        }
@@ -513,7 +612,6 @@
 main(int argc, char *argv[])
 {
        str conf = MONETDBCONFIG;
-       str dbfarm;
        str p;
        FILE *cnf = NULL;
        char buf[1024];
@@ -526,7 +624,6 @@
                exit(1);
        }
 
-       dbfarm = NULL;
        while (fgets(buf, 1024, cnf) != NULL) {
                /* eliminate fgets' newline */
                buf[strlen(buf) - 1] = '\0';


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to