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

Modified Files:
        monetdb.mx 
Log Message:
Undo Martin's changes, as they are not what I intended this tool to be,
and because I disagree that "expected features" should be made clear by
adding the documentation/command line options, and not implementing
them.


Index: monetdb.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/monetdb.mx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- monetdb.mx  18 Aug 2007 16:43:45 -0000      1.4
+++ monetdb.mx  18 Aug 2007 22:04:30 -0000      1.5
@@ -18,16 +18,12 @@
 @a Fabian Groffen
 @v 1.0
 @* MonetDB Database Administrator's Toolkit
-The monetdb utility is designed to be the interface for the DBA to the dbfarm.
-It simplifies database creation and deletion. Furthermore, it
-provides the primary interface to detect the service
-status of all running servers.
+A group of MonetDB servers in a dbfarm are under control of the
+Merovingian, which by itself does not allow any user interaction.
+The monetdb utility is designed to be the interface for the DBA to the
+dbfarm.  Creating or deleting databases next to retrieving status
+information about them are the primary goals of this tool.
 
-Managing the databases servers on a single host is handled by the merovigian,
-which relies on the Sabaoth functionality available in each server.
-The Merovigian prime task is to start database servers and redirect
-clients to the proper port.
-A group of MonetDB servers in a dbfarm are under control of the Merovingian.
 @h
 #define TOOLKIT_VERSION   "0.1"
 
@@ -35,8 +31,6 @@
 #include "mal_config.h" /* MONETDBCONFIG, MONETDBPREFIX */
 #include "monetdb.h"
 #include "mal_sabaoth.h"
-
-/* clean out, only mention those not already covered */
 #include <stdlib.h> /* exit */
 #include <stdarg.h>    /* variadic stuff */
 #include <stdio.h> /* fprintf */
@@ -54,9 +48,6 @@
 #define getErrMsg(X) X
 #define NO_ERR (err)0
 
-/* also take care of the OS depedent directory separator */
-#define DIR_SEP '/'
-
 static str
 replacePrefix(str s)
 {
@@ -71,10 +62,10 @@
                memcpy(buf, s, p - s);
                memcpy(buf + (p - s), MONETDBPREFIX, strlen(MONETDBPREFIX));
                memcpy(buf + (p - s) + strlen(MONETDBPREFIX), s + (p - s) + 9, 
strlen(s) - 9 - (p - s) + 1);
-       } 
-       for( s=buf; *s; s++)
-               *s= *s=='/'? DIR_SEP:*s;
-       return(buf);
+               return(buf);
+       } else {
+               return(strdup(s));
+       }
 }
 
 static void
@@ -87,32 +78,27 @@
                printf("  use the help command to get help for a particular 
command\n");
        } else if (strcmp(argv[1], "status") == 0) {
                printf("Usage: monetdb status [-als] [database ...]\n");
-               printf("  Shows the state of a given database service.\n");
-               printf("  Various options control what information\n");
+               printf("  Shows the state of a given database as known to 
the\n");
+               printf("  Sabaoth system.  Various options control what 
information\n");
                printf("  is displayed.\n");
                printf("Options:\n");
-               printf(" -d database | --database=nme  \n");
-               printf(" -l         | --list       list status of all databases 
[default]\n");
-               printf(" -c         | --cycle=#    list status of all databases 
every # seconds\n");
-               printf(" -b         | --brief      use short one-line 
listing\n");
-               printf(" -p         | --pause      suspend new client 
connections\n");
-               printf(" -r         | --resume     accept new client 
connections\n");
-               printf(" -s         | --shutdown   bring service down \n");
-               printf(" -a         | --activate   service can be started again 
\n");
+               printf("  -a  list status of all databases\n");
+               printf("  -l  use long listing\n");
+               printf("  -s  use short one-line listing\n");
        } else if (strcmp(argv[1], "create") == 0) {
                printf("Usage: monetdb create database\n");
-               printf("  Initialises a new database on the (local?) system. 
\n");
-               printf(" -d database | --database=nme  \n");
+               printf("  Initialises a new database in the Sabaoth system.  
A\n");
+               printf("  database created with this command makes it 
available\n");
+               printf("  to Merovingian.\n");
        } else if (strcmp(argv[1], "destroy") == 0) {
                printf("Usage: monetdb destroy [-f] database\n");
                printf("  Removes the given database, including all its data 
and\n");
                printf("  logfiles.  Once destroy has completed, all data is 
lost.\n");
                printf("  Be careful when using this command.\n");
                printf("Options:\n");
-               printf("  -f         | --force  do not ask for confirmation, 
destroy right away\n");
-               printf(" -d database | --database=nme  \n");
+               printf("  -f  do not ask for confirmation, destroy right 
away\n");
        } else if (strcmp(argv[1], "help") == 0) {
-               /* printf("Yeah, help on help, how desparate can you be? ;)");*/
+               printf("Yeah, help on help, how desparate can you be? ;)");
        } else if (strcmp(argv[1], "version") == 0) {
                printf("Usage: monetdb version\n");
                printf("  prints the version of the monetdb toolkit\n");
@@ -130,9 +116,47 @@
 static void
 command_status(int argc, char *argv[])
 {
-       (void)argc;
-       (void)argv;
-       printf("status: not yet implemented\n");
+       int doall;
+       int mode = 0;  /* 0=normal, 1=short, 2=long */
+       int i;
+       char *p;
+
+       if (argc == 1) {
+               /* print help message for this command */
+               command_help(2, &argv[-1]);
+               exit(1);
+       } else if (argc == 0) {
+               exit(2);
+       }
+
+       /* time to collect some option flags */
+       for (i = 1; i < argc; i++) {
+               if (argv[i][0] == '-') {
+                       for (p = argv[i] + 1; *p != '\0'; p++) {
+                               switch (*p) {
+                                       case 'a':
+                                               doall = 1;
+                                       break;
+                                       case 's':
+                                               mode = 1;
+                                       break;
+                                       case 'l':
+                                               mode = 2;
+                                       break;
+                                       case '-':
+                                               if (p[1] == '\0') {
+                                                       i = argc;
+                                                       break;
+                                               }
+                                       default:
+                                               fprintf(stderr, "status: 
unknown option: -%c\n", *p);
+                                               command_help(2, &argv[-1]);
+                                               exit(1);
+                                       break;
+                               }
+                       }
+               }
+       }
 }
 
 static void
@@ -140,7 +164,7 @@
 {
        if (argc == 1 || argc >= 3) {
                /* print help message for this command */
-               command_help(argc + 1, &argv[-1]);
+               command_help(2, &argv[-1]);
                exit(1);
        } else if (argc == 2) {
                sabdb *stats;
@@ -164,12 +188,11 @@
                                                argv[1], strerror(errno));
                                exit(1);
                        }
-/* WARNING dir-sep */
                        /* without an .uplog file, Merovingian won't work */
                        snprintf(path, 8095, "%s/%s/.uplog", dbfarm, argv[1]);
                        fclose(fopen(path, "w"));
                        /* avoid GDK from making fugly complaints */
-                       snprintf(path, 8095, "%s%c%s%c.gdk_lock", dbfarm, 
DIR_SEP, argv[1], DIR_SEP);
+                       snprintf(path, 8095, "%s/%s/.gdk_lock", dbfarm, 
argv[1]);
                        f = fopen(path, "w");
                        /* to all insanity, .gdk_lock is "valid" if it contains 
a
                         * ':', which it does by pure coincidence of a time 
having a
@@ -204,7 +227,7 @@
                return(strdup(data));
        }
        while ((e = readdir(d)) != NULL) {
-               snprintf(path, PATHLENGTH, "%s%c%s", dir, DIR_SEP, e->d_name);
+               snprintf(path, PATHLENGTH, "%s/%s", dir, e->d_name);
                if (stat(path, &s) == -1) {
                        snprintf(data, 8095, "unable to stat file %s: %s",
                                        path, strerror(errno));


-------------------------------------------------------------------------
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