ctdb-scripts: Drop node count from "ctdb natgw status" output
authorMartin Schwenke <martin@meltin.net>
Mon, 18 Apr 2016 05:44:15 +0000 (15:44 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 25 Apr 2016 05:10:14 +0000 (07:10 +0200)
Tweak "ctdb natgw natgwlist" to keep output format the same.

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

index 5c05886fedbad339d2d061932e0e31bf0d7ba08d..2ed168df8a5ad36f9af48db0981a5520ccee7c47 100755 (executable)
@@ -166,10 +166,7 @@ $natgw_nodes
 EOF
 
     # Print status of nodes in $_ns, along with node count
-    awk -v ns="$_ns" \
-       'BEGIN { out = "" ; count = 0 } \
-         ns ~ "@" $2 "@" { out =  out "\n" $0 ; count += 1 } \
-         END { print "Number of nodes:" count out }' <<EOF
+    awk -v ns="$_ns" 'ns ~ "@" $2 "@" { print $0 }' <<EOF
 $nodestatus
 EOF
 }
@@ -177,14 +174,17 @@ EOF
 # For backward compatibility
 natgwlist ()
 {
-    ret=0
+    _ret=0
     find_master
     if [ $? -eq 2 ] ; then
        echo "-1 0.0.0.0"
-       ret=2
+       _ret=2
     fi
-    nodes_status || return $?
-    return $ret
+    _t=$(nodes_status) || return $?
+    _n=$(echo "$_t" | wc -l)
+    echo "Number of nodes:${_n}"
+    echo "$_t"
+    return $_ret
 }
 
 prog=$(basename "$0")