tools/ctdb: New command runstate to print current runstate
authorMartin Schwenke <martin@meltin.net>
Fri, 11 Jan 2013 03:07:12 +0000 (14:07 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 24 May 2013 04:08:07 +0000 (14:08 +1000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

doc/ctdb.1.xml
tools/ctdb.c

index 83d0ac0365ff1cc5041812db1b90a4707a966eb0..d1734b7c8fb578dfcc267b60c0b8ba4a2ddeb338 100644 (file)
@@ -382,6 +382,23 @@ response from 3 time=0.000114 sec  (2 clients)
       </screen>
     </refsect2>
 
+    <refsect2><title>runstate</title>
+      <para>
+        Print the runstate of the specified node.  Runstates are used
+        to serialise important state transitions in CTDB, particularly
+        during startup.
+      </para>
+      <para>
+       Example: ctdb runstate
+      </para>
+      <para>
+       Example output:
+      </para>
+      <screen format="linespecific">
+RUNNING
+      </screen>
+    </refsect2>
+
     <refsect2><title>ifaces</title>
       <para>
        This command will display the list of network interfaces, which could
index ec2396d589a7a2e38f13a014bf79f378ad7cb61b..842c872b6414d48d9c141e2eb7bd6221cc53824d 100644 (file)
@@ -4372,6 +4372,26 @@ static int control_ping(struct ctdb_context *ctdb, int argc, const char **argv)
 }
 
 
+/*
+  get a node's runstate
+ */
+static int control_runstate(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       int ret;
+       enum ctdb_runstate runstate;
+
+       ret = ctdb_ctrl_get_runstate(ctdb, TIMELIMIT(), options.pnn, &runstate);
+       if (ret == -1) {
+               printf("Unable to get runstate response from node %u\n",
+                      options.pnn);
+               return -1;
+       }
+
+       printf("%s\n", runstate_to_string(runstate));
+       return 0;
+}
+
+
 /*
   get a tunable
  */
@@ -5804,6 +5824,7 @@ static const struct {
        { "status",          control_status,            true,   false,  "show node status" },
        { "uptime",          control_uptime,            true,   false,  "show node uptime" },
        { "ping",            control_ping,              true,   false,  "ping all nodes" },
+       { "runstate",        control_runstate,          true,   false,  "get runstate of a node" },
        { "getvar",          control_getvar,            true,   false,  "get a tunable variable",               "<name>"},
        { "setvar",          control_setvar,            true,   false,  "set a tunable variable",               "<name> <value>"},
        { "listvars",        control_listvars,          true,   false,  "list tunable variables"},