]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
add a -Y option to generate machine readable output.
authorRonnie Sahlberg <sahlberg@ronnie>
Sun, 3 Jun 2007 09:50:51 +0000 (19:50 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Sun, 3 Jun 2007 09:50:51 +0000 (19:50 +1000)
print 'ctdb status' in machinereadable form as
:VNN:0|1:

(This used to be ctdb commit 1aa6a632ec59d854fc5579fedad0d66b1b46ae8c)

ctdb/tools/ctdb_control.c

index 13225df5f3617fe2d7a07148507073abfd7f8a82..f3f9fb6f46ff5b3686564cd106118adc50bf800b 100644 (file)
@@ -32,6 +32,7 @@ static void usage(void);
 static struct {
        int timelimit;
        uint32_t vnn;
+       int machinereadable;
 } options;
 
 #define TIMELIMIT() timeval_current_ofs(options.timelimit, 0)
@@ -288,6 +289,15 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
                return ret;
        }
 
+       if(options.machinereadable){
+               printf(":Node:Status:\n");
+               for(i=0;i<nodemap->num;i++){
+                       printf(":%d:%d:\n", nodemap->nodes[i].vnn,
+                               !!nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED);
+               }
+               return 0;
+       }
+
        printf("Number of nodes:%d\n", nodemap->num);
        for(i=0;i<nodemap->num;i++){
                printf("vnn:%d %s%s\n", nodemap->nodes[i].vnn,
@@ -723,6 +733,7 @@ static void usage(void)
 "Usage: ctdb [options] <control>\n" \
 "Options:\n" \
 "   -n <node>          choose node number, or 'all' (defaults to local node)\n"
+"   -Y                 generate machinereadable output\n"
 "   -t <timelimit>     set timelimit for control in seconds (default %u)\n", options.timelimit);
        printf("Controls:\n");
        for (i=0;i<ARRAY_SIZE(ctdb_commands);i++) {
@@ -747,6 +758,7 @@ int main(int argc, const char *argv[])
                POPT_CTDB_CMDLINE
                { "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0, "timelimit", "integer" },
                { "node",      'n', POPT_ARG_STRING, &nodestring, 0, "node", "integer|all" },
+               { "machinereadable", 'Y', POPT_ARG_NONE, &options.machinereadable, 0, "enable machinereadable output", NULL },
                POPT_TABLEEND
        };
        int opt;