summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2014-11-24 17:07:02 +0530
committerKaushal M <kaushal@redhat.com>2015-02-18 05:02:12 -0800
commit692dd7e83cc8a1c85581dda3f752d5ea3b184f8c (patch)
tree7b13bc89e337bdff2cad6d0d6d0043eecaf3cee8 /cli/src
parent554823cd784b0afb37da68e71e7fc63643b644dc (diff)
cli: volume status for tcp,rdma type volume display only tcp port
For tcp,rdma type voumes, there will be two ports, one for tcp and one for rdma. But volume status command only display tcp port. By this change, adding an extra column for rdma port and changing the port to tcp port. Eg: >gluster volume status pathy >For tcp,rdma type volume Status of volume: patchy Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick brickname 49152 49153 Y 14158 >For rdma type volume Status of volume: patchy Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick brickname 0 49153 Y 14158 For tcp type volume Status of volume: patchy Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick brickname 49152 0 Y 14158 >gluster volume status patchy detail Status of volume: xcube2 ------------------------------------------------------------------------------ Brick : Brick brickname TCP Port : 49152 RDMA Port : 49153 Online : Y Pid : 14158 File System : ext4 Device : /dev/mapper/luks-2099dd4a-0050-4cae-ad7b-c6a0498c4e88 Mount Options : rw,seclabel,relatime,data=ordered Inode Size : 256 Disk Space Free : 31.1GB Total Disk Space : 47.9GB Inode Count : 3203072 Free Inodes : 2926789 >gluster volume status xcube --xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr>(null)</opErrstr> <volStatus> <volumes> <volume> <volName>xcube</volName> <nodeCount>2</nodeCount> <node> <hostname>hostname</hostname> <path>/home/brick1</path> <peerid>2d7bcb95-3d26-4d4f-b3c6-e2ee01b71662</peerid> <status>1</status> <port>49152</port> <ports> <tcp>49152</tcp> <rdma>N/A</rdma> </ports> <pid>5657</pid> </node> <node> <hostname>NFS Server</hostname> <path>localhost</path> <peerid>2d7bcb95-3d26-4d4f-b3c6-e2ee01b71662</peerid> <status>1</status> <port>2049</port> <ports> <tcp>2049</tcp> <rdma>N/A</rdma> </ports> <pid>5665</pid> </node> <tasks/> </volume> </volumes> </volStatus> </cliOutput> Change-Id: I81aab226edbd400d29cd3f510af4f344dd99ba51 BUG: 1164079 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/9191 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-volume.c33
-rw-r--r--cli/src/cli-rpc-ops.c15
-rw-r--r--cli/src/cli-xml-output.c66
-rw-r--r--cli/src/cli.h3
4 files changed, 89 insertions, 28 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 68755630d87..848dffe71d6 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1778,10 +1778,15 @@ void
cli_print_detailed_status (cli_volume_status_t *status)
{
cli_out ("%-20s : %-20s", "Brick", status->brick);
- if (status->online)
- cli_out ("%-20s : %-20d", "Port", status->port);
- else
- cli_out ("%-20s : %-20s", "Port", "N/A");
+
+ if (status->online) {
+ cli_out ("%-20s : %-20d", "TCP Port", status->port);
+ cli_out ("%-20s : %-20d", "RDMA Port", status->rdma_port);
+ } else {
+ cli_out ("%-20s : %-20s", "TCP Port", "N/A");
+ cli_out ("%-20s : %-20s", "RDMA Port", "N/A");
+ }
+
cli_out ("%-20s : %-20c", "Online", (status->online) ? 'Y' : 'N');
cli_out ("%-20s : %-20s", "Pid", status->pid_str);
@@ -1842,7 +1847,7 @@ cli_print_brick_status (cli_volume_status_t *status)
int fieldlen = CLI_VOL_STATUS_BRICK_LEN;
int bricklen = 0;
char *p = NULL;
- int num_tabs = 0;
+ int num_spaces = 0;
p = status->brick;
bricklen = strlen (p);
@@ -1852,25 +1857,27 @@ cli_print_brick_status (cli_volume_status_t *status)
p += fieldlen;
bricklen -= fieldlen;
} else {
- num_tabs = (fieldlen - bricklen) / CLI_TAB_LENGTH + 1;
+ num_spaces = (fieldlen - bricklen) + 1;
printf ("%s", p);
- while (num_tabs-- != 0)
- printf ("\t");
- if (status->port) {
+ while (num_spaces-- != 0)
+ printf (" ");
+ if (status->port || status->rdma_port) {
if (status->online)
- cli_out ("%d\t%c\t%s",
+ cli_out ("%-10d%-11d%-8c%-5s",
status->port,
+ status->rdma_port,
status->online?'Y':'N',
status->pid_str);
else
- cli_out ("%s\t%c\t%s",
+ cli_out ("%-10s%-11s%-8c%-5s",
+ "N/A",
"N/A",
status->online?'Y':'N',
status->pid_str);
}
else
- cli_out ("%s\t%c\t%s",
- "N/A", status->online?'Y':'N',
+ cli_out ("%-10s%-11s%-8c%-5s",
+ "N/A", "N/A", status->online?'Y':'N',
status->pid_str);
bricklen = 0;
}
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index bd133d0ba82..0238a8ff0e7 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -6722,12 +6722,15 @@ gf_cli_status_cbk (struct rpc_req *req, struct iovec *iov,
cli_out ("Status of volume: %s", volname);
if ((cmd & GF_CLI_STATUS_DETAIL) == 0) {
- cli_out ("Gluster process\t\t\t\t\t\tPort\tOnline\tPid");
+ cli_out ("%-*s %s %s %s %s", CLI_VOL_STATUS_BRICK_LEN,
+ "Gluster process", "TCP Port", "RDMA Port",
+ "Online", "Pid");
cli_print_line (CLI_BRICK_STATUS_LINE_LEN);
}
for (i = 0; i <= index_max; i++) {
+ status.rdma_port = 0;
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.hostname", i);
@@ -6751,9 +6754,15 @@ gf_cli_status_cbk (struct rpc_req *req, struct iovec *iov,
!strcmp (hostname, "Snapshot Daemon"))
snprintf (status.brick, PATH_MAX + 255, "%s on %s",
hostname, path);
- else
+ else {
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "brick%d.rdma_port", i);
+ ret = dict_get_int32 (dict, key, &(status.rdma_port));
+ if (ret)
+ continue;
snprintf (status.brick, PATH_MAX + 255, "Brick %s:%s",
hostname, path);
+ }
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.port", i);
@@ -6786,10 +6795,10 @@ gf_cli_status_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
cli_print_line (CLI_BRICK_STATUS_LINE_LEN);
cli_print_detailed_status (&status);
-
} else {
cli_print_brick_status (&status);
}
+
}
cli_out (" ");
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index b4c72eaa84e..b5cbbf68aa4 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -234,14 +234,15 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict,
int brick_index, int *online,
gf_boolean_t *node_present)
{
- int ret = -1;
- char *hostname = NULL;
- char *path = NULL;
- char *uuid = NULL;
- int port = 0;
- int status = 0;
- int pid = 0;
- char key[1024] = {0,};
+ int ret = -1;
+ char *hostname = NULL;
+ char *path = NULL;
+ char *uuid = NULL;
+ int port = 0;
+ int rdma_port = 0;
+ int status = 0;
+ int pid = 0;
+ char key[1024] = {0,};
snprintf (key, sizeof (key), "brick%d.hostname", brick_index);
ret = dict_get_str (dict, key, &hostname);
@@ -294,19 +295,62 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict,
if (ret)
goto out;
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "brick%d.rdma_port", brick_index);
+ ret = dict_get_int32 (dict, key, &rdma_port);
+
/* If the process is either offline or doesn't provide a port (shd)
* port = "N/A"
* else print the port number of the process.
*/
+ /*
+ * Tag 'port' can be removed once console management is started
+ * to support new tag ports.
+ */
+
if (*online == 1 && port != 0)
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"port",
+ "%d", port);
+ else
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"port",
+ "%s", "N/A");
+
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"ports");
+ if (*online == 1 && (port != 0 || rdma_port != 0)) {
+
+ if (port) {
ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"port",
+ (xmlChar *)"tcp",
"%d", port);
- else
+ } else {
ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"port",
+ (xmlChar *)"tcp",
"%s", "N/A");
+ }
+
+ if (rdma_port) {
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"rdma",
+ "%d", rdma_port);
+ } else {
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"rdma",
+ "%s", "N/A");
+ }
+
+ } else {
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"tcp",
+ "%s", "N/A");
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"rdma",
+ "%s", "N/A");
+ }
+
+ ret = xmlTextWriterEndElement (writer);
XML_RET_CHECK_AND_GOTO (ret, out);
memset (key, 0, sizeof (key));
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 89aedc5697d..bdf366b22ed 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -33,7 +33,7 @@
#define CLI_DEFAULT_CMD_TIMEOUT 120
#define CLI_TEN_MINUTES_TIMEOUT 600 //Longer timeout for volume top
#define DEFAULT_CLI_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs"
-#define CLI_VOL_STATUS_BRICK_LEN 55
+#define CLI_VOL_STATUS_BRICK_LEN 43
#define CLI_TAB_LENGTH 8
#define CLI_BRICK_STATUS_LINE_LEN 78
@@ -150,6 +150,7 @@ struct cli_local {
struct cli_volume_status {
int port;
+ int rdma_port;
int online;
uint64_t block_size;
uint64_t total_inodes;