Update of /cvsroot/monetdb/MonetDB5/src/tools
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23701
Modified Files:
merovingian.mx monetdb.mx
Log Message:
merovingian - it can handle a non-initialized dbfarm
monetdb - layout of the status information improved
Index: merovingian.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/merovingian.mx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- merovingian.mx 5 Sep 2007 17:51:30 -0000 1.43
+++ merovingian.mx 8 Sep 2007 07:53:56 -0000 1.44
@@ -1069,10 +1069,21 @@
fflush(stderr);
exit(1);
}
+ if (access(dbfarm,F_OK) == -1 ){
+ GDKcreatedir(dbfarm); /* it doesn't necessarily create all */
+ mkdir(dbfarm,0755);
+ if(access(dbfarm,F_OK) == 0 )
+ fprintf(stderr, "created dbfarm '%s'\n",dbfarm);
+ else {
+ fprintf(stderr, "cannot access dbfarm '%s'\n",dbfarm);
+ fflush(stderr);
+ exit(1);
+ }
+ }
snprintf(buf, 1024, "%s/.merovingian_lock", dbfarm);
/* we leak ret, but that doesn't matter as the file needs to remain
- * available, otherwise we lose the lock */
+ * available, otherwise we loose the lock */
if ((ret = MT_lockf(buf, F_TLOCK, 4, 1)) < 0) {
/* locking failed */
fprintf(stderr, "another merovingian is already running\n");
Index: monetdb.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/monetdb.mx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- monetdb.mx 7 Sep 2007 11:23:39 -0000 1.30
+++ monetdb.mx 8 Sep 2007 07:53:56 -0000 1.31
@@ -183,10 +183,11 @@
}
static void
-printStatus(sabdb *stats, int mode)
+printStatus(sabdb *stats, int mode, int len)
{
sabuplog uplog;
str e;
+ char *state;
if ((e = SABAOTHgetUplogInfo(&uplog, stats)) != MAL_SUCCEED) {
fprintf(stderr, "status: internal error: %s\n", e);
@@ -194,26 +195,26 @@
return;
}
+ switch (stats->state) {
+ case SABdbRunning:
+ state = "running";
+ break;
+ case SABdbCrashed:
+ state = "crashed";
+ break;
+ case SABdbInactive:
+ state = "stopped";
+ break;
+ default:
+ state = "unknown";
+ break;
+ }
+
if (mode == 1) {
/* short one-line mode */
- char *state;
char avg[8];
char *crash;
- switch (stats->state) {
- case SABdbRunning:
- state = "running";
- break;
- case SABdbCrashed:
- state = "crashed";
- break;
- case SABdbInactive:
- state = "stopped";
- break;
- default:
- state = "unknown";
- break;
- }
/* override if locked for brevity */
if (stats->locked == 1)
state = "mainten";
@@ -230,33 +231,17 @@
}
/* demo | running | avguptime | start | stop | crash |
lastcrash */
- printf("%-10s %s %7s %4d %4d %4d %s\n",
- stats->dbname,
+ printf("%*s %s %7s %4d %4d %4d %s\n",
+ -len, stats->dbname,
state, avg,
uplog.startcntr, uplog.stopcntr,
uplog.crashcntr, crash);
} else if (mode == 2) {
/* long mode */
- 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\n", stats->path);
printf(" database name: %s\n", stats->dbname);
@@ -359,7 +344,7 @@
{
int doall = 1; /* we default to showing all */
int mode = 0; /* 0=normal, 1=short, 2=long */
- int i;
+ int i, len = 10;
char *p;
str e;
sabdb *stats;
@@ -401,12 +386,6 @@
}
}
- if (mode == 1) {
- /* print header for short mode */
- /* demo | running | avguptime | start | stop | crash |
lastcrash */
- printf(" name state avgutme strt stop crsh
crashdate\n");
- }
-
if (doall == 1) {
sabdb *orig;
/* don't even look at the arguments, because we are instructed
@@ -418,8 +397,24 @@
}
orig = stats;
+ i= 0;
+ while( stats != NULL){
+ i++;
+ if( (int) strlen(stats->dbname) > len)
+ len= (int) strlen(stats->dbname);
+ stats= stats->next;
+ }
+
+ if (mode == 1) {
+ /* print header for short mode */
+ /* demo | running | avguptime | start | stop | crash |
lastcrash */
+ printf("%*s state avgutme strt stop crsh
crashdate\n",
+ -len,"name");
+ }
+
+ stats= orig;
while (stats != NULL) {
- printStatus(stats, mode);
+ printStatus(stats, mode,len);
stats = stats->next;
}
@@ -428,6 +423,24 @@
return;
}
+ for (i = 1; i < argc; i++)
+ if (argv[i] != NULL) {
+ if ((e = SABAOTHgetStatus(&stats, argv[i])) !=
MAL_SUCCEED) {
+ fprintf(stderr, "status: internal error: %s\n",
e);
+ GDKfree(e);
+ exit(2);
+ }
+ if( (int) strlen(stats->dbname) >len)
+ len = (int) strlen(stats->dbname);
+ }
+
+ if (mode == 1) {
+ /* print header for short mode */
+ /* demo | running | avguptime | start | stop | crash |
lastcrash */
+ printf("%*s state avgutme strt stop crsh crashdate\n",
+ -len,"name");
+ }
+
for (i = 1; i < argc; i++) {
if (argv[i] != NULL) {
if ((e = SABAOTHgetStatus(&stats, argv[i])) !=
MAL_SUCCEED) {
@@ -439,7 +452,7 @@
if (stats == NULL) {
fprintf(stderr, "status: no such database:
%s\n", argv[i]);
} else {
- printStatus(stats, mode);
+ printStatus(stats, mode, 10);
SABAOTHfreeStatus(&stats);
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins