ctdb-tools: Add top-level "ctdb natgw" command
authorMartin Schwenke <martin@meltin.net>
Mon, 18 Apr 2016 04:26:58 +0000 (14:26 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 25 Apr 2016 05:10:15 +0000 (07:10 +0200)
This can list the different aspects of status: master, list, status.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/doc/ctdb.1.xml
ctdb/tools/ctdb.c

index 7c3b55199350cf7723f90942ff2c87d254ad7d8b..fb7c468402d40c0bbe86ab32b18c5518290f8cbd 100644 (file)
@@ -490,6 +490,71 @@ pnn:3 192.168.2.203       OK
       </refsect3>
     </refsect2>
 
+    <refsect2>
+      <title>natgw {master|list|status}</title>
+      <para>
+       This command shows different aspects of NAT gateway status.
+       For an overview of CTDB's NAT gateway functionality please see
+       the <citetitle>NAT GATEWAY</citetitle> section in
+       <citerefentry><refentrytitle>ctdb</refentrytitle>
+       <manvolnum>7</manvolnum></citerefentry>.
+      </para>
+
+      <variablelist>
+       <varlistentry>
+         <term>master</term>
+         <listitem>
+           <para>
+             Show the PNN and private IP address of the current NAT
+             gateway master node.
+           </para>
+           <para>
+             Example output:
+           </para>
+           <screen>
+1 192.168.2.201
+           </screen>
+         </listitem>
+       </varlistentry>
+       <varlistentry>
+         <term>list</term>
+         <listitem>
+           <para>
+             List the private IP addresses of nodes in the current
+             NAT gateway group, annotating the master node.
+           </para>
+           <para>
+             Example output:
+           </para>
+           <screen>
+192.168.2.200
+192.168.2.201  MASTER
+192.168.2.202
+192.168.2.203
+           </screen>
+         </listitem>
+       </varlistentry>
+       <varlistentry>
+         <term>status</term>
+         <listitem>
+           <para>
+             List the nodes in the current NAT gateway group and
+             their status.
+           </para>
+           <para>
+             Example output:
+           </para>
+           <screen>
+pnn:0 192.168.2.200       UNHEALTHY (THIS NODE)
+pnn:1 192.168.2.201       OK
+pnn:2 192.168.2.202       OK
+pnn:3 192.168.2.203       OK
+           </screen>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+    </refsect2>
+
     <refsect2>
       <title>ping</title>
       <para>
index 350e2dfe5c87aac56348ffee28c4cc98abe5c970..f04adb122b1e6b848f6fb7a7a86d3b3171d40064 100644 (file)
@@ -1173,6 +1173,29 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
        exit(1);
 }
 
+/* Display NAT gateway status */
+static int control_natgw(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       static char prog[PATH_MAX+1] = "";
+
+       if (argc != 1) {
+               usage();
+       }
+
+       if (!ctdb_set_helper("NAT gateway helper", prog, sizeof(prog),
+                            "CTDB_NATGW_HELPER", CTDB_HELPER_BINDIR,
+                            "ctdb_natgw")) {
+               DEBUG(DEBUG_ERR, ("Unable to set NAT gateway helper\n"));
+               exit(1);
+       }
+
+       execl(prog, prog, argv[0], NULL);
+
+       DEBUG(DEBUG_ERR,
+             ("Unable to run NAT gateway helper %s\n", strerror(errno)));
+       exit(1);
+}
+
 /*
   display the status of the scripts for monitoring (or other events)
  */
@@ -5836,6 +5859,7 @@ static const struct {
        { "enablescript",     control_enablescript,  true,      false, "enable an eventscript", "<script>"},
        { "disablescript",    control_disablescript,  true,     false, "disable an eventscript", "<script>"},
        { "natgwlist",        control_natgwlist,        false,  true, "show the nodes belonging to this natgw configuration"},
+       { "natgw",            control_natgw,            false,  true, "show NAT gateway configuration ", "[master|list|status]"},
        { "xpnn",             control_xpnn,             false,  true,  "find the pnn of the local node without talking to the daemon (unreliable)" },
        { "getreclock",       control_getreclock,       true,   false, "Show the reclock file of a node"},
        { "setreclock",       control_setreclock,       true,   false, "Set/clear the reclock file of a node", "[filename]"},