1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-01 04:58:35 +03:00

add a -Y option to generate machine readable output.

print 'ctdb status' in machinereadable form as
:VNN:0|1:

(This used to be ctdb commit 1aa6a632ec59d854fc5579fedad0d66b1b46ae8c)
This commit is contained in:
Ronnie Sahlberg 2007-06-03 19:50:51 +10:00
parent dac3f7d23c
commit 5dde7e27e0

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